AI Compass
Compass

RLHF and alignment

How a model learns what is wanted: preference data, reward models, DPO as a shortcut, and the limits of the method.

·2 min read·By Fachredaktion Technik
DETAIL
3 sections

The idea

After pre-training a model can continue text. After fine-tuning it can follow instructions. What is still missing is a sense of which of two possible answers is better.

For that, people are shown two answers and pick the better. From many such comparisons the model learns what is preferred.

The flow

  1. 01

    Generate answer pairs

    The model produces two or more answers to a request.

  2. 02

    Have them rated

    People pick the better one, following a written guideline.

  3. 03

    Learn the preference

    Either via a reward model or directly from the pairs.

  4. 04

    Adapt the model

    The preferred direction is reinforced without drifting too far from the base model.

The rating guideline

This is where the desired behaviour is actually specified, and it is often written casually.

  • Rank the criteria: correctness before completeness before form.
  • State explicitly how to handle uncertainty: is "I do not know" better than a guess?
  • Do not allow length as a quality signal, or the model learns verbosity.
  • Measure inter-rater agreement. Below 70 percent the guideline is too vague.

What measurably improves

PropertyEffect of alignment
Following instructionsclearly better
Keeping to a formatclearly better
Tone and politenessclearly better
Refusing impermissible requestsclearly better
Factual correctnesssmall, sometimes worse
Admitting ignoranceonly if explicitly rewarded

The reward model

Bradley-Terry model for preferences

P(y_w ≻ y_l | x) = σ( r_φ(x, y_w) − r_φ(x, y_l) ) L_RM = − log σ( r_φ(x, y_w) − r_φ(x, y_l) )

The probability that an answer is preferred follows from the difference of rewards.

r_φ
the reward model
y_w
the preferred answer
y_l
the rejected answer
σ
the logistic function

DPO

The decisive step is the observation that the optimal policy can be written in closed form through the reward model. Substituting that, the reward model drops out:

Direct preference optimisation

L_DPO = − log σ( β·log(π_θ(y_w|x)/π_ref(y_w|x)) − β·log(π_θ(y_l|x)/π_ref(y_l|x)) )

The probability of the preferred answer should rise against the base model and that of the rejected one fall.

π_θ
the policy being trained
π_ref
the base model, frozen
β
how strongly divergence is penalised, usually 0.1 to 0.5

The advantage is considerable: no separate reward model, no reinforcement-learning loop, no sampling during training. What remains is supervised training on pairs, with correspondingly stable optimisation.

Reward hacking, concretely

Observed shortcutCause in the rating
Answers keep getting longerLength correlated with approval
Excessive bullet listsStructure was read as quality
Agreeing with the asker's positionPoliteness was rewarded
Avoiding clear statementsErrors were punished harder than evasion
Formulaic openingsThey occurred often in preferred answers

All five have been documented in released models. They are not optimisation failures but correct optimisation of an imprecise specification.

For general-purpose models the AI Act requires, among other things, a description of the training and alignment procedures and an assessment of systemic risks. The rating guideline, the selection of raters and the measured agreement are therefore documentation artefacts, not merely internal working papers.

Related courses and sources

CourseFree1200 minEN

Hugging Face deep reinforcement learning course

Reward, policy and exploration in playable environments. Useful for understanding what actually happens when a language model is aligned.

For anyone wanting to understand what actually happens when a language model is aligned.

Hugging FaceGo to offer
PaperFreeEN

Training Language Models to Follow Instructions

How a text continuation engine becomes an assistant. The paper behind alignment from human feedback.

For anyone asking how a text continuation engine becomes an assistant.

Was this page helpful?
RLHF and alignment