Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update parsing of dataset_config.file to prevent custom-function-name from clobbering data-collator name. #829

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion recipes/quickstart/finetuning/datasets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_custom_dataset(dataset_config, tokenizer, split: str):
```
For an example `get_custom_dataset` you can look at the provided datasets in llama_recipes.datasets or [custom_dataset.py](./custom_dataset.py).
The `dataset_config` in the above signature will be an instance of llama_recipes.configs.dataset.custom_dataset with the modifications made through the command line.
The split signals wether to return the training or validation dataset.
The split signals whether to return the training or validation dataset.
The default function name is `get_custom_dataset` but this can be changed as described below.

In order to start a training with the custom dataset we need to set the `--dataset` as well as the `--custom_dataset.file` parameter.
Expand All @@ -47,6 +47,8 @@ python -m llama_recipes.finetuning --dataset "custom_dataset" --custom_dataset.f
```
This will call the function `get_foo` instead of `get_custom_dataset` when retrieving the dataset.

If you need to use a custom data collator, name it `get_data_collator` in the same file as `get_foo`.

### Adding new dataset
Each dataset has a corresponding configuration (dataclass) in [configs/datasets.py](../../../../src/llama_recipes/configs/datasets.py) which contains the dataset name, training/validation split names, as well as optional parameters like datafiles etc.

Expand Down
2 changes: 1 addition & 1 deletion src/llama_recipes/datasets/custom_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_custom_dataset(dataset_config, tokenizer, split: str):

def get_data_collator(dataset_processer,dataset_config):
if ":" in dataset_config.file:
module_path, func_name = dataset_config.file.split(":")
module_path, func_name = dataset_config.file.split(":")[0], "get_data_collator"
else:
module_path, func_name = dataset_config.file, "get_data_collator"

Expand Down