TRL
Hugging Face's post-training library: supervised fine-tuning, DPO, GRPO and reward models.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkWhat it is
TRL (Transformer Reinforcement Learning) is Hugging Face's library for post-training. It provides trainers for supervised fine-tuning, DPO, GRPO, reward modelling and more, built on Transformers.
The stable trainers include SFTTrainer for instruction tuning, DPOTrainer and KTOTrainer for preference data, RewardTrainer, and GRPOTrainer and RLOOTrainer for online reinforcement learning, where an asynchronous GRPO trainer streams rollouts from a vLLM server. It works with PEFT for LoRA adapters and with DeepSpeed for larger runs, and Unsloth builds on it for faster single-GPU training. A typical first step is an SFT run on a small model with a chat dataset from the Hugging Face Hub.
Best for
Post-training experiments on the Hugging Face stack.
Skills it helps with
Related tools
Axolotl
Config-driven toolkit for fine-tuning open models, from LoRA to full multi-GPU runs.
Unsloth
Faster, lower-memory LoRA and QLoRA fine-tuning for open models.
MLX LM
Runs and fine-tunes LLMs on Apple silicon with MLX.
Modal
Serverless cloud for running Python on GPUs for inference, batch jobs and training.
Sentence Transformers
Python library for embedding and reranker models.
Transformers
Hugging Face's library of open model definitions.