MCPcopy Create free account
hub / github.com/AnswerDotAI/ModernBERT / _tokenize

Method _tokenize

src/text_data.py:205–210  ·  view source on GitHub ↗
(self, text_sample)

Source from the content-addressed store, hash-verified

203
204 # How to tokenize a text sample to a token sample
205 def _tokenize(self, text_sample):
206 if self.tokenizer._pad_token is None:
207 # Some tokenizers (e.g. GPT2 tokenizer) have no padding token which causes bugs
208 raise RuntimeError("If tokenizing on-the-fly, tokenizer must have a pad_token_id")
209
210 return self.tokenizer(text_sample["text"], truncation=True, padding="max_length", max_length=self.max_seq_len)
211
212 def _read_binary_tokenized_sample(self, sample: BatchEncoding):
213 seq_len = sample["len"] if "len" in sample else len(sample["input_ids"])

Callers 1

__getitem__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected