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
trl env— print system and dependency informationtrl vllm-serve— start a vLLM generation servertrl skills— manage TRL agent skills
Basic usage
Specify the model and dataset directly as flags:- SFT
- DPO
- GRPO
- RLOO
- KTO
- Reward
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_rewardreasoning_accuracy_rewardthink_format_rewardget_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:- SFT
- DPO
- GRPO
--config override values in the file.
Multi-GPU and distributed training
The TRL CLI natively supports Accelerate. Pass anyaccelerate 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:
Dataset mixtures
Combine multiple datasets into a single training dataset using thedatasets key in your config file:
- SFT
- DPO
- GRPO
DatasetConfig and DatasetMixtureConfig for all available dataset mixture keywords.