trl icon indicating copy to clipboard operation
trl copied to clipboard

Add support for IterableDataset for DPOTrainer

Open h-tonywu opened this issue 1 year ago • 0 comments

Feature request

The DPOTrainer should accept instances of datasets.IterableDataset for the following input args:

  • train_dataset
  • eval_dataset.

For the moment, it only accepts datasets.Dataset inputs.

Motivation

Currently, the users of DPOTrainer must materialize their dataset in memory using a datasets.Dataset. For large scale datasets (e.g. Chat Vision examples), this is intractable. Another use case is that some users might be interested in having an infinite dataset where examples are generated on-the-fly or sampled from a fixed distribution.

According to the docstring and to the DPOTrainer._prepare_dataset method, it seems that DPO Trainer should accept. A few changes in the kwargs fed to _prepare_dataset should make it work.

Your contribution

I have already made a working branch with successful runs on this PR: https://github.com/huggingface/trl/pull/3559.

Changes are quite minimal, so review should be straightforward! 🤗

h-tonywu avatar Jun 10 '25 10:06 h-tonywu