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

Function _encode

SwissArmyTransformer/examples/roberta/finetune_roberta_rte.py:73–76  ·  view source on GitHub ↗
(text, text_pair)

Source from the content-addressed store, hash-verified

71from transformers.models.roberta.modeling_roberta import create_position_ids_from_input_ids
72
73def _encode(text, text_pair):
74 encoded_input = tokenizer(text, text_pair, max_length=args.sample_length, padding='max_length', truncation='only_first')
75 position_ids = create_position_ids_from_input_ids(torch.tensor([encoded_input['input_ids']]), 1, 0)
76 return dict(input_ids=encoded_input['input_ids'], position_ids=position_ids[0].numpy(), attention_mask=encoded_input['attention_mask'])
77
78from sat.data_utils import load_hf_dataset
79def create_dataset_function(path, args):

Callers 1

process_fnFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected