talira

A comprehensive library to post-train foundation models

open sourceApache-2.0free

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 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.

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 toolplan not known

Alternatives

The same job

These do what TRL does.

  1. Unsloth Run and train AI models on your own local hardware via an open-source UI
  2. Axolotl A free and open source framework for fine-tuning and post-training large language models
  3. LlamaFactory An open source framework for fine-tuning 100+ language and vision-language models from a CLI or a web UI
  4. OpenRLHF Scalable RLHF and agentic RL framework on Ray and vLLM
  5. verl Flexible, efficient reinforcement learning post-training for LLMs
  6. MLX LM Run and fine-tune LLMs on Apple silicon with MLX

Compare TRL with the top 3