MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / _encode

Function _encode

SwissArmyTransformer/examples/bert/finetune_bert_boolq.py:58–63  ·  view source on GitHub ↗
(text, text_pair)

Source from the content-addressed store, hash-verified

56
57
58def _encode(text, text_pair):
59 tokenizer = get_tokenizer()
60 encoded_input = tokenizer(text, text_pair, max_length=args.sample_length, padding='max_length', truncation='only_first')
61 seq_len = len(encoded_input['input_ids'])
62 position_ids = torch.arange(seq_len)
63 return dict(input_ids=encoded_input['input_ids'], position_ids=position_ids.numpy(), token_type_ids=encoded_input['token_type_ids'], attention_mask=encoded_input['attention_mask'])
64
65from sat.data_utils import load_hf_dataset
66def create_dataset_function(path, args):

Callers 1

process_fnFunction · 0.70

Calls 1

get_tokenizerFunction · 0.90

Tested by

no test coverage detected