Preprocess text data
(
examples: Dict[str, List[Any]],
tokenizer: PreTrainedTokenizer,
column_name: str = 'text'
)
| 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""" |
nothing calls this directly
no outgoing calls
no test coverage detected