DPO and Curious Agents

Direct Preference Optimization trains a language model straight from pairs of "this reply beats that one". It needs no reward model and no RL loop. Paprika points the same loss at whole game trajectories and lifts an 8B model's success rate by 47%.

Pick a loss, then press Train. Five replies to one prompt start at the reference model's odds. Watch where the preferences push them. Then we build, piece by piece, the closed-form policy, the DPO loss, its gradient and Paprika's curriculum.

You need a little Python and what a probability is. We build the rest from zero.

Session 6 of Georgia Tech CS 8803, LLM seminar. It rests on two papers: Rafailov, Sharma, Mitchell, Ermon, Manning and Finn, Direct Preference Optimization: Your Language Model is Secretly a Reward Model (NeurIPS 2023), and Tajwar, Jiang, Thankaraj, Rahman, Kolter, Schneider and Salakhutdinov, Training a Generally Curious Agent (2025). Every idea is re-taught here in our own words and devices.

Train on preferences only

1.0

Toy, run live: five made-up replies, a made-up hidden reward, and preferences drawn from it by the Bradley-Terry rule. The dashed outline is the closed-form target of Chapter 1. "No weight" drops DPO's per-pair weight, as the paper's Unlikelihood baseline does.

Chapter 0

Why RLHF Hurts

See which part of the standard alignment recipe is slow and unstable

A pretrained model can continue any text. Ask it a question and it may answer, or it may write the next forum post. Alignment teaches it which of the things it knows to say.

The standard recipe in 2022 is RLHF, reinforcement learning from human feedback. It has three phases, and each one trains a different model.

  1. Supervised fine-tuning (SFT). Train on good demonstrations. The result is πSFT.
  2. Reward modelling. People pick the better of two replies. A network rφ learns to score replies so that its scores explain the picks.
  3. RL fine-tuning. PPO pushes the policy toward high scores, on a leash to πSFT.

Phase 2 needs a model of one human choice. Call the hidden quality of a reply y to a prompt x its reward r(x, y). Call the two replies y1 and y2. The Bradley-Terry model gives the chance that a person prefers y1.

Say it aloud

p of y-one beats y-two given x equals sigma of: r of x, y-one, minus r of x, y-two.

p(y1 ≻ y2 | x)
p of y-one beats y-two given x the chance a person picks reply y1 for prompt x.
σ
sigma the logistic function, 1 / (1 + e−z). It turns any number into a chance between 0 and 1.
r(x, y1) − r(x, y2)
the reward gap how much better y1 is than y2. Nobody can see r; we only see the clicks.
In plain words

Take the reward gap between the two replies. Pass it through sigma. The result is the chance that the first reply wins.

With numbers

With made-up rewards 2.0 and 1.0: the gap is 1.0, and σ(1.0) = 1 / (1 + 0.368) = 0.731. A one-point gap wins 73% of comparisons, not all of them.

Phase 2 is an ordinary classification problem. Phase 3 is the trouble. Its objective averages over replies sampled from the policy, and drawing a token is not differentiable. So the field uses PPO (Proximal Policy Optimization), an RL method that estimates the gradient from samples.

Count the models in memory

Each box is a 7B model held on the GPU. The bar adds up weights and optimizer state. Switch to DPO and see which boxes go.

Illustrative sums, not from the papers: 2 bytes per weight in bf16, plus 8 bytes of Adam state per trained weight. Activations, fp32 master weights and the rollout cache are left out.

With these sums: one 7B model is 7 billion × 2 bytes = 14 GB. PPO holds four (policy, critic, reward model, reference), so 56 GB. Adam adds 7 billion × 8 bytes = 56 GB for each of the two trained models. The total is 168 GB. DPO holds two models and trains one: 28 + 56 = 84 GB.

Failure. The policy finds text that the reward model over-scores, such as padding every answer. The DPO paper names the risk "mode-collapse to single high-reward answers". Measure: the reward climbs while human win rate stalls. Fix: the KL leash of Chapter 1. PPO adds four more knobs to tune: clip ratio, GAE lambda, value-loss weight and KL target.

  1. The closed-form policy: the leashed objective has an exact answer. The hero's dashed outline.
  2. Killing the reward model: the intractable sum cancels, and a loss is left.
  3. The loss by hand: four log-probabilities to one number.
  4. Secretly a reward model: the gradient and its per-pair weight. The hero's two buttons.
  5. Results, honestly: what held up and what broke.
  6. Teaching curiosity: Paprika's ten games and its data.
  7. Multi-turn preferences: DPO over whole trajectories, plus RPO.
  8. The curriculum: UCB picks which games to sample.
  9. What Paprika bought: transfer, limits, and the tension with alignment.
  10. Field guide: numbers, code, links and the credit.
Why can phase 3 of RLHF not use plain gradient descent?

Chapter 1

The Closed-Form Policy

Solve the leashed reward problem exactly, with no search at all

Phase 3 asks: which policy earns the most reward while it stays near the reference? Name the parts. The policy π gives each reply y a probability π(y | x). The reference πref is the frozen SFT model. The KL divergence measures how far π has moved from πref; it is 0 only when they match. The knob β sets the price of each unit of distance.

Say it aloud

Maximize over pi: the average, over replies y drawn from pi, of r of x, y, minus beta times the KL divergence of pi from pi-ref.

maxπ
maximize over pi search over all policies for the best one.
Ey∼π
the average over y drawn from pi the reward we expect if we sample replies from π.
r(x, y)
r of x, y the reward of reply y to prompt x.
β
beta the price of distance. The DPO paper's default is 0.1.
DKL[π ‖ πref]
the KL divergence of pi from pi-ref the sum over y of π(y) log(π(y) / πref(y)), in nats.
In plain words

For a candidate policy, average the reward of its replies. Subtract beta times how far it moved from the reference. The best policy makes this largest.

With numbers

With made-up numbers: average reward 1.5, KL 0.4 nats. At β = 0.1 the score is 1.5 − 0.04 = 1.46. At β = 1 the same move scores 1.1, so a large β keeps π near home.

Appendix A.1 of the paper solves this exactly. Put the KL inside the average, flip the sign and divide by β. The bracket becomes the KL from π to one special distribution, plus a term with no π in it. A KL is smallest, 0, when the two sides match. So that distribution is the answer.

Say it aloud

pi-r of y given x equals pi-ref of y given x, times e to the r of x, y over beta, divided by Z of x.

πr(y|x)
pi-r of y given x the best leashed policy for reward r.
πref(y|x)
pi-ref of y given x the reference odds of reply y.
exp(r / β)
e to the r over beta a bonus that grows fast with reward. A small β makes it sharper.
Z(x)
Z of x the partition function: the sum over all y of πref(y|x) exp(r(x, y) / β). It makes the odds add to 1, and it depends on the prompt only.
In plain words

Start from the reference odds. Multiply each reply by e to its reward over beta. Divide by the total Z so that the odds add to 1.

With numbers

With made-up numbers: four replies at πref = 0.25, rewards 2.0, 1.0, 0.0 and −1.5, β = 1. The numerators are 1.847, 0.680, 0.250 and 0.056, so Z = 2.833. Then πr = 65.2%, 24.0%, 8.8% and 2.0%.

Turn the leash

Four replies with their rewards. Grey ticks are the reference odds. Drag β and watch the formula move the mass.

1.00

Toy rewards and a uniform reference. The formula above draws each bar.

Failure. Z sums over every possible reply, which is every token sequence. Measure: count the terms. A 50,000-token vocabulary and 100-token replies give 50,000100 of them. So nobody can compute πr directly. Fix: Chapter 2 makes Z cancel.

Why can you not compute the closed-form policy directly, even with a trained reward model?

Chapter 2

Killing the Reward Model

Turn the policy formula around so that the intractable sum cancels

Take the log of the Chapter 1 formula and solve it for the reward:

r(x, y) = β log( πr(y|x) / πref(y|x) ) + β log Z(x)

The reward that made a policy optimal is β times its log-ratio to the reference, plus a term that depends on the prompt alone. Bradley-Terry uses only the reward gap between two replies to one prompt. In that gap, β log Z(x) appears twice and subtracts to zero.

We do not know the optimal policy. So put the trainable policy πθ in its place and fit it to real pairs by maximum likelihood. Call the preferred reply yw (the winner) and the other yl (the loser). Negate the log-likelihood to get a loss.

Say it aloud

L-DPO equals minus the average over pairs in D of log sigma of: beta log of pi-theta of y-w over pi-ref of y-w, minus beta log of pi-theta of y-l over pi-ref of y-l.

LDPO
L-DPO the loss we minimize. 0.693 when πθ equals πref.
ED
the average over D over all (prompt, winner, loser) triples in the dataset D.
log σ
log sigma the log of the Bradley-Terry chance that the winner wins.
β
beta the same leash price as Chapter 1.
log πθ(yw)/πref(yw)
the winner's log-ratio how much the policy raised the winner over the reference, in logs.
log πθ(yl)/πref(yl)
the loser's log-ratio the same for the loser.
In plain words

For each pair, take the winner's log-ratio minus the loser's log-ratio, times beta. Pass it through log sigma and negate. Average over the pairs.

With numbers

With the made-up numbers of Chapter 3: the winner's log-ratio is +0.40 and the loser's is −0.80, with β = 0.1. Inside: 0.1 × 1.20 = 0.12. The loss is −log σ(0.12) = 0.635.

Every input comes from two forward passes: one through πθ, one through the frozen πref. The pairs exist before training starts, so the loop samples nothing.

Shift every reward

Three replies, small enough to sum Z by hand. Add the same c to every reward. Watch Z and the policy bars.

0.0

Toy: πref = 0.5, 0.3, 0.2; rewards 1, 0, −1; β = 1. The paper calls rewards that differ by a function of the prompt alone one equivalence class (Appendix A.5, Lemma 1).

With c = 3: Z goes from 1.733 to 34.80, a factor of e3 = 20.1. The policy stays 78.44%, 17.31% and 4.25%. Every term of Z picked up the same factor, so every ratio stays the same.

Failure. Your loss sits at 0.693 and never moves. Measure: every log-ratio is 0, so the policy and the reference are the same weights. Fix: freeze a separate copy as πref before training, and give the optimizer only πθ.

Why does Z(x) vanish from the DPO loss?

Chapter 3

The DPO Loss By Hand

Push four log-probabilities through the loss and check them against the paper's code

The prompt: "Write a function that reverses a string." The winner yw is one line, return s[::-1]. The loser yl is a correct 12-line loop. To score a reply, add the log-probability of each of its tokens. That gives one number per reply and per model.

QuantityMeaningValue
log πθ(yw|x)policy, winner−1.20
log πθ(yl|x)policy, loser−2.10
log πref(yw|x)reference, winner−1.60
log πref(yl|x)reference, loser−1.30
  1. Log-ratios. Winner: −1.20 − (−1.60) = +0.40. Loser: −2.10 − (−1.30) = −0.80.
  2. Implicit rewards, β = 0.1 (the paper's default): 0.040 and −0.080.
  3. Margin: 0.040 − (−0.080) = 0.120.
  4. Loss: σ(0.120) = 0.530, and −log 0.530 = 0.635.

Compare three states of the same pair. An untrained policy equals the reference, so the margin is 0 and the loss is ln 2 = 0.693, a coin flip. Our policy is a little better than a coin flip. A policy that ranks the pair the wrong way pays more.

Statelog πθ(yw), log πθ(yl)MarginLoss
Untrained−1.60, −1.3000.693
Mid-training−1.20, −2.100.1200.635
Later−0.85, −3.400.2850.561
Wrong way−3.00, −0.50−0.2200.809

Compute the loss live

The curve is −log σ(margin). The dot is this pair. Raise the policy's winner, or lower its loser, and watch the dot slide.

-1.20
-2.10
-1.60
-1.30
0.10

Made-up log-probabilities. The formula is the paper's Eq. 7.

Appendix B of the paper gives the loss in six lines of PyTorch. It groups the same four numbers differently: policy gap minus reference gap. (−1.20 + 2.10) − (−1.60 + 1.30) = 0.90 + 0.30 = 1.20, times β gives 0.120 again.

pythonimport torch.nn.functional as F

def dpo_loss(pi_logps, ref_logps, yw_idxs, yl_idxs, beta):   # the paper's Appendix B
    pi_yw_logps, pi_yl_logps = pi_logps[yw_idxs], pi_logps[yl_idxs]      # -1.20, -2.10
    ref_yw_logps, ref_yl_logps = ref_logps[yw_idxs], ref_logps[yl_idxs]  # -1.60, -1.30
    pi_logratios = pi_yw_logps - pi_yl_logps                            # 0.90
    ref_logratios = ref_yw_logps - ref_yl_logps                         # -0.30
    losses = -F.logsigmoid(beta * (pi_logratios - ref_logratios))       # 0.635 at beta 0.1
    rewards = beta * (pi_logps - ref_logps).detach()                # implicit rewards
    return losses, rewards

Failure. The loss is right but the model does not move. Measure: print the sequence log-probabilities; if they include the prompt tokens, the prompt dominates. Fix: sum log-probabilities over the reply tokens only.

The pair has margin 0.120 and loss 0.635, below 0.693. What does that tell you?

Chapter 4

Secretly a Reward Model

Read the gradient, and see why each pair gets its own weight

Give the quantity inside the loss a name. The implicit reward of a reply is r̂θ(x, y) = β log(πθ(y|x) / πref(y|x)). It is a full reward function: give it a prompt and a reply, and it returns a score. This is the paper's title. Differentiate the loss, using d/dz log σ(z) = σ(−z), and you get its gradient.

Say it aloud

The gradient of L-DPO equals minus beta times the average of: sigma of r-hat of y-l minus r-hat of y-w, times the gradient of log pi of y-w minus the gradient of log pi of y-l.

∇θLDPO
the gradient of L-DPO the direction in weight space that raises the loss fastest; training steps the other way.
σ(r̂l − r̂w)
sigma of r-hat-l minus r-hat-w the weight of this pair: near 1 if the policy ranks it backwards, near 0 if it is already learned.
∇θ log π(yw|x)
the gradient of log pi of y-w the direction that makes the winner more likely.
∇θ log π(yl|x)
the gradient of log pi of y-l the direction that makes the loser more likely, which DPO subtracts.
In plain words

Push the winner up and the loser down. Scale the push by how wrong the current implicit ranking is. A pair that is already learned gets almost no push.

With numbers

From Chapter 3, r̂w = 0.040 and r̂l = −0.080, so the weight is σ(−0.120) = 0.470. A pair at r̂w = 3 and r̂l = −3 gets σ(−6) = 0.0025, about 190 times less.

Read the weight of one pair

The teal curve is DPO's weight, σ(−margin). The blue line is the unweighted loss: every pair at full strength. Drag the margin.

0.12

The marks are this page's worked pairs: 0.120 (weight 0.470), 0.285 (0.429) and 6.0 (0.0025).

The paper tests the weight by removing it (Section 4, Appendix C.3). That is its Unlikelihood baseline: raise log π(yw), lower log π(yl), at the same strength for every pair. The hero's "No weight" button runs it.

Failure. The unweighted loss keeps pushing pairs that are already solved, and the policy collapses. Measure: sample at temperature 1. Appendix Table 3 shows Unlikelihood summaries that repeat the word "when" for whole lines. Fix: keep the weight; it fades each solved pair out.

pythondef implicit_reward(policy, ref, x, y, beta):     # two forward passes, one subtraction
    return beta * (policy.seq_logprob(x, y) - ref.seq_logprob(x, y))

def best_of_n(policy, ref, x, candidates, beta):    # rerank like a reward model
    return max(candidates, key=lambda y: implicit_reward(policy, ref, x, y, beta))

Section 5.2 also explains PPO's trouble. The term β log Z(x) returns there as a "soft value function". PPO must estimate it with a critic or a one-sample baseline, and the noise makes its gradient unstable. DPO never estimates it.

What does the factor σ(r̂l − r̂w) do in the DPO gradient?

Chapter 5

Results, Honestly

Check what the DPO paper measured, and where its own evidence shows cracks

The paper tests DPO on three tasks, with models up to 6B parameters. Each row names the setup and the result.

TaskSetupResult
SentimentIMDb prefixes, GPT-2 large, a sentiment classifier as the true reward, 22 runs"By far the most efficient frontier" of reward against KL. It beats PPO even when PPO sees the true reward (PPO-GT).
SummarizationReddit TL;DR, GPT-J, GPT-4 as judgeAbout 61% win rate against reference summaries at temperature 0. PPO: 57% at its best temperature, also 0.
DialogueAnthropic HH, Pythia-2.8BThe only efficient method that beats the preferred replies. It matches Best of 128 with one sample.
New inputsTL;DR policies on CNN/DailyMail news (Table 1)DPO 0.36 and 0.31, PPO 0.26 and 0.23, at temperatures 0 and 0.25.

DPO also holds its win rate as the sampling temperature rises; PPO falls toward the base GPT-J model. Every win rate above comes from a GPT-4 judge. Section 6.4 checks that judge against people.

Check the judge against people

The study compared each method's summaries with greedy PPO summaries. Pick a method and compare the two GPT-4 prompts with the human verdict.

The paper's Table 2 (TL;DR). "Simple" asks which summary covers the important information. "Concise" also asks which is more concise.

With the paper's numbers: for DPO, humans give 58%, the concise prompt 54% and the simple prompt 47%. The simple prompt is 11 points off; the concise prompt is 4 points off. The authors found that the simple prompt favours longer, more repetitive summaries, so they report the concise prompt.

Failure. DPO can be fluent and wrong. Appendix Table 9 shows a dialogue answer about how the United States entered World War II. It is detailed and confident, and it invents facts, so GPT-4 picks the human answer. Measure: check facts, not only preference. Fix: none inside the loss; DPO learns whatever the labels reward.

Two more limits come from the paper itself. The authors "did not meaningfully tune" β (0.1, or 0.5 for TL;DR). They also leave open generalization, reward over-optimization and scale beyond 6B.

In Table 9, why did GPT-4 prefer the human answer to DPO's longer one?

Chapter 6

Teaching Curiosity

Turn games into preference pairs that reward gathering information

Now the setting changes. An agent plays twenty questions: it asks, gets "yes" or "no", and must find the secret. It acts for many turns, and it never sees the hidden state. That kind of task is a POMDP (partially observable Markov decision process). To win, the agent must explore: ask a question because the answer is unknown.

Prior work found that LLMs explore poorly even on a multi-armed bandit: several slot machines with unknown payout. Training on trajectories from a known algorithm (UCB) helps on bandits. But most tasks have no such algorithm. Paprika instead trains on many different games and hopes the skill transfers.

Find the best arm in 20 pulls

Five arms with hidden payout rates. Each dot is one pull: green paid, grey did not. Pick a strategy and play a game. The bars show the success rate over 4,000 games.

Toy payout rates 0.60, 0.30, 0.45, 0.75, 0.50. Paprika's own bandit task also gives 20 pulls, then asks for the best arm; its numbers are in Chapter 9.

Paprika builds ten task groups (Table 1 of the paper). Some need world knowledge, so another LLM, GPT-4o-mini, plays the environment. Rule-based games use a program, which the authors found more reliable. A judge filters out "wins" that the environment reported wrongly.

Task groupTrain / test tasksMax turnsFeedback
Twenty questions1,499 / 36720LLM
Guess my city500 / 18520LLM
Wordle1,515 / 8006program
Cellular automata1,000 / 5006program
Customer service628 / 20020LLM
Murder mystery203 / 5020LLM
Mastermind1,000 / 50012program
Battleship1,000 / 20020program
Minesweeper1,000 / 20020program
Bandit best arm81 / 121program

To make data, Paprika samples nsample = 20 games per training task (100 for Mastermind). It uses Min-p sampling at temperature 1.5, which keeps only tokens close to the top token's probability. So games are diverse but still readable. The winner hw is the game that succeeds in the fewest turns. Paprika draws the loser hl at random from the worse games, to keep the data diverse.

With made-up scores for one task: 6 games fail, 9 win slowly, 5 win fast. hw is the fastest win. hl may be a failure or a slow win, with equal chance for each of the other 19.

Failure. The environment LLM says "Goal reached" when the guess was wrong. Measure: a separate judge call that knows the secret replies VALID or NOTVALID. Fix: drop the false wins, and drop games whose environment replies break the format after 5 attempts.

Why does Paprika not just fine-tune on trajectories from a known-good algorithm?

Chapter 7

Multi-Turn Preferences

Sum the implicit reward over the agent's own turns, and add a pull toward the winner

A game is a trajectory h: the environment speaks, the agent acts, again and again. Call the agent's action at turn t at, and everything before it, the history, h:t. Only the agent's tokens count. The environment's words are context, never a target.

Say it aloud

L-DPO equals minus the average of log sigma of: the sum over t of beta log pi-theta of a-t-w given h-to-t-w, over pi-ref of the same, minus the same sum for the loser.

LDPO
L-DPO the multi-turn loss, the paper's Eq. 2.
Σt
the sum over t add one term per agent turn. The two games may have different lengths.
log πθ(atw|h:tw)/πref(·)
the winner's log-ratio at turn t how much the policy raised the agent's action at in the winning game, given its history.
log πθ(atl|h:tl)/πref(·)
the loser's log-ratio at turn t the same for the losing game.
In plain words

Add the agent's log-ratios over every turn of the winning game. Do the same for the losing game. Subtract, times beta, and apply the usual log sigma loss.

With numbers

With made-up numbers: the winner's two turns have log-ratios +0.20 and +0.15, sum 0.35. The loser's three turns have −0.05, −0.20 and −0.40, sum −0.65. At β = 0.1 the margin is 0.100 and the loss is 0.644.

Paprika trains in two stages. First, SFT on the winning games alone: maximize the log-probability of the winner's action tokens, divided by their count. Then DPO on the pairs.

But DPO only watches the gap. It can widen the gap by lowering both replies, if the loser drops faster. Razin et al. call this unintentional unalignment. The fix is RPO, which adds the SFT loss back:

LRPO = LDPO + α · LSFT,   with α = 1.0

Catch the falling winner

Both outcomes start at log πref = −1.00 (dashed line). Switch the outcome and watch the DPO term, then raise α.

1.0

Made-up log-probabilities, β = 0.1. The SFT term here is −log πθ(yw) for one token. Paprika uses α = 1.0, following Pang et al.

Both outcomes have margin 0.120 and DPO loss 0.635. With α = 1, RPO gives 0.635 + 0.60 = 1.235 when the winner rises, and 0.635 + 1.30 = 1.935 when both fall. Only RPO prefers the healthy outcome.

The recipe (Section 4): 17,181 SFT games and 5,260 RPO pairs; learning rate 10−6 for SFT and 2 × 10−7 for RPO; batch 32; AdamW with cosine decay. πref is the initial model. The authors chose DPO because it lets data collection and training run on different machines. They expect online RL to do better.

Failure. The agent starts to copy the environment's feedback text. Measure: check the loss mask; environment tokens must have no log-ratio term. Fix: mask every environment token, as the paper does.

Why does Paprika add the SFT loss to the DPO loss?

Chapter 8

The Curriculum Showcase

Spend the sampling budget on the task groups that still teach something

In Paprika, "the major cost for training is actually data generation rather than model updates". A 20-turn game needs an agent call and an environment call per turn, so up to 40 calls. Twenty games make up to 800 calls for one pair (our estimate). A task the model always wins, or never wins, gives no useful pair.

So score each task by its spread of outcomes. Call a task τ, the average score of policy π on it Rπ(τ), and the variance of that score σ2π(τ).

Say it aloud

nu-pi of tau equals the square root of sigma-squared-pi of tau, divided by R-pi of tau.

νπ(τ)
nu-pi of tau the coefficient of variation: the task's learning potential.
√σ2π(τ)
the square root of sigma-squared the standard deviation of the score over sampled games.
Rπ(τ)
R-pi of tau the average score. Dividing by it puts games with different score scales on one footing.
In plain words

Play the task several times. Take the standard deviation of the scores and divide by their average.

With numbers

With made-up scores (11 for a win, 0 for a loss): always winning gives ν = 0. Winning half the time gives 5.5 / 5.5 = 1. Winning 1 game in 20 gives 2.40 / 0.55 = 4.36. Never winning makes R = 0, so ν has no value.

Measuring ν per task costs rollouts. So Paprika treats each task group as an arm of a bandit and picks groups with UCB (Upper Confidence Bound). Arm k has nk pulls so far, and its observed ν values add up to sk.

Say it aloud

theta-k equals s-k over n-k, plus the square root of two log of the sum over j of n-j, over n-k.

θk
theta-k the UCB score of group k. UCB samples the group with the highest score next.
sk / nk
s-k over n-k the average ν seen so far for group k.
√(2 log Σjnj / nk)
the exploration bonus large for a group pulled rarely; Σjnj is the total pulls over all groups.
In plain words

For each group, add its average ν to a bonus that shrinks as it gets pulled. Sample the group with the largest total. Update its s and n.

With numbers

With made-up numbers after 20 pulls: twenty questions has s = 3.2, n = 5, so θ = 0.640 + 1.095 = 1.735. Wordle has s = 0.9, n = 3, so θ = 0.300 + 1.413 = 1.713. Twenty questions is next. If it returns 0.50, it drops to 1.624 and Wordle (1.725) takes over.

Let UCB pick the groups

Six groups with hidden learning potential (grey ticks). Solid bar: average ν seen. Pale cap: the bonus. Pink: the group served next. Press Play.

3

Toy: we made up the hidden ν values and the noise. The formula is the paper's Algorithm 1.

The paper ran this on twenty questions, split by GPT-4o-mini into 477 easy, 726 medium and 296 hard training topics. Each of 3 rounds sampled 250 tasks. Against uniform sampling, the curriculum gained 1.4% in average success and 3.3% in pass@4. Pass@4 counts a task as solved if any of 4 tries succeeds: at 40% per try that is 1 − 0.64 = 87%.

Failure. UCB keeps picking a group that always fails. Measure: that group's pairs are empty. Fix: skip tasks with no win; ν has no value there. The paper also warns that the curriculum depends on good groupings.

Why divide the standard deviation by the mean, instead of using the variance alone?

Chapter 9

What Paprika Bought

Read the transfer results, their limits, and how they pull against alignment

Trained on about 22,500 trajectories from all ten groups, Paprika raises Llama-3.1-8B-Instruct's average success by 47% of its starting value. The sharper test is a game it never saw.

Read Paprika's numbers

Blue: Llama-3.1-8B-Instruct. Teal: after Paprika. Switch between the unseen bandit and the standard benchmarks.

The paper's Figure 3 (bandit, trained only on other groups) and Table 2 (benchmarks; MT-Bench is out of 10, the rest are percentages).

With the paper's numbers: on the bandit group, success rises from 42.25% to 62.25% with no bandit data. That is (62.25 − 42.25) / 42.25 = 47% more. In leave-one-out runs, Paprika improves 9 of the 10 groups it did not train on. Wordle shows no transfer.

The controls rule out simpler stories. Fine-tuning on 100,000 WildChat conversations hurts every group, so more multi-turn text is not the cause. RPO beats SFT alone on all 6 groups tested, so the losing games carry signal.

Failure. Transfer has a limit. On the standard bandit benchmark, scored by regret (the reward lost on every pull of a worse arm), Paprika helps only with few arms: "the gap vanishes when the number of arms grow". Measure: regret over 100 trials. Fix: the authors suggest online RL on the bandit tasks.

The papers pull in opposite directions. Alignment DPO narrows a model toward liked replies and keeps it near πref. Paprika needs diversity, and it gets it upstream, from sampling at temperature 1.5. The loss only keeps what worked. So Paprika "would perform worse in the absence of a good base model": it can only amplify moves the base model sometimes makes.

What does the bandit result (42.25% to 62.25%) show that the 10-group average does not?

Chapter 10

Field Guide

Keep the terms, the numbers, the code and the open questions in one place

DPO turns the leashed reward problem into a classification loss on the policy, because the intractable sum cancels in a reward gap. Paprika feeds the same loss whole game trajectories, chosen by a bandit, and gets an agent that explores better on games it never saw.

TermMeaningNumber to remember
Bradley-Terrychance of a pick from the reward gapgap 1.0 gives 0.731
βprice of distance from πref0.1 default; 0.5 for TL;DR
Closed formπref · exp(r/β) / Z65.2%, 24.0%, 8.8%, 2.0%
DPO loss−log σ(β × log-ratio gap)0.693 untrained; 0.635 at margin 0.12
Pair weightσ(r̂l − r̂w)0.470 at margin 0.12; 0.0025 at 6
TL;DR win rateGPT-4 judge vs referencesDPO 61%, PPO 57%
RPODPO + α × SFTα = 1.0
Paprika datafiltered self-play games17,181 SFT + 5,260 pairs
Coefficient of variationspread of scores / meanhalf wins: 1.0
Transferunseen bandit group42.25% to 62.25%

Checklist

  1. Freeze a copy of the SFT model as πref before the first step.
  2. Sum log-probabilities over reply tokens only; in multi-turn data, over agent tokens only.
  3. Check that the loss starts at 0.693.
  4. Track log πθ(yw) on its own. If it falls, add the SFT term (RPO).
  5. Audit your judge for length bias before you trust a win rate.
  6. Sample from tasks with spread in their outcomes; skip tasks never won.
pythonimport math
import torch.nn.functional as F

def rpo_loss(pw, pl, rw, rl, n_tok_w, beta=0.1, alpha=1.0):
    # pw, pl: policy log-probs summed over AGENT tokens of winner / loser, shape (B,)
    # rw, rl: the same from the frozen reference
    dpo = -F.logsigmoid(beta * ((pw - rw) - (pl - rl)))
    sft = -pw / n_tok_w                                   # per-token NLL of the winner
    return (dpo + alpha * sft).mean()

def ucb_pick(s, n):                                        # s, n: lists, one per task group
    N = sum(n)
    return max(range(len(s)), key=lambda k: s[k] / n[k] + (2 * math.log(N) / n[k]) ** .5)
DPO for alignmentDPO for curiosity (Paprika)
What yw isthe reply a person preferredthe game won in the fewest turns
Who labelsa humana task score, checked by a judge
Where diversity comes fromthe KL leash, as a guardMin-p sampling at temperature 1.5
Known failurefluent but wrong; judge length biasno gain with many arms; needs a good base model

What the authors leave open

The DPO authors ask how DPO generalizes out of distribution, whether its late dip in dialogue is reward over-optimization, and how it scales past 6B. The Paprika authors expect online RL to beat offline DPO, and want models that generate their own tasks.

Keep going

Credit: Session 6 of Georgia Tech CS 8803, LLM seminar. Papers: Direct Preference Optimization (Rafailov et al., NeurIPS 2023, arXiv 2305.18290) and Training a Generally Curious Agent (Tajwar et al., arXiv 2502.17543). The toy replies, bandits and all made-up numbers are ours.

The takeaway. The DPO loss has no opinion about what "good" means. Human picks make it an aligner; self-played games make it an explorer. The data decides.

Teach it back: open Present or Teach and explain why Z cancels and what the pair weight does. Then go back to the five replies and predict where DPO lands before you press Train.

CS 8803 LLM Seminar, Session 06: DPO and Curious Agents
DPO paper · Paprika paper · Back to Gleams