MCPcopy Create free account
hub / github.com/UIC-Liu-Lab/CPT / tokenize_function

Function tokenize_function

posttrain.py:133–146  ·  view source on GitHub ↗
(examples)

Source from the content-addressed store, hash-verified

131 padding = "max_length" if args.pad_to_max_length else False
132
133 def tokenize_function(examples):
134 # Remove empty lines
135 examples[text_column_name] = [
136 line for line in examples[text_column_name] if len(line) > 0 and not line.isspace()
137 ]
138 return tokenizer(
139 examples[text_column_name],
140 padding=padding,
141 truncation=True,
142 max_length=max_seq_length,
143 # We use this option because DataCollatorForLanguageModeling (see below) is more efficient when it
144 # receives the `special_tokens_mask`.
145 return_special_tokens_mask=True,
146 )
147
148 with accelerator.main_process_first():
149 tokenized_datasets = raw_datasets.map(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected