> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/huggingface/trl/llms.txt
> Use this file to discover all available pages before exploring further.

# TRL - Transformers Reinforcement Learning

> A comprehensive library for post-training foundation models with SFT, GRPO, DPO, and reinforcement learning from human feedback.

TRL is a full-stack Python library for post-training transformer language models. Built on top of the Hugging Face ecosystem, it provides state-of-the-art algorithms for supervised fine-tuning, preference optimization, and reinforcement learning from human feedback (RLHF) — scaling from a single GPU to multi-node clusters.

<CardGroup cols={2}>
  <Card title="Quick Start" icon="rocket" href="/quickstart">
    Fine-tune your first model in minutes with SFT, DPO, or GRPO
  </Card>

  <Card title="Installation" icon="download" href="/installation">
    Install TRL with pip and set up your environment
  </Card>

  <Card title="Trainers" icon="brain" href="/sft-trainer">
    Explore SFT, GRPO, DPO, Reward, RLOO and more
  </Card>

  <Card title="API Reference" icon="code" href="/api/callbacks">
    Full API docs for trainers, configs, utilities, and callbacks
  </Card>
</CardGroup>

## Training algorithms

TRL covers the full post-training pipeline — from initial fine-tuning to reward modeling and RL-based alignment.

<CardGroup cols={2}>
  <Card title="SFT Trainer" icon="graduation-cap" href="/sft-trainer">
    Supervised fine-tuning with packing, chat templates, and LoRA support
  </Card>

  <Card title="GRPO Trainer" icon="trophy" href="/grpo-trainer">
    Group Relative Policy Optimization — the algorithm behind DeepSeek-R1
  </Card>

  <Card title="DPO Trainer" icon="thumbs-up" href="/dpo-trainer">
    Direct Preference Optimization for human preference alignment
  </Card>

  <Card title="Reward Trainer" icon="star" href="/reward-trainer">
    Train reward models for RLHF pipelines
  </Card>
</CardGroup>

## Get started

<Steps>
  <Step title="Install TRL">
    ```bash theme={null}
    pip install trl
    ```
  </Step>

  <Step title="Load a dataset">
    ```python theme={null}
    from datasets import load_dataset
    dataset = load_dataset("trl-lib/Capybara", split="train")
    ```
  </Step>

  <Step title="Train your model">
    ```python theme={null}
    from trl import SFTTrainer

    trainer = SFTTrainer(
        model="Qwen/Qwen2.5-0.5B",
        train_dataset=dataset,
    )
    trainer.train()
    ```
  </Step>

  <Step title="Scale up">
    Use the [CLI](/clis), [DeepSpeed](/deepspeed-integration), or [vLLM](/vllm-integration) integrations to scale to multi-GPU and multi-node setups.
  </Step>
</Steps>

## Key features

<CardGroup cols={2}>
  <Card title="Efficient scaling" icon="server">
    Leverage Accelerate for DDP, DeepSpeed ZeRO, and FSDP across single GPU to multi-node clusters
  </Card>

  <Card title="Memory-efficient training" icon="memory">
    Full PEFT/LoRA/QLoRA integration and quantization support for training on consumer hardware
  </Card>

  <Card title="vLLM acceleration" icon="bolt">
    Fast online generation with co-located vLLM for RL-based training methods
  </Card>

  <Card title="Command Line Interface" icon="terminal" href="/clis">
    Fine-tune without writing code using the `trl` CLI
  </Card>
</CardGroup>
