Skip to content

Add dataset mixer #3791

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add dataset mixer #3791

wants to merge 3 commits into from

Conversation

lewtun
Copy link
Member

@lewtun lewtun commented Jul 28, 2025

What does this PR do?

This PR adds support to mix datasets / config / splits for more effective training recipes. The usage is best demonstrated via a YAML config with something like:

dataset_mixture:
    datasets:
    - id: dataset_id_1
        config: config_name
        columns:
        - col1
        - col2
        weight: 0.5
    - id: dataset_id_2
        config: config_name
        columns:
        - col1
        - col2
        weight: 0.5
    seed: 42
    test_split_size: 0.1

The PR also introduces a helper get_dataset() method to make it simpler to return the dataset from either the mixture or the single dataset setup we had previously.

A few questions:

  1. I am not sure if weight is the right terminology since it's not relative to other configs. An alternative would be frac or pct
  2. Where should this be documented?
  3. Should I add the get_dataset() utitlity function to our training scripts or is this feature best left for power users?
  4. One limitation with the current implementation is that you cannot independently specify which subsets should be mixed as a train or test split (we create a separate test split if requested by the user). Do we need to support this?

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@lewtun lewtun requested review from edbeeching and qgallouedec July 28, 2025 17:39
@qgallouedec
Copy link
Member

Nice! Can you replace load_dataset by get_dataset in the scripts (trl/scripts)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants