RL library to fine-tune language models to human preferences
Top 20.0% on sourcepulse
RL4LMs is a modular Python library designed for fine-tuning large language models (LLMs) to align with human preferences using reinforcement learning. It provides customizable building blocks for various NLP tasks, enabling researchers and practitioners to optimize LLMs with arbitrary reward functions and datasets.
How It Works
The library implements on-policy RL algorithms (PPO, A2C, TRPO, NLPO) and actor-critic policies for both causal and sequence-to-sequence LLMs. It integrates a wide array of NLP metrics (lexical, semantic, task-specific) that can serve as reward functions. The framework uses a gym-style text generation environment, enhanced with stable-baselines3
's SubProcVecEnv
for parallel rollouts, and supports adaptive KL divergence control to maintain model stability.
Quick Start & Requirements
pip install -e .
after git clone https://github.com/allenai/RL4LMs.git
python scripts/training/train_text_generation.py --config_path scripts/training/task_configs/summarization/t5_ppo.yml
Highlighted Details
Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The library is primarily focused on on-policy algorithms and may require significant configuration for custom RL setups. Some metric computations might depend on external libraries like coreNLP.
1 year ago
1 week