trl  by huggingface

Library for transformer RL

created 5 years ago
14,823 stars

Top 3.4% on sourcepulse

GitHubView on GitHub
Project Summary

TRL (Transformer Reinforcement Learning) is a Python library for post-training foundation models using advanced techniques like Supervised Fine-Tuning (SFT), Proximal Policy Optimization (PPO), and Direct Preference Optimization (DPO). It targets researchers and engineers working with large language models, offering efficient scaling and integration with the Hugging Face ecosystem.

How It Works

TRL provides specialized trainer classes (SFTTrainer, GRPOTrainer, DPOTrainer, RewardTrainer) that wrap 🤗 Transformers' Trainer. This design allows seamless integration with distributed training (DDP, DeepSpeed ZeRO, FSDP) and efficient fine-tuning of large models on modest hardware via 🤗 PEFT (LoRA/QLoRA) and Unsloth optimized kernels.

Quick Start & Requirements

  • Install: pip install trl
  • Prerequisites: Python, 🤗 Transformers, Datasets. GPU recommended for practical use.
  • Docs: https://huggingface.co/docs/trl/index
  • CLI: trl sft --model_name_or_path ... or trl dpo --model_name_or_path ...

Highlighted Details

  • Supports SFT, PPO, GRPO, DPO, and Reward modeling.
  • Integrates with 🤗 PEFT for parameter-efficient fine-tuning.
  • Leverages 🤗 Accelerate for distributed training.
  • Includes Unsloth integration for accelerated training.

Maintenance & Community

  • Developed by Hugging Face.
  • Active development and community support.

Licensing & Compatibility

  • License: Apache-2.0.
  • Compatibility: Permissive license allows commercial use and integration with closed-source projects.

Limitations & Caveats

The library focuses on transformer-based models and requires familiarity with the Hugging Face ecosystem for advanced customization.

Health Check
Last commit

22 hours ago

Responsiveness

1 day

Pull Requests (30d)
121
Issues (30d)
63
Star History
1,375 stars in the last 90 days

Explore Similar Projects

Starred by Jeremy Howard Jeremy Howard(Cofounder of fast.ai) and Stas Bekman Stas Bekman(Author of Machine Learning Engineering Open Book; Research Engineer at Snowflake).

SwissArmyTransformer by THUDM

0.3%
1k
Transformer library for flexible model development
created 3 years ago
updated 7 months ago
Starred by Nat Friedman Nat Friedman(Former CEO of GitHub), Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), and
9 more.

trlx by CarperAI

0.1%
5k
Distributed RLHF for LLMs
created 2 years ago
updated 1 year ago
Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Eugene Yan Eugene Yan(AI Scientist at AWS), and
10 more.

accelerate by huggingface

0.2%
9k
PyTorch training helper for distributed execution
created 4 years ago
updated 2 days ago
Feedback? Help us improve.