Hugging Face library for post-training LLMs: SFT, DPO, GRPO, PPO, reward modeling. Current version is 0.29.1 (Mar 2026). Requires Python >=3.10. Extremely high API churn — major parameter renames across versions. tokenizer= renamed to processing_class= in 0.12. Still pre-1.0 (Development Status: Pre-Alpha).
pip install trlVerified import paths — ran on the pinned version, not inferred.
SFT then DPO pipeline. Use SFTConfig/DPOConfig for all training args.
Replace tokenizer=tokenizer with processing_class=tokenizer in all trainer constructors.
Use SFTConfig(max_length=512, ...) and pass as args=SFTConfig(...) to SFTTrainer.
Pin exact TRL version in requirements. Read the GitHub releases page before upgrading: https://github.com/huggingface/trl/releases
With PEFT models, omit ref_model entirely. DPOTrainer handles reference behavior automatically via adapter disable/enable.
Wrap single reward function in a list: reward_funcs=[my_reward_fn].
For chat format datasets use a 'messages' column with OpenAI-style message dicts. For plain text use a 'text' column. Check dataset_text_field in SFTConfig if using a custom column name.
Ensure your Python environment (version and OS distribution) has readily available pre-built `torch` wheels. Consider using a Python version officially supported by PyTorch (e.g., Python 3.10, 3.11) on a widely supported base OS (e.g., Debian/Ubuntu). If using Alpine, you may need to build `torch` from source or switch to a glibc-based image.