Search

Search papers and lessons

RLAIF vs. RLHF: Scaling Reinforcement Learning from AI Feedback

Harrison Lee, Samrat Phatale, Hassan Mansoor et al. · 2023

Lee and colleagues show that preference labels written by a large off-the-shelf language model can train a policy about as well as human labels, and that the labeler need not be larger than the policy.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Neural network basics
  • Linear algebra
  • Reinforcement learning
  • ReadReady to readNot yet

TL;DR

Training a language model with reinforcement learning from human feedback needs many human preference labels, and those are slow and expensive to collect. Lee and colleagues replace the human labeler with an off-the-shelf large language model that is asked which of two responses is better. Across summarisation and dialogue tasks, the policy trained on these AI labels is preferred by human raters about as often as the policy trained on human labels. A further variant skips the reward model and uses the labeler's score directly as the reward.

Builds on: Reinforcement Learning from Human Feedback (RLHF), Reward Model, LLM-as-a-Judge, Chain-of-Thought Prompting · Leads to: Direct Preference Optimization, Constitutional AI: Harmlessness from AI Feedback

Why it mattered

The paper turned a question that was open in 2023 into a measured answer: an LLM can stand in for human preference labels without losing much quality on these tasks. Later work on learning directly from preference pairs, such as Direct Preference Optimization, and the wider practice of using a strong model to grade or rank outputs, rest on the same kind of preference data. The paper also made the cost argument concrete: its authors estimate that LLM labeling is more than ten times cheaper than human annotation.

It also brought two ideas into the mainstream. First, the labeler can be a model of the same size or even the policy itself, which opened the door to self-improvement loops. Second, the reward model is not always needed: the d-RLAIF variant queries the labeler during reinforcement learning, which avoids the problem of a reward model going stale as the policy changes.

The problem

The pipeline of Reinforcement Learning from Human Feedback (RLHF) has three stages: fine-tune a model on demonstrations, collect human preferences between pairs of responses, and then train a Reward Model on those preferences and optimise the policy against it. The second stage is the bottleneck. Preference labels are costly, take time, and differ between annotators.

Earlier work by Bai and colleagues had introduced the idea of RLAIF, where part of the preference data came from AI feedback. That work did not compare AI and human feedback head to head, so it left open whether AI labels could replace human ones. This paper asks that question directly on three tasks: summarisation (Reddit posts with summaries), helpful dialogue, and harmless dialogue.

Two further questions follow. Does the labeler have to be bigger than the policy? And is the reward model a necessary middleman? The paper tests both.

How it works

The method runs in this order. Here is one tiny case traced through all of it.

  1. Start with a pair of responses. Take one input, such as a short Reddit post, and two candidate summaries A and B from the policy.
  2. Ask the labeler for a preference. Build a prompt with a preamble, optional examples, the input, the two responses, and an ending such as "Preferred Response=". Read the log-probabilities of the tokens "1" and "2" (a log-probability is the log of the chance the model gives a token, so a higher number means more likely) and apply a softmax over them. A softmax turns two numbers into two probabilities that add to 1. This gives a soft label, not a yes or no.
  3. Remove position bias. Run the prompt a second time with the order reversed, then average the two results. Suppose the first run gives A probability 0.75 and B probability 0.25, and the reversed run gives B 0.55 and A 0.45. The averaged label is A 0.60 and B 0.40.
  4. Optionally, ask for reasoning first. Ask the labeler to explain its judgement, then append the explanation to the prompt and read the preference as before. The paper finds this consistently improves the labeler's agreement with human labels.
  5. Train a reward model on the soft labels. The reward model gives a score to each response. A softmax over the two scores is compared to the soft label with cross-entropy, so the model learns to match the labeler's confidence, not just its choice.
  6. Run reinforcement learning. The policy generates responses, the reward model scores them, and the policy is updated. The paper uses a REINFORCE-style method with a baseline rather than proximal policy optimisation, because it is simpler and works well here.
  7. Evaluate with people. Human raters rank responses from different policies, and the win rate is the share of comparisons one policy wins.

Direct RLAIF, the variant the paper calls d-RLAIF, changes steps 5 and 6. The labeler is asked to rate a single response on a scale of 1 to 10. The probability of each score token is read, a weighted average is taken, and that number is rescaled to the range from -1 to 1 and used as the reward. There is no reward model to train, and the reward always comes from the current labeler.

flowchart LR
  A[Prompt with two responses] --> B[Labeler reads log-probabilities for 1 and 2]
  B --> C[Swap order and average]
  C --> D[Soft preference labels]
  D --> E[Train reward model]
  E --> F[RL updates the policy]
  F --> A

The math

Let the labeler produce log-probabilities ℓ1\ell_1 and ℓ2\ell_2 for the tokens "1" and "2". The soft preference is the softmax:

P1AI=eℓ1eℓ1+eℓ2,P2AI=1−P1AI.P^{\mathrm{AI}}_1 = \frac{e^{\ell_1}}{e^{\ell_1} + e^{\ell_2}}, \qquad P^{\mathrm{AI}}_2 = 1 - P^{\mathrm{AI}}_1.

Step 3 in symbols: removing position bias

Write PfwdP^{\mathrm{fwd}} for the preference from the original order and PrevP^{\mathrm{rev}} for the preference from the reversed order, mapped back to the original candidates. The final label is

PAAI=12(PAfwd+PArev).P^{\mathrm{AI}}_{A} = \tfrac{1}{2}\left(P^{\mathrm{fwd}}_{A} + P^{\mathrm{rev}}_{A}\right).

In the worked case above, 12(0.75+0.45)=0.60\tfrac{1}{2}(0.75 + 0.45) = 0.60.

Step 5 in symbols: the reward model loss

Let rAr_A and rBr_B be the reward model's scores for the two responses. The model's preference is σA=erA/(erA+erB)\sigma_A = e^{r_A} / (e^{r_A} + e^{r_B}). Training minimises the cross-entropy against the soft label PAAIP^{\mathrm{AI}}_A:

LRM=−[PAAIlog⁡σA+(1−PAAI)log⁡(1−σA)].\mathcal{L}_{\mathrm{RM}} = -\left[ P^{\mathrm{AI}}_A \log \sigma_A + (1 - P^{\mathrm{AI}}_A) \log (1 - \sigma_A) \right].

This is the standard pairwise objective, with the hard label replaced by a probability. When the labeler is unsure, the reward model is pushed toward a small score gap instead of a large one.

Steps 5 and 6 in symbols: the d-RLAIF score

The labeler's score is the expectation over the ten rating tokens. If P(i∣y,x)P(i \mid y, x) is the normalised probability of rating ii for response yy to input xx,

s(y∣x)=∑i=110i P(i∣y,x),s(y \mid x) = \sum_{i=1}^{10} i \, P(i \mid y, x),

and this value is rescaled to [−1,1][-1, 1] before it is used as the reward, using any linear map that sends 1 to −1-1 and 10 to 11, for example (s−5.5)/4.5(s - 5.5)/4.5. The weighted average keeps information that a single chosen rating would throw away: a response rated 8 with probability 0.5 and 9 with probability 0.5 has a score of 8.5, which is not the same as a response rated 8 with certainty, which scores 8.

Checking the labeler: alignment accuracy

Before a labeler is trusted, its labels are compared with human labels. The paper measures how often the AI label agrees with the human label. With DD examples, soft AI probabilities PAI∈RD×2P^{\mathrm{AI}} \in \mathbb{R}^{D \times 2}, and hi∈{1,2}h_i \in \{1, 2\} the index of the response the human preferred for example ii,

zacc=1D∑i=1D1[arg⁡max⁡jPi,jAI=hi].z_{\mathrm{acc}} = \frac{1}{D} \sum_{i=1}^{D} \mathbb{1}\left[ \arg\max_j P^{\mathrm{AI}}_{i,j} = h_i \right].

Here 1[⋅]\mathbb{1}[\cdot] is 1 when the condition inside holds and 0 otherwise, so zaccz_{\mathrm{acc}} is the fraction of examples where the labeler's more likely choice matches the human's. The score ignores how confident the labeler was, so it is a coarse measure.

Results

Summarisation and helpful dialogue. Human raters preferred RLAIF over the supervised baseline 71% of the time for summarisation and 63% for helpful dialogue. RLHF scored 73% and 64% on the same comparisons. The differences between RLAIF and RLHF against the baseline are not statistically significant. Head to head, RLAIF and RLHF are equally preferred: neither win rate differs significantly from 50% on either task.

Harmless dialogue. Here raters judged each response as harmless or harmful. RLAIF reached a harmless rate of 88%, against 76% for RLHF and 64% for the supervised baseline. This gap is statistically significant, the one place where AI feedback clearly beat human feedback in the paper.

Self-improvement. When the labeler is PaLM 2 XS, the same size as the policy, RLAIF still beats the baseline with a 68% win rate on summarisation, against 71% for the larger labeler. On helpful dialogue, the d-RLAIF policy and its labeler are the same checkpoint and reach a 66% win rate over the baseline. The paper calls this strict self-improvement.

d-RLAIF. On summarisation, d-RLAIF reaches a 74% win rate over the baseline, above the same-size RLAIF policy at 68%. The paper reports that d-RLAIF's win rate is significantly higher than the 68% of same-size RLAIF. The authors attribute this to querying the labeler directly and to avoiding a stale reward model.

Labeler quality. The best summarisation prompt, a detailed preamble with chain-of-thought, reached 78.0% agreement with human labels. Chain-of-thought consistently helped, while detailed preambles and few-shot examples had mixed effects across tasks. The authors note that an earlier estimate put agreement between human annotators on the OpenAI preference dataset at 73 to 77%, so 78% looks reasonable in absolute terms. Larger labelers agree more: 78.0% for PaLM 2 L and 62.7% for PaLM 2 XS, with PaLM 2 S in between.

Limits. The win rate differences are small and some are not significant, so the claim is parity, not superiority. The labeler is a single model family, PaLM 2, and the tasks are three. The paper also reports that combining human and AI labels did not beat human labels alone, though it does not rule out better combinations. In a small study of 70 summaries, RLHF sometimes hallucinated facts that RLAIF did not, while RLAIF summaries contained run-on sentences. The difference in overall quality ratings was not significant. Length bias is a concern, since both RL policies write longer responses; the authors check that their advantage survives a length-controlled analysis.

Reading guide

Read the paper in this order and use the lessons listed for each part.

Check yourself

QuestionRecall: what does the labeler output in RLAIF, and why is it a soft label rather than a single choice?Show answer

The labeler gives log-probabilities for the tokens "1" and "2", which are turned into probabilities with a softmax. The result is a distribution over the two responses, such as 0.6 and 0.4. A soft label keeps the labeler's uncertainty, and the reward model is trained against it with cross-entropy, so it learns to match the confidence as well as the choice.

QuestionComputation: the labeler gives probability 0.8 to response A in the original order, and 0.3 to response A in the reversed order. What is the averaged preference for A?Show answer

Average the two inferences: (0.8 + 0.3) / 2 = 0.55. The averaged preference for A is 0.55, and for B it is 0.45. The reversed run favoured B, which is the position effect the reversal is meant to cancel, so the average lands close to even.

QuestionWhy: the paper finds that a same-size labeler still improves the policy, but it also finds that a larger labeler agrees more with humans. Why are both findings compatible with the claim that RLAIF is useful?Show answer

RLAIF does not require the labeler to be better than humans. It needs the labeler to be good enough that its preference signal points in a useful direction. A same-size labeler is noisier, which lowers agreement, but the policy can still improve because the signal is correlated with human judgement. A larger labeler gives a cleaner signal. In canonical RLAIF it runs once per pair, before RL, so its cost is paid up front and not repeated during training.

QuestionApplied: a team wants to train a customer-support assistant without paying for many human preference labels. They can use d-RLAIF or canonical RLAIF. Which would you suggest, and what would you monitor?Show answer

Canonical RLAIF trains a reward model on AI labels and then runs RL, so the reward model can go stale as the policy changes. d-RLAIF queries the labeler during RL, which avoids that, but each training step calls the labeler, which costs more at run time. Monitor the labeler's agreement with a small set of human labels, check harmlessness and quality with human raters, and watch for length growth, since the paper found RL policies drifting toward longer responses.

Sources

Read the full paper

Harrison Lee, Samrat Phatale, Hassan Mansoor et al., 2023. arXiv:2309.00267