Skip to content
AI & Machine Learning Rich #rlhf#dpo#alignment

RLHF / RLAIF Pipeline

SFT -> reward model -> PPO/DPO. Three stages that align an LLM to preferences.

A free, animated rlhf / rlaif pipeline you can read here or embed on any website, from Scrollchart.

RLHF / RLAIF Pipeline

RLHF / RLAIF PipelineThree-stage alignment: SFT → reward model → PPO, with DPO shortcut skipping explicit RMStage 1: SFTsupervised fine-tuneStage 2: RMreward modelStage 3: RL (PPO)policy optimisationKL pen.vs SFT refdemonstrations(human or AI)cross-entropy losspairwise prefs(y_w > y_l)Bradley-Terry losspolicy generatesRM scores outputr - beta * KLDPO shortcutSFT → policy directly from prefs (no explicit RM)Reward hacking risk:Policy exploits RM scoring blind spots. KL penalty (beta = 0.01 to 0.1) anchors policy near SFT to limit distributional drift.RLAIF variant: Constitutional AI replaces human pref labels with AI critique labels (Anthropic, 2022).PPO training dynamics0k20k40k60k80kPPO steps0.000.250.500.751.00KL peakKL div. from SFTreward scoreInstructGPT (2022): 1.3B PPO model preferred 4:1 over 175B SFT baseline by human raters

Stage 1: supervised fine-tuning on demonstrations. Stage 2: pairwise preferences train a reward model. Stage 3: PPO maximizes RM score with KL penalty to SFT model. DPO shortcut shown skipping the explicit RM. Reward hacking failure mode annotated.

Good for

  • LLM alignment explainers for AI safety and ML engineering audiences
  • Fine-tuning guides comparing PPO vs DPO vs Constitutional AI approaches
  • AI curriculum covering RLHF as the bridge between pretraining and instruction following

Source & accuracy

This rlhf / rlaif pipeline is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

Three stages from pretraining to human-aligned LLM

RLHF (Reinforcement Learning from Human Feedback) is a three-step process. Stage 1, SFT (Supervised Fine-Tuning), takes a pretrained LLM and fine-tunes it on high-quality examples (e.g., 'good' responses to prompts), teaching it the baseline style and format. Stage 2, Reward Model, trains a separate model to score responses on a human-preference scale. Stage 3, PPO or DPO, uses the reward model to guide policy optimization, rewarding responses humans prefer and punishing those they don't.

This pipeline is necessary because human preferences are diverse and hard to capture in a loss function. Pretraining optimizes for prediction accuracy (next token); RLHF optimizes for usefulness and safety according to human judgment.

The reward model as a proxy for human judgment

The reward model is trained on pairwise human comparisons: given two responses, humans rank them. The model learns to output high scores for preferred responses. This avoids expensive per-response annotation (which would require a score for every possible output), scaling to millions of training examples.

Quality of the reward model directly impacts the final LLM: a weak reward model with human-annotation noise can train a jailbroken or unaligned policy.

PPO and DPO tradeoffs

PPO (Proximal Policy Optimization) is the original algorithm but is sample-inefficient and complex to tune. DPO (Direct Preference Optimization) avoids training a separate reward model entirely, learning directly from preference pairs. DPO is simpler and faster but assumes preference pairs are stationary (humans don't change their minds).

Embed this diagram

Add this animated rlhf / rlaif pipeline to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated rlhf / rlaif pipeline for any website.
Who uses it
AI/ML blogs.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="rlhf-pipeline" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "RLHF / RLAIF Pipeline" for my website?
Scrollchart provides "RLHF / RLAIF Pipeline" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a rlhf / rlaif pipeline in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.