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

🏛️ Improve DPO configuration documentation structure #2561

Merged
merged 5 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
31 changes: 12 additions & 19 deletions tests/test_dpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,10 @@ def test_dpo_trainer_padding_token_is_none(self):

with self.assertRaisesRegex(
ValueError,
expected_regex=r"Can't find `pad_token_id` in the `processing_class`. "
r"Explicitly set `tokenizer.pad_token` \(e.g. `tokenizer.pad_token = tokenizer.eos_token`\) "
r"before instantiating the trainer.",
Comment on lines -460 to -462
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new error message

expected_regex=r"`padding_value` is not specified in `DPOConfig`, and `pad_token_id` is missing in "
r"the `processing_class`. Please either set the `padding_value` argument in `DPOConfig`, or set "
r"`tokenizer.pad_token` (e.g., `tokenizer.pad_token = tokenizer.eos_token`) before instantiating the "
r"trainer.",
):
trainer = DPOTrainer(
model=self.model,
Expand Down Expand Up @@ -490,24 +491,16 @@ def test_dpo_trainer_w_dataset_num_proc(self):
dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_preference")

tokenizer = AutoTokenizer.from_pretrained(self.model_id)
tokenizer.pad_token = None

with self.assertRaisesRegex(
ValueError,
expected_regex=r"Can't find `pad_token_id` in the `processing_class`. "
r"Explicitly set `tokenizer.pad_token` \(e.g. `tokenizer.pad_token = tokenizer.eos_token`\) "
r"before instantiating the trainer.",
):
Comment on lines -495 to -500
Copy link
Member Author

@qgallouedec qgallouedec Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably an error: we aren't supposed to test this here, but the num_proc (test_dpo_trainer_w_dataset_num_proc)

trainer = DPOTrainer(
model=self.model,
ref_model=None,
args=training_args,
processing_class=tokenizer,
train_dataset=dummy_dataset["train"],
eval_dataset=dummy_dataset["test"],
)
trainer = DPOTrainer(
model=self.model,
args=training_args,
processing_class=tokenizer,
train_dataset=dummy_dataset["train"],
eval_dataset=dummy_dataset["test"],
)

trainer.train()
trainer.train()

def test_tr_dpo_trainer(self):
with tempfile.TemporaryDirectory() as tmp_dir:
Expand Down
Loading
Loading