Skip to main content
TRL provides a command-line interface (CLI) to fine-tune large language models using methods like SFT, DPO, GRPO, and more. The CLI abstracts away boilerplate so you can launch training jobs quickly and reproducibly.

Available commands

trl sft

Supervised fine-tuning

trl dpo

Direct Preference Optimization

trl grpo

Group Relative Policy Optimization

trl rloo

REINFORCE Leave-One-Out

trl kto

Kahneman-Tversky Optimization

trl reward

Reward model training
Other commands:
  • trl env — print system and dependency information
  • trl vllm-serve — start a vLLM generation server
  • trl skills — manage TRL agent skills

Basic usage

Specify the model and dataset directly as flags:

Key flags

Model flags (ModelConfig)

Training flags (shared across trainers)

SFT-specific flags

DPO-specific flags

GRPO-specific flags

Built-in reward_funcs values for GRPO and RLOO:
  • accuracy_reward
  • reasoning_accuracy_reward
  • think_format_reward
  • get_soft_overlong_punishment
  • Any dotted import path (e.g. my_lib.rewards.custom_reward)

Using config files

Define all training arguments in a YAML config file for cleaner, reproducible runs:
CLI flags passed alongside --config override values in the file.

Multi-GPU and distributed training

The TRL CLI natively supports Accelerate. Pass any accelerate launch argument directly, such as --num_processes:

Using --accelerate_config

The --accelerate_config flag selects a distributed training strategy. It accepts either a predefined profile name or a path to a custom Accelerate YAML config file. Predefined profiles:
Or in a config file:

Dataset mixtures

Combine multiple datasets into a single training dataset using the datasets key in your config file:
See DatasetConfig and DatasetMixtureConfig for all available dataset mixture keywords.

LoRA training example

Full SFT training with LoRA via the CLI:

Getting system information

Print system and dependency versions for bug reports:
This outputs platform, Python, PyTorch, Transformers, Accelerate, TRL, and optional dependency versions.