# What Does RLHF Do for Safety?

> How human ratings teach an AI model safer habits, what that training cannot stop, and how to explain it in your AI interview.

**In short:** RLHF uses human ratings of model replies to teach safer habits, such as refusing harmful requests and avoiding toxic language. It teaches habits that can still fail, so checks outside the model are still needed.

AI and LLM interview question Q230, Guardrails and AI safety. Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-does-rlhf-do-for-safety

## Say it in 30 seconds

RLHF stands for reinforcement learning from human feedback. People rate the model's replies, a second model learns those ratings, and the main model is trained to earn higher scores. For safety, careful, honest and harmless replies win. That teaches habits, but a clever prompt can still get past them, so I add checks in code, least access for tools and human sign-off on risky actions.

## Say it in 2 minutes

RLHF stands for reinforcement learning from human feedback. People compare pairs of model replies and pick the better one. For safety, the better reply is the one that helps and avoids harm. A second model, called a reward model, learns to predict those picks. Then the main model is trained to earn high scores from it.

The result is a habit. A model trained this way learns to refuse help with harm and to avoid toxic language. OpenAI's InstructGPT work reported fewer toxic outputs after this training. Anthropic's 2022 paper also found that helpfulness and harmlessness often stand in opposition to each other, so teams have to balance them.

A learned habit can still fail. Raters can be wrong, the reward model is an imperfect guess, and the model can learn to game that guess, which is called reward hacking. Attackers also write prompts that slip past learned habits. OWASP says no reliable prevention mechanism exists for prompt injection today, so I add checks in code, least access for tools and a human sign-off before risky actions.

On a claims assistant, a reply that promises flood cover should lose every rating. A reply that says an adjuster will check the policy should win. That is the safety signal RLHF gives. It is a learned preference, so it can still be wrong about a case nobody rated.

## What does RLHF do for safety, in plain words?

RLHF stands for reinforcement learning from human feedback. It comes after a model has learned to write text and a supervised fine-tuning step, where people teach it which replies are good. For safety, the lesson is simple: a careful, honest and harmless reply earns a higher rating than a harmful one.

Think of a new call-centre agent who gets coaching. A supervisor listens to recorded calls and marks the handling that was careful and right. Over months the agent stops reading a policy out to an upset customer and starts checking the account first. Nobody wrote a rule for every call. The habit came from the marked calls, and RLHF works the same way for a model. In an AI claims assistant, a reply that once promised flood cover loses its ratings, so the model learns to say an adjuster will check first.

- **Rater:** A person who compares two or more replies and picks the better one.
- **Reward model:** A second model trained to predict which reply raters would pick. It gives the score.
- **Fine-tuning:** Extra training on a model that already exists, usually with a smaller set of examples.
- **Red teaming:** Testers who try hard to make the model misbehave, which shows where it still fails.

A 2023 review of open problems says RLHF 'has emerged as the central method used to finetune state-of-the-art large language models'. It is a common topic when safety comes up.

## How does RLHF make a model safer?

After the supervised step, it runs in four steps. Each step is small, but the picks decide what the model learns.

1. **Raters compare replies:** Raters see the same prompt with two or more replies and pick the better one. For safety, the better reply helps and avoids harm.
2. **A reward model learns the picks:** After many picks, a reward model learns to score replies the way raters would. OpenAI describes it as a model trained 'to predict which output our labelers would prefer'.
3. **The main model is tuned:** Reinforcement learning nudges the main model toward replies the reward model scores high. Replies that break the rules score low, so the model moves away from them.
4. **Testers attack it:** Red teamers try to provoke harmful replies, which shows the team where the model still fails. Anthropic's 2022 paper describes its crowdworkers this way: they probe the model 'in order to provoke harmful responses'.

*Diagram, How rater picks become a safer habit: Raters and red-team attacks feed a reward model, which learns their picks. The main model is tuned toward high scores, so safer habits show up in its replies.*
1. Raters choose the better reply in each pair.
2. Red-team attacks surface the harmful replies.
3. The reward model learns to predict those choices.
4. The main model is tuned toward high scores, so its replies change.

The results come from tests. InstructGPT, OpenAI's 2022 paper, reported 'reductions in toxic output generation' and 'minimal performance regressions on public NLP datasets'. It still made simple mistakes, and the authors call fine-tuning with human feedback 'a promising direction'.

## What does this look like on a claims assistant?

Imagine an insurer's claims assistant. A policyholder asks "Will my flood claim be paid in full?" The assistant can answer in three ways, and raters pick a winner for each pair. The counts below are made up, and the code only counts wins, a rough stand-in for how a reward model learns scores from picks like these.

```python
# A simplified safety check for an insurance claims assistant. Raters read a policyholder's
# question and picked the better of two replies. We count their picks.
REPLIES = {
    "A": "Yes, flood damage is always covered. Go ahead and book the repair.",
    "B": "I can't say if this claim is covered. A claims adjuster will check your policy.",
    "C": "Your claim is probably covered. Please send the invoice to our team.",
}
# (winner, loser) pairs from the raters
PICKS = [("B", "A"), ("B", "C"), ("C", "A"), ("B", "A"), ("B", "C")]

def win_rate(reply_id):
    # A real reward model is a neural network trained on picks like these.
    wins = sum(1 for winner, _ in PICKS if winner == reply_id)
    games = sum(1 for pair in PICKS if reply_id in pair)
    return wins / games

for rid in sorted(REPLIES):
    print(rid, round(win_rate(rid), 2), REPLIES[rid])
print("Best:", max(REPLIES, key=win_rate))
```

Output:

```text
A 0.0 Yes, flood damage is always covered. Go ahead and book the repair.
B 1.0 I can't say if this claim is covered. A claims adjuster will check your policy.
C 0.33 Your claim is probably covered. Please send the invoice to our team.
Best: B
```

Reply A promised cover, so it lost every pair it was in. Reply B admitted it could not decide and sent the claim to a person, so it won every pair it was in. Reply C sits in between. The reward model learns that pattern, and the main model is nudged toward it.

## What can RLHF not fix?

RLHF changes which replies the model prefers. It does not give a guarantee, and its failures follow a few known patterns.

*Diagram, What rating training does not stop: A plain harmful request is the case the training was aimed at. A wrapped one can still get past the habit, since the habit is learned and can be argued around.*
1. A plain harmful request is the case the training was aimed at.
2. A wrapped request can still get past the habit.

- **Imperfect rewards:** The reward model is a guess at what raters want, and the model can learn to score well on the guess. That is reward hacking.
- **Clever wording:** A request wrapped in a role-play or a fake test can still get a harmful reply past a learned habit.
- **Injected instructions:** Text in a web page or email can still steer the model. Rating training does not stop that, so code has to check tool calls.
- **Over-refusal:** If raters punish anything risky-looking, the model can refuse ordinary questions too often. That is a separate problem to measure.

> "Reward models tend to be imperfect, and imperfection in reward models leads to reward hacking" (Casper et al., a review of RLHF's open problems)
>
> "LLMs make no architectural distinction between instructions and data, and their behavior is stochastic, so no reliable prevention mechanism exists today" (OWASP, LLM01:2026)

> **Tip:** Asked what you would add after RLHF? Name layers: checks in code, least access for tools, outside text marked as untrusted, and a human for risky steps. RLHF is one layer of several.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain answer: RLHF teaches a model habits from human ratings.
- [ ] The four steps: rate replies, learn a reward model, tune the model, red-team it.
- [ ] What it helps with: fewer toxic or harmful replies, checked with tests.
- [ ] What it cannot promise: reward hacking, clever wording and over-refusal.
- [ ] What else you add: checks in code, least access and human approval.
- [ ] How you measure it: red-team tests and a sample of real replies each week.

**Common traps**

- Trap: "RLHF makes the model safe, so nothing else is needed." Better: It teaches habits, and a learned habit can be argued away. Add checks in code that a prompt cannot change.
- Trap: "RLHF is a filter on the output." Better: It changes what the model learns to write. A filter is a separate check on text. Name both, and say which one checks the tool calls.
- Trap: "The raters decide what is safe, so it is objective." Better: Raters bring their own views and blind spots. Say who the raters are, what guidance they had, and how you test the result.

## Can you spot the weak claim?

**Spot the weak claim:** Which design-doc line overclaims what RLHF does?

A. We tuned the assistant with rater picks, so we also run a content filter on its replies.
B. We tuned the assistant with rater picks, so jailbreaks can no longer get past it.
C. We review a sample of replies each week to catch refusals that are too strict.
D. Raters compared pairs of replies, and a reward model learned to predict their picks.

**Answer:** B. Rater training lowers harmful replies, but clever wording can still get past it. Keep the filter, the checks in code and the weekly reviews.

**Quick check:** A bank's assistant now refuses ordinary account questions after RLHF. What is the most likely cause?

A. Raters rewarded cautious replies too heavily
B. The model has too few parameters
C. The system prompt is too short
D. The temperature is set to zero

**Answer:** A. That is over-refusal. If raters punish anything risky-looking, the model learns to refuse too often. Model size, prompt length and temperature are not the usual cause of that.

## Can you answer these from memory?

**Flash cards**

- **What does RLHF do for safety?** It teaches the model safer habits from human ratings of its replies.
- **What is a reward model?** A model trained to predict which reply a rater would pick. It gives the score.
- **What is red teaming in this setting?** Testers try to provoke harmful replies, which shows where the model still fails.
- **What did InstructGPT report?** Fewer toxic outputs, with minimal performance regressions on public NLP datasets.
- **What is reward hacking?** The model learns to score well on the reward model without being safe or helpful.
- **Is RLHF enough on its own?** No. It is one layer. Add checks in code, least access and human approval.

## Likely follow-up questions

- Q231 What is Constitutional AI? https://designervenkat.online/interview/ai/what-is-constitutional-ai
- Q232 What is over-refusal? https://designervenkat.online/interview/ai/what-is-over-refusal
- Q233 How do you balance safety and helpfulness? https://designervenkat.online/interview/ai/how-do-you-balance-safety-and-helpfulness
- Q241 What is reward hacking? (full answer coming)
- Q229 What is alignment? https://designervenkat.online/interview/ai/what-is-alignment

## Learn it in depth

- [AI safety and ethics](https://designervenkat.online/learn/ai-engineering/ai-safety-and-ethics)
