MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / preprocess

Method preprocess

evals/ppl.py:36–46  ·  view source on GitHub ↗

Preprocess text data

(
        examples: Dict[str, List[Any]],
        tokenizer: PreTrainedTokenizer,
        column_name: str = 'text'
    )

Source from the content-addressed store, hash-verified

34
35 @staticmethod
36 def preprocess(
37 examples: Dict[str, List[Any]],
38 tokenizer: PreTrainedTokenizer,
39 column_name: str = 'text'
40 ) -> Dict[str, List[List[int]]]:
41 """Preprocess text data"""
42 tokenized = tokenizer(examples[column_name])
43 return {
44 'input_ids': tokenized['input_ids'],
45 'length': [len(ids) for ids in tokenized['input_ids']]
46 }
47
48 def batchify(self, dataset: Dataset, tokens_per_batch: int) -> Iterator[List[torch.Tensor]]:
49 """Split dataset into batches of exactly block_size length"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected