trl
Train transformer language models with reinforcement learning.
Decision gist · record as of 2026-08-14
Yes. TRL is actively maintained (release 1 day old), has no known vulnerabilities, low install friction, and a permissive license. It is the standard library for post-training transformer models in the Hugging Face ecosystem. Install it if you need to fine-tune, align, or distill language models with modern techniques; skip it only if you are working exclusively with inference or base model training.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; GPU or accelerator hardware strongly recommended for practical training.
- Low friction install with a pure Python wheel.
- Actively maintained with a release 1 day old and 19071 repository stars.
License · maintenance · safety
Apache-2.0 (permissive) — Apache-2.0 permissive license allows commercial and private use with minimal restrictions; source code changes must be documented but derivative works are permitted.
last release 2026-08-13 (1 days) · last repo commit 2026-08-14 · 19,071 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,711,636 downloads/mo, #2,521 on PyPI
Alternatives
Verify before relying
pip install trl
from trl import SFTTrainer
from datasets import load_dataset
dataset = load_dataset("trl-lib/Capybara", split="train")
trainer = SFTTrainer(
model="Qwen/Qwen2.5-0.5B",
train_dataset=dataset,
)
trainer.train()- Whether DistillationTrainer's vLLM integration requires vLLM as an optional dependency or if it is bundled.
- Memory requirements and typical training time for the example models mentioned.
- Whether PEFT and Unsloth integrations are optional or required for certain trainers.
What it is and what it does
TRL is a post-training library for transformer language models that wraps the Hugging Face Transformers ecosystem with specialized trainer classes for advanced alignment techniques. It implements methods like Supervised Fine-Tuning (SFT), Direct Preference Optimization (DPO), Group Relative Policy Optimization (GRPO), Kahneman-Tversky Optimization (KTO), and knowledge distillation, each exposed as a trainer class that handles distributed training, gradient accumulation, and hardware scaling automatically.
The library is designed to work with models of any size by integrating with accelerate for multi-GPU and multi-node setups, and with PEFT for parameter-efficient training on large models via quantization and LoRA. It supports a command-line interface for quick experimentation without writing code, and provides an experimental API for unstable features. All trainers are thin wrappers around the Transformers trainer, meaning they inherit its distributed training support (DDP, DeepSpeed ZeRO, FSDP) and ecosystem compatibility.
Use it for
- Fine-tune a base language model on domain-specific instruction data using SFTTrainer to create a specialized assistant.
- Align a model with human preferences by training on paired preference data using DPOTrainer or GRPOTrainer.
- Train a reward model to score model outputs for use in reinforcement learning pipelines with RewardTrainer.
- Distill a large teacher model into a smaller student model using DistillationTrainer with memory-efficient chunked loss.
- Quickly prototype alignment techniques via the CLI without writing Python code for SFT, DPO, or KTO workflows.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
TRL is actively maintained (release 1 day old), has no known vulnerabilities, low install friction, and a permissive license. It is the standard library for post-training transformer models in the Hugging Face ecosystem. Install it if you need to fine-tune, align, or distill language models with modern techniques; skip it only if you are working exclusively with inference or base model training.
Install
trl on PyPI
Before you install
Low friction install with a pure Python wheel. Actively maintained with a release 1 day old and 19071 repository stars. Requires Python 3.10 or later and five runtime dependencies (accelerate, datasets, jinja2, packaging, transformers).
Requires Python 3.10 or later; GPU or accelerator hardware strongly recommended for practical training.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; source code changes must be documented but derivative works are permitted.
Quickstart
pip install trl
from trl import SFTTrainer
from datasets import load_dataset
dataset = load_dataset("trl-lib/Capybara", split="train")
trainer = SFTTrainer(
model="Qwen/Qwen2.5-0.5B",
train_dataset=dataset,
)
trainer.train()
Verify before relying
- Whether DistillationTrainer's vLLM integration requires vLLM as an optional dependency or if it is bundled.
- Memory requirements and typical training time for the example models mentioned.
- Whether PEFT and Unsloth integrations are optional or required for certain trainers.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 5 packagesacceleratedatasetsjinja2packagingtransformers |
| Maintenance | Actively maintained 1 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,711,636 / month, #2,521 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 2 - Pre-AlphaIntended Audience :: DevelopersIntended Audience :: Science/ResearchNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14 |
Evidence: trl-1.10.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “fine-tune language models with reinforcement learning”
- trlTRL provides trainer classes for post-training foundation models…
- google-tunixTunix is a JAX-based library for post-training large language models…
- tinker_cookbookTinker Cookbook provides recipes and abstractions for fine-tuning…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also google-tunix · setfit · tinker_cookbook · verl · peft · transformer-smaller-training-vocab · ms-swift · verifiers · coqui-tts-trainer