Lensa ML
Lensa ML

RLHF

Step 1 of 6

The Alignment Problem

Why raw language models need alignment

Temperature1
TOKEN PROBABILITY DISTRIBUTIONThe35%cat19%sat13%on12%the8%mat5%is4%a4%Generated: the on the cat the The
Temperature
1.00
Top Prob
34.6%
Entropy
2.63 bits

Moderate temperature: the model samples fairly well, but there's no guarantee the output is helpful, honest, or harmless. We need alignment.

Step 1 of 6: The Alignment Problem

Why raw language models need alignment

Temperature1
TOKEN PROBABILITY DISTRIBUTIONThe35%cat19%sat13%on12%the8%mat5%is4%a4%Generated: the on the cat the The
Temperature
1.00
Top Prob
34.6%
Entropy
2.63 bits

Moderate temperature: the model samples fairly well, but there's no guarantee the output is helpful, honest, or harmless. We need alignment.

Step 2 of 6: Collecting Human Preferences

Building a dataset of ranked outputs

Comparisons4
HUMAN PREFERENCE PAIRSAConcise and accurate answerBRambling off-topic answerAVerbose but correct replyBClear helpful explanationAShort but misleading textBCorrect but rude responseAHelpful step-by-step guideBIncomplete vague response
Pairs
4
Dataset Size
8 responses
Human Hours
2.0 est.

Moderate dataset: enough pairs to capture basic human preferences. Quality and diversity of annotators matter as much as quantity.

Step 3 of 6: Training a Reward Model

Learning to score outputs like humans

Train Step0
REWARD SCORESHelpful, accurate answer0.07Polite but wrong reply0.32Rude but correct text0.20Harmful misleading output0.12Clear step-by-step guide0.28ACCURACY1.00.5
Step
0
Accuracy
50.0%
Best Score
0.32

Early training: the reward model assigns near-random scores. It hasn't learned to distinguish good outputs from bad ones yet.

Step 4 of 6: PPO Optimization

Updating the policy with reward signal

KL weight \u03B20.50
BASE (blue) vs POLICY (purple) DISTRIBUTIONT0T1T2T3T4T5T6T7BasePolicy (PPO)
KL Weight
0.50
KL Div
0.308
Reward
0.708
Objective
0.554

Moderate β: a good balance. The policy improves on reward while staying close to the base model, avoiding degenerate behavior.

Step 5 of 6: KL Divergence Constraint

Keeping the model close to its base

KL Budget1
BASE MODEL vs ALIGNED MODELABCDEFBaseAligned
KL Budget
1.0
KL Divergence
0.137
Within Budget
Yes

Moderate KL budget: enough room for meaningful alignment while keeping the model's core capabilities intact. This is the typical operating range.

Step 6 of 6: DPO Alternative

Direct preference optimization without a reward model

DPO \u03B20.10
PPO vs DPO PIPELINEPPO (3 models)SFT ModelReward ModelPPO PolicyDPO (1 model)Direct OptimizationPREFERENCE MARGINS (chosen - rejected)Helpful answervs Harmful output0.600.90Clear explanationvs Confusing reply1.201.50Honest responsevs Deceptive text0.100.40ReferenceDPO Policy
DPO \u03B2
0.10
Avg Margin
0.93
Impl. Reward
0.093

Low β: DPO aggressively follows preferences, deviating far from the reference model. Simpler than PPO but same reward hacking risks.