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

corrects loss function for Self-play Preference Optimization hard label version #1615

Merged
merged 3 commits into from
May 3, 2024

Conversation

angelahzyuan
Copy link
Contributor

@angelahzyuan angelahzyuan commented May 3, 2024

Corrects implementation mentioned in #1612. arxiv: https://arxiv.org/abs/2405.00675. This updates the loss function according to Equation (4.8) with $P(y_w > y_l) = 1$ and $P(y_l > y_w) = 0$, and justified it in doc as the hard label version of the algorithm.
Screenshot 2024-05-02 at 9 01 54 PM

It should work well now for the first iteration. The reported 3 iterations' results were based on the soft label version.

@angelahzyuan angelahzyuan changed the title corrects sppo hard lable version corrects loss function for Self-play Preference Optimization hard lable version May 3, 2024
@angelahzyuan
Copy link
Contributor Author

@winglian

@angelahzyuan angelahzyuan changed the title corrects loss function for Self-play Preference Optimization hard lable version corrects loss function for Self-play Preference Optimization hard label version May 3, 2024
@kashif
Copy link
Collaborator

kashif commented May 3, 2024

@angelahzyuan thank you for the fix! Can you kindly run the pre-commit run --all-files command in the root of trl to fix the formatting etc.

@kashif
Copy link
Collaborator

kashif commented May 3, 2024

@angelahzyuan perhaps move the comment inside the elif of the loss, currently its outside, to avoid confusion

@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.

@angelahzyuan
Copy link
Contributor Author

@kashif done

trl/trainer/dpo_trainer.py Outdated Show resolved Hide resolved
@kashif kashif merged commit 75de236 into huggingface:main May 3, 2024
9 checks passed
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