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

[Trainer] Changing the dataset dynamically during training #2227

Open
ilyasoulk opened this issue Oct 14, 2024 · 1 comment
Open

[Trainer] Changing the dataset dynamically during training #2227

ilyasoulk opened this issue Oct 14, 2024 · 1 comment
Labels
🏋 DPO Related to DPO ❓ question Seeking clarification or more information

Comments

@ilyasoulk
Copy link

Hello,

I am currently training a model using DPO, and I'm adapting the dataset dynamically during training. My current approach looks like this:

trainer = DPOTrainer(
    model,
    None,
    args=training_args,
    train_dataset=dataset,
    tokenizer=tokenizer,
    peft_config=peft_config,
    beta=args.beta,
    max_prompt_length=1024,
    max_length=1536,
)
for i in range(repetitions):
    train_result = trainer.train()
    # Adapt the dataset based on the training result
    dataset = get_adapted_dataset(train_result)
    with PartialState().local_main_process_first():
        # Tokenize the updated dataset
        print("Updating the training dataset")
        trainer.train_dataset = dataset.map(trainer.tokenize_row, num_proc=None)

Is this the correct way to adapt the dataset during training, or is there a more appropriate approach for this scenario?

@qgallouedec
Copy link
Member

Using an iterable dataset might be more suited. If the way you update the dataset depends on the results, you'll probably need to set a callback as well

@qgallouedec qgallouedec added ❓ question Seeking clarification or more information 🏋 DPO Related to DPO labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏋 DPO Related to DPO ❓ question Seeking clarification or more information
Projects
None yet
Development

No branches or pull requests

2 participants