TextRL  by voidful

RLHF for text generation models (GPT, BLOOM, T5)

created 4 years ago
562 stars

Top 58.1% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

This library implements Reinforcement Learning from Human Feedback (RLHF) for text generation models available on Hugging Face Transformers. It allows users to fine-tune models like GPT-2, FLAN-T5, and BLOOM using RL techniques, enabling improved control and quality in generated text. The target audience includes researchers and developers looking to enhance text generation capabilities beyond standard supervised fine-tuning.

How It Works

TextRL integrates Hugging Face Transformers, PFRL, and OpenAI GYM to facilitate RL fine-tuning. It frames text generation as a sequential decision-making problem, where the model learns a policy to generate text token by token. A custom reward function, defined by the user, guides the learning process, allowing for tailored optimization based on specific criteria like sentiment, coherence, or adherence to a style.

Quick Start & Requirements

  • Install via pip: pip install pfrl@git+https://github.com/voidful/pfrl.git and pip install textrl.
  • Requires Python and PyTorch.
  • GPU acceleration is highly recommended for training and inference.
  • Official examples and Colab notebooks are available for various models.

Highlighted Details

  • Supports a wide range of Hugging Face Transformer models, including BLOOM (up to 176B via Petals).
  • Allows for customizable reward functions to guide generation quality.
  • Provides implementations for PPO and other RL algorithms via PFRL.
  • Includes examples for controllable generation, such as influencing sentiment or style.

Maintenance & Community

The repository is maintained by voidful. Links to Colab examples are provided for quick experimentation.

Licensing & Compatibility

The library appears to be under a permissive license, but specific details are not explicitly stated in the README. Compatibility with commercial use depends on the licenses of the underlying Hugging Face models and PFRL.

Limitations & Caveats

The README mentions strong recommendations for contributing to public swarms (like Petals) for larger models, indicating potential resource constraints or distributed computing requirements for very large models. The effectiveness of RLHF heavily relies on the design of the reward function, which can be complex to implement correctly.

Health Check
Last commit

1 year ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
5 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Shawn Wang Shawn Wang(Editor of Latent Space), and
2 more.

self-rewarding-lm-pytorch by lucidrains

0%
1k
Training framework for self-rewarding language models
created 1 year ago
updated 1 year ago
Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Omar Sanseviero Omar Sanseviero(DevRel at Google DeepMind), and
1 more.

RL4LMs by allenai

0.0%
2k
RL library to fine-tune language models to human preferences
created 3 years ago
updated 1 year ago
Feedback? Help us improve.