natolambert/rlhf-book

Textbook on reinforcement learning from human feedback

What it solves

This project addresses the lack of canonical, open-source documentation for Reinforcement Learning from Human Feedback (RLHF) and post-training language model techniques. It provides a structured guide to bridge the gap between academic research and industry practices, such as model alignment and character training, which previously lacked transparent, accessible references.

How it works

The repository serves as a comprehensive educational hub containing a book manuscript, reference code implementations, and reusable diagrams. The book covers the fundamentals of post-training, while the code directory provides practical implementations for algorithms like PPO, DPO, rejection sampling, and reward modeling. Users can build the book locally into HTML or PDF formats or use the provided code to experiment with alignment techniques.

Who it’s for

This resource is designed for researchers, developers, and students interested in the mechanics of aligning language models. It is intended for those who want to move beyond high-level theory and understand the specific implementation details of preference learning and model training.

Highlights

  • Comprehensive reference implementations for key algorithms including PPO, REINFORCE, DPO, and reward model training.
  • Reusable diagram source files (LaTeX/TikZ) suitable for presentations and technical writing.
  • A transparent documentation of the author's AI-assisted writing and editing workflow.
  • Open-source educational materials including slide decks and course content.
  • A community-driven ecosystem supporting translations and ongoing contributions.

Related

  • Project
  • Project
  • Project
  • Project