MCPcopy Create free account
hub / github.com/MuLabPKU/TransArch / tokenize

Function tokenize

TransMLA_NeurIPS_2025/transmla/utils.py:163–173  ·  view source on GitHub ↗
(data_batch)

Source from the content-addressed store, hash-verified

161 ds = datasets.Dataset.from_dict({data_name: new_data_list})
162
163 def tokenize(data_batch):
164 # tokenize then pad each batch according to the longest sequence in the batch
165 batch = tokenizer(
166 data_batch[data_name],
167 padding="longest",
168 max_length=max_seqlen,
169 truncation=True,
170 return_tensors="pt",
171 )
172 batch["labels"] = batch["input_ids"].clone()
173 return batch
174
175 # tokenize lazily
176 ds.set_transform(tokenize)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected