Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

TRL

Hugging Face's post-training library: supervised fine-tuning, DPO, GRPO and reward models.

By Hugging FaceChecked
Visit huggingface.co(opens in a new tab)
Bookmark

Bookmarks are kept in your free account, so you can find this page again on any device.

Sign in to bookmark

What 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

  • Axolotl

    Config-driven toolkit for fine-tuning open models, from LoRA to full multi-GPU runs.

    Open source

  • Unsloth

    Faster, lower-memory LoRA and QLoRA fine-tuning for open models.

    Open sourceUnsloth

  • MLX LM

    Runs and fine-tunes LLMs on Apple silicon with MLX.

    Models and local inferenceOpen source

  • Modal

    Serverless cloud for running Python on GPUs for inference, batch jobs and training.

    Models and local inferenceUsage-basedModal

  • Sentence Transformers

    Python library for embedding and reranker models.

    Retrieval and vector searchOpen sourceHugging Face

  • Transformers

    Hugging Face's library of open model definitions.

    Models and local inferenceOpen sourceHugging Face

All Fine-tuning