TRL is the alignment toolkit
trl (Transformer Reinforcement Learning) is the canonical Python library for: SFT (we covered this), DPO (Direct Preference Optimization), PPO (Proximal Policy Optimization for RLHF), KTO, IPO, ORPO, GRPO, and other preference / RL methods. The dominant 2026 default for alignment is DPO — it skips the reward-model + PPO loop and trains directly on preference pairs.
DPO in 30 seconds
DPO takes pairs (prompt, chosen, rejected). The objective increases probability of chosen relative to rejected using a closed-form bound that mirrors RLHF without the RL. Training looks like SFT with a different loss; converges fast; doesn't need a separate reward model.