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

🃏 Model card for TRL #2123

Merged
merged 63 commits into from
Sep 27, 2024
Merged

🃏 Model card for TRL #2123

merged 63 commits into from
Sep 27, 2024

Conversation

qgallouedec
Copy link
Member

@qgallouedec qgallouedec commented Sep 25, 2024

What does this PR do?

Having our own model card.

Demo

from datasets import load_dataset
from trl import DPOConfig, DPOTrainer
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct")
dataset_name = "trl-lib/tldr-preference"
train_dataset = load_dataset(dataset_name, split="train").select(range(50))
args = DPOConfig(output_dir="dpo-qwen2", logging_steps=10, push_to_hub=True, save_strategy="epoch", num_train_epochs=1)
trainer = DPOTrainer(model=model, args=args, tokenizer=tokenizer, train_dataset=train_dataset)
trainer.train()

if args.push_to_hub:
    trainer.push_to_hub(dataset_name=dataset_name)

result: https://huggingface.co/qgallouedec/dpo-qwen2

It adds

Link to the paper

Screenshot 2024-09-25 at 18 44 17 Screenshot 2024-09-25 at 18 44 22

Link to the dataset

Screenshot 2024-09-25 at 23 12 53 Screenshot 2024-09-25 at 23 13 04

TRL own model card

Screenshot 2024-09-26 at 00 18 28

Other

  • Citations
  • Links to wandb run

TODO

  • AlignPropTrainer
  • BCOTrainer
  • CPOTrainer
  • DPOTrainer
  • GKDTrainer
  • IterativeSFTTrainer
  • KTOTrainer
  • NashMDTrainer
  • OnlineDPOTrainer
  • ORPOTrainer
  • PPOv2Trainer
  • RewardTrainer
  • RLOOTrainer
  • SFTTrainer
  • XPOTrainer

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

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

@qgallouedec qgallouedec marked this pull request as ready for review September 26, 2024 14:59
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.

Amazing work on the model cards @qgallouedec - now they're really packed with useful information 🔥 !!

LGTM with a tweak to the example inference code

examples/scripts/alignprop.py Show resolved Hide resolved
@@ -133,6 +133,6 @@ def tokenize(element):
# Save and push to hub
trainer.save_model(training_args.output_dir)
if training_args.push_to_hub:
trainer.push_to_hub()
trainer.push_to_hub(dataset_name="trl-internal-testing/descriptiveness-sentiment-trl-style")
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: we should move these datasets that aren't strictly used for tests to trl-lib

tests/test_dpo_trainer.py Outdated Show resolved Hide resolved
trl/templates/model_card.md Outdated Show resolved Hide resolved
trl/templates/model_card.md Outdated Show resolved Hide resolved
@qgallouedec
Copy link
Member Author

qgallouedec commented Sep 27, 2024

Note that the code demo for diffusion models and VLM will be wrong but we can probably keep it like that for now

qgallouedec and others added 3 commits September 27, 2024 12:09
Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>
Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>
@valayDave
Copy link

When will this commit be released ? Will it be a part of v0.12 ?

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.

5 participants