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

[DPO] add KTO loss #1075

Merged
merged 5 commits into from
Dec 11, 2023
Merged

[DPO] add KTO loss #1075

merged 5 commits into from
Dec 11, 2023

Conversation

kashif
Copy link
Collaborator

@kashif kashif commented Dec 8, 2023

add Tahneman-Tversky optimization (KTO) loss function from https://github.com/ContextualAI/HALOs]

fixes #1072

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

Copy link
Member

@lewtun lewtun left a comment

Choose a reason for hiding this comment

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

Super fast addition @kashif ! I've checked the equations and it looks good to me 🔥

trl/trainer/dpo_trainer.py Outdated Show resolved Hide resolved
kashif and others added 2 commits December 8, 2023 12:06
Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>
Copy link
Contributor

@vwxyzjn vwxyzjn left a comment

Choose a reason for hiding this comment

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

Nice work @kashif! This is blazing fast. Maybe in a follow-up PR you can add a test example using anthropic's hh?

trl/trainer/dpo_trainer.py Outdated Show resolved Hide resolved
docs/source/dpo_trainer.mdx Outdated Show resolved Hide resolved
@kashif kashif mentioned this pull request Dec 10, 2023
@kashif kashif merged commit d275cb4 into huggingface:main Dec 11, 2023
9 checks passed
@kashif kashif deleted the KTO branch December 11, 2023 10:41
lapp0 pushed a commit to lapp0/trl that referenced this pull request May 10, 2024
* add KTO loss

* fix docs

* Update trl/trainer/dpo_trainer.py

Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>

* formatting

* add link to papers

---------

Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>
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.

Implement KTO
4 participants