Glossary/R/RLHF
Models Also called: reinforcement learning from human feedback, preference tuning, preference fine-tuning, reward model training, RLAIF

What is RLHF?

RLHF, reinforcement learning from human feedback, is a post-training method that teaches a model which of its own answers people prefer. Labelers rank several outputs for the same prompt, a reward model learns to predict those rankings, and a reinforcement learning algorithm such as PPO updates the language model to score higher on that reward while a KL penalty keeps it close to where it started. RLHF happens before you get the weights; there is no RLHF parameter on an inference call.

What are the three steps of RLHF?

The recipe most people mean comes from InstructGPT (Ouyang et al., 2022). First, OpenAI fine-tuned GPT-3 with supervised learning on answers written by labelers. Second, labelers ranked between 4 and 9 model outputs per prompt, which gives K choose 2 pairwise comparisons, and a reward model was trained on those comparisons to score any response. Third, the supervised model was trained further with PPO, a reinforcement learning algorithm, to produce responses the reward model scores highly.

During the PPO step the paper adds a per-token KL penalty from the supervised model at each token, to mitigate over-optimization of the reward model. The penalty grows as the trained model's token probabilities move away from the supervised model's.

The idea predates language models. Christiano et al. (2017) trained agents on Atari games and simulated robot locomotion from human preferences between pairs of trajectory segments, with feedback on less than one percent of the agent's interactions.

Why does every preference method get called RLHF?

In model cards and launch posts, "trained with RLHF" usually means any post-training on preference data. In papers and training code the word is narrower: a learned reward model plus a reinforcement learning loop that samples from the model being trained. Several common methods fall outside that narrow sense.

  • DPO (Rafailov et al., 2023) solves the same objective with a simple classification loss on preferred and rejected pairs. It trains no separate reward model and runs no RL sampling loop.
  • RLAIF, named in Anthropic's Constitutional AI paper (Bai et al., 2022), keeps the preference model and the RL step but takes the preference labels from an AI model instead of people.

When a vendor says RLHF, read the technical report to find out which of these it ran. If you are choosing a method for your own model, use the narrow meaning. Full RLHF trains a reward model and then samples new responses from the model throughout training, while DPO trains from a fixed file of pairs.

What can you run yourself?

On a hosted API, the preference option you are most likely to find is DPO. OpenAI's fine-tuning API takes method.type: "dpo" and a JSONL file where each line holds an input, a preferred_output and a non_preferred_output. Training is limited to one-turn examples, and the preferred and non-preferred messages must be the last assistant message. The beta hyperparameter runs from 0 to 2 and sets how closely the new model sticks to its previous behaviour versus the preferences; leave it at auto to use the platform's value. The guide recommends running SFT on your preferred responses before the DPO job.

On your own GPUs, Hugging Face's TRL library groups the pieces as trainers: SFTTrainer for the supervised step, RewardTrainer for the reward model, GRPOTrainer and RLOOTrainer among its online methods, and DPOTrainer and KTOTrainer among its offline methods.

What does RLHF change in the model you call?

InstructGPT used supervised fine-tuning followed by RLHF to make GPT-3 follow user instructions. In the paper's human evaluations, outputs from the 1.3B-parameter InstructGPT model were preferred to outputs from the 175B GPT-3, a model with 100 times more parameters.

The same paper reports regressions against GPT-3 on certain public NLP datasets after RLHF and calls this an alignment tax. If an instruct model underperforms on a narrow task, run your eval against the base model of the same family before you assume your prompt is at fault.

A preference pair and a DPO job on OpenAI's fine-tuning API

$ head -n 1 prefs.jsonl
{"input": {"messages": [{"role": "user", "content": "Summarise this stack trace in one line: KeyError: 'user_id' in auth/middleware.py line 42"}]}, "preferred_output": [{"role": "assistant", "content": "auth/middleware.py line 42 reads request['user_id'], and the request has no user_id key."}], "non_preferred_output": [{"role": "assistant", "content": "There is an error in your code. You should check your middleware and make sure all keys exist."}]}

$ cat dpo_job.py
from openai import OpenAI

client = OpenAI()
uploaded = client.files.create(file=open("prefs.jsonl", "rb"), purpose="fine-tune")
job = client.fine_tuning.jobs.create(
    training_file=uploaded.id,
    model="gpt-4.1-mini-2025-04-14",
    method={
        "type": "dpo",
        "dpo": {"hyperparameters": {"beta": 0.1}},
    },
)
print(job.id, job.status)

Each line pairs one prompt with a preferred and a non-preferred final assistant message, in the field names OpenAI's DPO guide uses. The job sets method.type to dpo and passes beta under dpo.hyperparameters; the model name is one of the guide's supported models. Nothing here trains a reward model or runs a PPO loop, so in the narrow sense this is preference tuning with no RL step.

Common questions

RLHF: frequently asked

Is DPO a kind of RLHF?

It solves the same problem without the RL. The DPO paper describes its method as solving the standard RLHF problem with only a simple classification loss, so there is no separate reward model and no sampling loop. Marketing copy often files DPO under RLHF; training code and papers keep them apart.

Can I do RLHF through a provider's API?

You can usually do preference tuning, which is close. OpenAI's fine-tuning API offers DPO on a list of supported models, trained from pairs of preferred and non-preferred responses. For the full reward model and RL loop you need open weights and a training library such as TRL.

How is RLHF different from fine-tuning?

RLHF is a kind of fine-tuning with a different training signal. Supervised fine-tuning shows the model the answer you want and trains it to reproduce that answer. RLHF trains on comparisons: the model learns which of two answers people ranked higher, through a reward model and an RL step. InstructGPT ran supervised fine-tuning first and RLHF after it.

What is RLAIF?

RL from AI feedback. Anthropic's Constitutional AI paper trains a preference model on preferences labelled by an AI model, then trains with RL using that preference model as the reward signal. The pipeline matches RLHF; only the source of the labels changes.

Sources

Where these facts come from