MCPcopy Create free account
hub / github.com/AMAP-ML/EMF / prepare_dataset

Function prepare_dataset

trl/examples/scripts/rloo/rloo.py:105–120  ·  view source on GitHub ↗

pre-tokenize the dataset before training; only collate during training

(dataset, tokenizer)

Source from the content-addressed store, hash-verified

103 dataset_text_field = "prompt"
104
105 def prepare_dataset(dataset, tokenizer):
106 """pre-tokenize the dataset before training; only collate during training"""
107
108 def tokenize(element):
109 outputs = tokenizer(
110 element[dataset_text_field],
111 padding=False,
112 )
113 return {"input_ids": outputs["input_ids"]}
114
115 return dataset.map(
116 tokenize,
117 batched=True,
118 remove_columns=dataset.column_names,
119 num_proc=training_args.dataset_num_proc,
120 )
121
122 # Compute that only on the main process for faster data processing.
123 # see: https://github.com/huggingface/trl/pull/1255

Callers 1

rloo.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected