What problem does it solve? Aligning language models with human preferences requires complex RLHF pipelines involving supervised fine-tuning, reward modeling, and reinforcement learning, which are difficult to implement correctly from scratch. ## Core Features & Use Cases - Supervised Fine-Tuning (SFT): Train base models on instruction-following data with support for chat templates, sequence packing, LoRA, and multi-GPU training. - Preference Alignment (DPO): Align models using chosen/rejected preference pairs without a reward model, with 10+ loss variants including IPO, hinge, and robust DPO. - Online RL (PPO/GRPO): Optimize policies with reward models or custom reward functions, with GRPO offering memory-efficient training. - Reward Model Training: Train Bradley-Terry reward models on preference data for use in PPO pipelines. - Use Case: Take a base Qwen model, run SFT on instruction data, train a reward model on UltraFeedback preferences, then apply PPO to produce a human-aligned chat model. ## Quick Start Fine-tune Qwen2.5-0.5B with DPO on the trl-lib/ultrafeedback_binarized preference dataset using TRL.