AI Hints
Home›Fine-Tuning LLMs Tutorial›Preference Tuning and DPO
Fine-Tuning LLMs · Lesson 91 of 120

Preference Tuning

Learning from better and worse.

⏱ 2 min read▶ Video at 2:18:15🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

Supervised fine-tuning shows the model one good answer. But often, it's easier to say which of two answers is better, than to write the perfect one. Training on those choices is called preference tuning.

  • SFT shows one good answer
  • Easier to pick the better one
  • Preference tuning

SFT vs preference tuning

In supervised fine-tuning, each example is a prompt, and one answer to copy. In preference tuning, each example is a prompt, a chosen answer, and a rejected answer. The model learns to make chosen answers more likely, and rejected answers less likely.

SFT

  • Prompt + one answer
  • Copy the answer
  • Teaches format and task

Preference tuning

  • Prompt + chosen + rejected
  • Prefer chosen over rejected
  • Teaches style and quality

The classic recipe: RLHF

The first famous method was RLHF. Reinforcement learning from human feedback. First, people compare pairs of answers. Then a reward model learns to score answers like those people. Finally, reinforcement learning trains the chat model, to get high scores. It works, but it's complicated, and unstable.

  1. People compare answers
  2. Train a reward model
  3. RL to maximise reward
  4. Complex and unstable

Where it fits

In practice, preference tuning comes after supervised fine-tuning. First, SFT teaches the task, and the format. Then preference tuning polishes the style. Polite, not rude. Helpful, not vague. Safe, not harmful.

keyvalue
Step 1SFT: task and format
Step 2preferences: style
Examplespolite, helpful, safe
OrderSFT first, then preferences

Summary

Let's recap. Preference data has a chosen, and a rejected answer. RLHF uses a reward model, and reinforcement learning. And preference tuning usually comes after SFT. Next, a simpler method. DPO.

Key takeaways
  • Chosen vs rejected
  • RLHF: reward model + RL
  • After SFT
Next up: DPO — preferences without a reward model