What do you want to do?
3 use cases
-
Fine-tune a small model from the command line
Run supervised fine-tuning on Qwen2.5-0.5B with a public dataset using only the TRL CLI.
View prompt
Using huggingface/trl, install it with `pip install trl`, run `trl sft --model_name_or_path Qwen/Qwen2.5-0.5B` with `--dataset_name trl-lib/Capybara` and `--output_dir Qwen2.5-0.5B-SFT`, and tell me how to load the result for a quick chat test.
-
Align a model to preferences with DPO
Train a model on chosen versus rejected answers with DPOTrainer or the TRL dpo command.
View prompt
With huggingface/trl, train a DPO model using `trl dpo --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct` and `--dataset_name argilla/Capybara-Preferences`, then write a small script that compares base and trained answers on 10 prompts from <my list>.
-
Train math reasoning with GRPO
Use GRPOTrainer with the built-in accuracy_reward on a math dataset, the method behind DeepSeek R1.
View prompt
Using huggingface/trl, install `pip install trl[math_verify]`, write a GRPOTrainer script on trl-lib/DeepMath-103K with accuracy_reward and Qwen/Qwen2.5-0.5B-Instruct, and add logging so I can watch the reward climb.
Quick start with TRL
- Check you have what it needs: Python with pip; A GPU is strongly recommended; the README covers NVIDIA, AMD and AWS Trainium setups; Access to Hugging Face Hub models and datasets.
- Open huggingface/trl on GitHub and read the README and license.
- Install TRL with
pip install trl - Run
trl sft --model_name_or_path Qwen/Qwen2.5-0.5Bwith--dataset_name trl-lib/Capybaraand--output_dir Qwen2.5-0.5B-SFT - Wait for training to finish and check the output folder
- Run TRL sft with --help to see more options
These steps come from our top use case, Fine-tune a small model from the command line, which also has a copy-paste agent prompt.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for huggingface/trl
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeAbout this repo
- Who it is forML engineers and tinkerers who want to fine-tune or align open models with standard recipes.
- Why it is hot20k stars, talked about in 2 AI sources we track
- LanguagePython
- Sourcegithub.com/huggingface/trl ยท Back to Hot repos
Requirements
- Python with pip
- A GPU is strongly recommended; the README covers NVIDIA, AMD and AWS Trainium setups
- Access to Hugging Face Hub models and datasets
Add this badge to your README
Maintain TRL? Show readers where to find these use cases.
Markdown
[](https://dedupedai.com/use-cases/huggingface-trl/?utm_source=github&utm_medium=badge&utm_campaign=huggingface-trl)
HTML
<a href="https://dedupedai.com/use-cases/huggingface-trl/?utm_source=github&utm_medium=badge&utm_campaign=huggingface-trl"><img src="https://dedupedai.com/badge/huggingface/trl.svg" alt="Use cases on Deduped" height="20"></a>
A static image, no tracking script. About the badge
Questions about TRL
What is TRL?
TRL is Hugging Face's library for post-training foundation models. It provides trainers for Supervised Fine-Tuning (SFT), GRPO, DPO, KTO and reward modeling on top of Transformers, scales from one GPU to multi-node clusters with Accelerate, integrates PEFT for LoRA and QLoRA, and ships a CLI that fine-tunes without writing code. It is an open-source project on GitHub: https://github.com/huggingface/trl.
How do I use TRL?
Install TRL with pip install trl; then run trl sft --model_name_or_path Qwen/Qwen2.5-0.5B with --dataset_name trl-lib/Capybara and --output_dir Qwen2.5-0.5B-SFT; wait for training to finish and check the output folder. The use cases on this page give the full steps and a copy-paste agent prompt for each job.
Who is TRL for?
ML engineers and tinkerers who want to fine-tune or align open models with standard recipes.
What can I do with TRL?
3 use cases so far, for example: Fine-tune a small model from the command line; Align a model to preferences with DPO; Train math reasoning with GRPO. Each has steps and a copy-paste agent prompt.
What do I need to run TRL?
Python with pip; A GPU is strongly recommended; the README covers NVIDIA, AMD and AWS Trainium setups; Access to Hugging Face Hub models and datasets.
What are alternatives to TRL?
Other hot AI repos in Software and DevOps: ECC, Thinkrail, Superpowers, Deep Infer, Instructor.
Is TRL safe to run?
Deduped does not own, audit or vouch for it. Read the README and license, run it on your own systems first and review every command before you run it.