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

Function _encode

SwissArmyTransformer/examples/roberta/finetune_roberta_wsc.py:136–139  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

134from transformers.models.roberta.modeling_roberta import create_position_ids_from_input_ids
135
136def _encode(text):
137 encoded_input = tokenizer(text, max_length=args.sample_length, padding='max_length', truncation='only_first')
138 position_ids = create_position_ids_from_input_ids(torch.tensor([encoded_input['input_ids']]), 1, 0)
139 return dict(input_ids=encoded_input['input_ids'], position_ids=position_ids[0].numpy(), attention_mask=encoded_input['attention_mask'])
140
141import spacy
142

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected