# TRL

> A comprehensive library to post-train foundation models

Source: https://talira.ai/catalog/trl-ryrdxeq8
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library, Command-line tool
- Categories: [ai / ml / fine tuning](https://talira.ai/categories/ai/ml/fine-tuning), [languages / python](https://talira.ai/categories/languages/python)
- Licence: Apache-2.0[^1]
- Pricing: Free and open source
- Free tier: yes
- Backed by: [Hugging Face](https://talira.ai/orgs/hugging-face.md)

TRL (Transformers Reinforcement Learning) is Hugging Face's Python library for post-training language models: supervised fine-tuning, preference optimization (DPO, KTO, ORPO), reinforcement learning with GRPO, RLOO and an asynchronous GRPO trainer that streams rollouts from a vLLM server, reward modelling and knowledge distillation. Each trainer is a light wrapper around the [Transformers](https://talira.ai/catalog/transformers-fxs828eh.md) trainer, so it scales from one GPU to multi-node clusters with DDP, DeepSpeed ZeRO and FSDP through Accelerate, and trains LoRA and QLoRA adapters on modest hardware through PEFT. A command-line interface fine-tunes models without writing code.

## Links

- Website: https://huggingface.co/docs/trl
- GitHub: https://github.com/huggingface/trl
- Docs: https://huggingface.co/docs/trl

## Problems it solves

- fine-tune an open LLM on my own chat dataset with a few lines of Python
- align a language model to human preferences with DPO instead of a full RLHF pipeline
- train a reasoning model with GRPO and verifiable rewards like DeepSeek-R1
- run reinforcement learning on an LLM with generation offloaded to vLLM so the GPUs aren't idle
- train a reward model from pairs of preferred and rejected answers
- distil a large model into a smaller one for cheaper inference
- fine-tune a large model on modest GPUs with LoRA or QLoRA adapters
- fine-tune a model from the command line without writing a training script

## Features

- SFTTrainer for supervised fine-tuning
- DPOTrainer, KTOTrainer, CPO and ORPO for preference optimization
- GRPOTrainer, AsyncGRPOTrainer and RLOOTrainer for online RL
- RewardTrainer for reward models
- Knowledge distillation trainers
- Scales with Accelerate, DDP, DeepSpeed ZeRO and FSDP
- PEFT integration for LoRA and QLoRA
- vLLM generation for online methods
- Unsloth integration
- Command-line interface

## Capabilities

- Has a command line tool: plan not known

## Trust

Overall: 0.76 out of 1.
Signals: maintenance 1.00, adoption 0.86, momentum 0.72, community 1.00, backing 0.30, extensibility 0.20.

- last commit 5 days ago
- 860 commits in the last 90 days
- latest release v1.18.2 10 days ago
- 19.8k GitHub stars
- 543 contributors
- backed by Hugging Face

## Related

- Based on [Transformers](https://talira.ai/catalog/transformers-fxs828eh.md)

## Alternatives

- [Unsloth](https://talira.ai/catalog/unsloth-sdmq90qx.md): Run and train AI models on your own local hardware via an open-source UI
- [Axolotl](https://talira.ai/catalog/axolotl-9ht2yme4.md): A free and open source framework for fine-tuning and post-training large language models
- [LlamaFactory](https://talira.ai/catalog/llamafactory-7swv7mxz.md): An open source framework for fine-tuning 100+ language and vision-language models from a CLI or a web UI
- [OpenRLHF](https://talira.ai/catalog/openrlhf-kzgavqp9.md): Scalable RLHF and agentic RL framework on Ray and vLLM
- [verl](https://talira.ai/catalog/verl-mggfesa0.md): Flexible, efficient reinforcement learning post-training for LLMs
- [MLX LM](https://talira.ai/catalog/mlx-lm-rb2gav1w.md): Run and fine-tune LLMs on Apple silicon with MLX

## Sources

[^1]: https://github.com/huggingface/trl/blob/main/LICENSE (checked 25 Nov 2026)
