Hugging Face TRL logo
AI Developer Tools FREEMIUM from $9/mo

Hugging Face TRL

TRL, short for Transformers Reinforcement Learning, is a Hugging Face library for post-training transformer language models.

It provides trainers for Supervised Fine-Tuning, Group Relative Policy Optimization, Direct Preference Optimization, reward modeling and more, with experimental online and offline methods and knowledge distillation…

Hugging Face TRL screenshot

TRL, short for Transformers Reinforcement Learning, is a Hugging Face library for post-training transformer language models. It provides trainers for Supervised Fine-Tuning, Group Relative Policy Optimization, Direct Preference Optimization, reward modeling and more, with experimental online and offline methods and knowledge distillation trainers. It is integrated with the Hugging Face transformers library and documented on the Hugging Face site, with getting started, conceptual and how-to guides. As an open-source library it has no subscription.

TRL targets machine learning engineers, applied researchers and advanced students who already work in Python and want to align or specialize language models. The documentation walks through dataset formats, training logs, reducing memory use, speeding up training and distributing training across devices. Beginners can learn post-training with the smol course the maintainers link, while experts can explore experimental trainers. Anyone using Hugging Face models, datasets and Hub will find the workflow familiar.

A team can fine-tune an assistant model on curated conversations with SFTTrainer, then apply DPO using preference pairs to shape its behavior. Researchers train reasoning models with GRPO, drawing on posts such as the Open-R1 reproduction of DeepSeek-R1, and vision language teams align multimodal models. Engineers cut memory use with PEFT adapters, DeepSpeed and Liger Kernel integrations and scale runs across GPUs. Co-located vLLM generation speeds up online reinforcement learning, and the examples section offers community tutorials. Blog posts also cover Ulysses sequence parallelism for million-token contexts and weight syncing for very large models.

Hugging Face TRL alternatives

See all →

Frequently asked

6 questions
What does TRL do?
TRL provides trainers for post-training transformer language models with methods including SFT, GRPO, DPO and reward modeling. It is integrated with the Hugging Face transformers library.
Who is TRL meant for?
Machine learning engineers and researchers who work in Python and want to fine-tune or align language models. Learners can start with the smol course.
How can TRL be used to align a model with preferences?
Prepare a preference dataset and train with DPOTrainer, or use KTO and other offline methods. Online methods such as GRPO are available for reward-driven training.
Does TRL cost anything?
Open-source status means using it carries no subscription. Compute for training depends on the hardware you use.
What are the limits of TRL?
Python and suitable GPU resources are required, since this is a code library rather than a no-code product. Some trainers are labeled experimental.
What does TRL integrate with?
Transformers, PEFT, DeepSpeed and Liger Kernel are supported, and the docs cover reducing memory usage and distributing training. Installation and a quickstart are in the Getting Started section.

Reviews (0)

Write review

No reviews yet. Be the first to share your experience.