SuperAPI AI Directory

rlhf-book

"Reinforcement Learning from Human Feedback" is a textbook about reinforcement learning from human feedback (RLHF) that also broadly introduces post-training language models. The project was created by Nathan Lambert and is open source, offering online reading, purchase of the print book (Manning or Amazon), and a Discord community. The repository contains not only the book source files, but also reference implementations of RLHF algorithms and diagram source files for learners and researchers to use. The content covers instruction fine-tuning, policy gradient methods, reward model training, direct alignment methods, rejection sampling, on-policy distillation, and more. The book chapters use the CC-BY-NC-SA-4.0 license, while the rest, including code, uses the MIT license. The community also maintains an unofficial Simplified Chinese translation.

Open website

About this tool

"Reinforcement Learning from Human Feedback" is a textbook by Nathan Lambert about reinforcement learning from human feedback (RLHF), and also serves as a broad introductory guide to post-training language models. The project is open source on GitHub and offers online reading, purchase of the print book (Manning or Amazon), and Discord community discussion.

Purpose

The book aims to open-source the knowledge the author accumulated in frontier work on open models, covering everything from established methods such as rejection sampling to industrial practices such as character training that lack publicly available research. It provides a systematic starting point for people who want to learn RLHF and post-training language models, and includes code implementations and diagram resources.

Main Capabilities

The repository contains the following:

  • Code directory (code/): reference implementations of RLHF algorithms, including instruction fine-tuning (SFT of a base model using chat templates), policy gradient methods (PPO, REINFORCE, GRPO, RLOO, etc.), reward model training (preference RM, ORM, PRM), direct alignment methods (DPO and variants), rejection sampling (best-of-N), and on-policy distillation (SDPO). For specific settings and usage, see code/README.md.
  • Book source files (book/): for build instructions, see book/README.md.
  • Diagrams directory (diagrams/): source files for the book's diagrams, which can be used for presentations, blog posts, or learning materials.

How to Use

Readers can read the online version, purchase the print book, and join the Discord community. For the code, refer to code/README.md for installation and usage. The book can be built locally; see book/README.md for the build steps. Diagrams can be generated with the corresponding tools.

Applicable Scenarios

Suitable for machine learning researchers, engineers, students, and anyone interested in RLHF and post-training language models. It can be used for self-study, teaching reference, research citation, and as a source of material for presentations and blog posts.

Limitations

The book chapters use the CC-BY-NC-SA-4.0 license, while the rest, including code, diagrams, and scripts, uses the MIT license. Note that some images in book/images/ are unauthorized photos or screenshots. The community translation is an independent project, unrelated to the official printed edition, and must comply with the same license and provide attribution. The project does not accept merging translations into this repository,Translations should remain in their respective repositories. New content should first be written by humans and can then be edited with AI; content that is clearly AI-written is very likely not to be accepted in a PR.

Basis for Classification

This project is an open-source textbook and accompanying code, mainly used for learning RLHF and post-training language models, so it is classified under the "AI Learning Websites" category.