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

Function _encode

SwissArmyTransformer/examples/roberta/finetune_roberta_wic.py:108–111  ·  view source on GitHub ↗
(text, text_pair)

Source from the content-addressed store, hash-verified

106from transformers.models.roberta.modeling_roberta import create_position_ids_from_input_ids
107
108def _encode(text, text_pair):
109 encoded_input = tokenizer(text, text_pair, max_length=args.sample_length, padding='max_length', truncation='only_first')
110 position_ids = create_position_ids_from_input_ids(torch.tensor([encoded_input['input_ids']]), 1, 0)
111 return dict(input_ids=encoded_input['input_ids'], position_ids=position_ids[0].numpy(), attention_mask=encoded_input['attention_mask'])
112
113from sat.data_utils import load_hf_dataset
114def create_dataset_function(path, args):

Callers 1

process_fnFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected