(
self,
tokenizer_path: Path,
destination_path: Path,
chunk_size: int,
train_val_split_ratio: float,
filepaths: List[str],
progress_queue: Queue,
process_id: int = 0,
)
| 345 | process.join() |
| 346 | |
| 347 | def process_data( |
| 348 | self, |
| 349 | tokenizer_path: Path, |
| 350 | destination_path: Path, |
| 351 | chunk_size: int, |
| 352 | train_val_split_ratio: float, |
| 353 | filepaths: List[str], |
| 354 | progress_queue: Queue, |
| 355 | process_id: int = 0, |
| 356 | ) -> None: |
| 357 | previous_iteration_time = None |
| 358 | total_tasks = len(filepaths) |
| 359 | tasks_completed = 0 |
| 360 | |
| 361 | try: |
| 362 | assert len(filepaths) > 0, 'No files provided.' |
| 363 | |
| 364 | training_outdir = destination_path / 'train' |
| 365 | |
| 366 | # If path don't exist make it. |
| 367 | training_outdir.mkdir(parents=True, exist_ok=True) |
| 368 | |
| 369 | tokenizer = Tokenizer(tokenizer_path) |
| 370 | |
| 371 | training_dataset_builder = PackedDatasetBuilder( |
| 372 | outdir=training_outdir, |
| 373 | # Use process_id to differentiate builders |
| 374 | prefix=f'train_{self.dataset_name}_{process_id}', |
| 375 | chunk_size=chunk_size, |
| 376 | # NOTE: `sep_token` does not work as it says. |
| 377 | # See https://github.com/Lightning-AI/lit-llama/issues/482 |
| 378 | # Consequently, it a token that fills up the initial tensor. |
| 379 | # And works more like a pad token. |
| 380 | # Also see issue: https://github.com/jzhang38/TinyLlama/issues/83 |
| 381 | pad_token=tokenizer.pad_id, |
| 382 | dtype='auto', |
| 383 | vocab_size=tokenizer.vocab_size, |
| 384 | ) |
| 385 | |
| 386 | validation_dataset_builder = None |
| 387 | splitter = None |
| 388 | |
| 389 | if train_val_split_ratio < 1.0: |
| 390 | validation_outdir = destination_path / 'validation' |
| 391 | validation_outdir.mkdir(parents=True, exist_ok=True) |
| 392 | validation_dataset_builder = PackedDatasetBuilder( |
| 393 | outdir=validation_outdir, |
| 394 | # Use process_id to differentiate builders |
| 395 | prefix=f'validation_{self.dataset_name}_{process_id}', |
| 396 | chunk_size=chunk_size, |
| 397 | pad_token=tokenizer.pad_id, |
| 398 | dtype='auto', |
| 399 | vocab_size=tokenizer.vocab_size, |
| 400 | ) |
| 401 | splitter = Splitter(train_val_split_ratio) |
| 402 | |
| 403 | for filepath in filepaths: |
| 404 | try: |
nothing calls this directly
no test coverage detected