-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for auto packing ratio (#683)
- Loading branch information
Showing
14 changed files
with
587 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2022 MosaicML LLM Foundry authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Dataloader builder utilities.""" | ||
|
||
from composer import DataSpec | ||
from omegaconf import DictConfig | ||
from transformers import PreTrainedTokenizerBase | ||
|
||
from llmfoundry.data.denoising import build_text_denoising_dataloader | ||
from llmfoundry.data.finetuning.dataloader import build_finetuning_dataloader | ||
from llmfoundry.data.text_data import build_text_dataloader | ||
|
||
|
||
def build_dataloader(cfg: DictConfig, tokenizer: PreTrainedTokenizerBase, | ||
device_batch_size: int) -> DataSpec: | ||
"""Builds a dataloader from a config. | ||
Args: | ||
cfg (DictConfig): An omegaconf dictionary used to configure the loader. | ||
tokenizer (PreTrainedTokenizerBase): The tokenizer that the model will use. | ||
device_batch_size (int): The size of the batches (number of examples) | ||
that the dataloader will produce. | ||
""" | ||
if cfg.name == 'text': | ||
return build_text_dataloader( | ||
cfg, | ||
tokenizer, | ||
device_batch_size, | ||
) | ||
elif cfg.name == 'text_denoising': | ||
return build_text_denoising_dataloader( | ||
cfg, | ||
tokenizer, | ||
device_batch_size, | ||
) | ||
elif cfg.name == 'finetuning': | ||
return build_finetuning_dataloader( | ||
cfg, | ||
tokenizer, | ||
device_batch_size, | ||
) | ||
else: | ||
raise ValueError(f'Not sure how to build dataloader with config: {cfg}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.