Skip to content
AgenticAIWiki
  1. Learn
  2. Part 5
  3. 31. Alignment and distillation
  4. 31.1

Lesson 31.1 · 1 of 5 · 6 min read · Reviewed 24 Nov 2026

Preference data: chosen and rejected

By the end, you can

  • Describe the shape of a preference record: prompt, chosen and rejected.
  • Spot the data problems that teach a model the wrong lesson.

Supervised fine-tuningSupervised fine-tuning (SFT): Fine-tuning on pairs of inputs and ideal outputs. (29.2) shows a model one good answer. Preference tuningPreference tuning: Training a model to prefer some responses over others, using ranked or paired examples. (29.4) shows it two answers and says which is better. This chapter goes deeper, and it starts with the data, because the data decides what the model learns.

The record

{
  "prompt": "A customer says their parcel is late and they are angry. Reply.",
  "chosen": "I'm sorry it hasn't arrived. I've checked: it left the depot today and should reach you tomorrow. If it doesn't, reply here and I'll arrange a refund.",
  "rejected": "Parcels can be delayed for many reasons. Please wait 5 to 7 working days before contacting us."
}

Three fields. The prompt is the input. Chosen is the answer you want more of. Rejected is the answer you want less of. Some datasets add a score, a margin (“much better” or “slightly better”) or the rater’s reason.

Where pairs come from

Source How it works Watch for
Human raters People compare two model answers using written guidelines Slow and costly; raters disagree
AI feedback A strong model judges pairs against written principles Inherits the judge’s blind spots
Edits A person fixes a model answer; the fix is chosen, the original rejected Teaches style edits well, little else
Rules A checker marks one answer correct (tests pass, JSON parses) Only works for checkable tasks (31.3)

The best pairs are usually on-policy: both answers come from the model you are tuning, so it learns to move between things it actually says.

Teach one difference at a time

A good pair differs in the quality you care about and in little else. In the example above, both replies are short and polite. The difference is that the chosen one takes action. If the chosen answers were also always longer, the model could learn “longer is better” instead.

Worked check: four bad pairs

Problem Example Fix
Length bias Chosen is twice as long in most pairs Add pairs where the shorter answer wins
Tie Two answers equally good, one picked at random Drop it, or mark it as a tie and leave it out
Near-duplicate Chosen and rejected differ by one comma Drop it: there is nothing to learn
Noisy label Two raters disagree on the same pair Re-rate with clearer guidelines, or drop it

A quick sanity script catches most of these: compare lengths, measure how similar the two answers are, and check agreement on a sample rated twice.

Common mistakes

  • Vague guidelines. “Pick the better answer” gets you each rater’s taste. Write what better means, with examples.
  • Only style pairs. Include pairs about honesty, refusing correctly and admitting uncertainty, or the model may learn to please rather than to be right.
  • Testing on training pairs. Hold out a set of prompts the model never trains on (29.5).
  • Too few prompts, many pairs each. Breadth of prompts matters more than many pairs for one prompt.

Key points

  • A preference record is a prompt plus two answers, one marked chosen and one rejected.
  • The pair should differ in the quality you want to teach, and as little as possible in anything else.
  • Pairs come from human raters, from an AI judge guided by written principles, or from both.
  • Check for length bias, ties, near-duplicates and rater disagreement before training.
Hands-on labRuns in the Playground

Audit a batch of preference pairs

Find and drop the pairs that would teach a model the wrong lesson.

You will have: A cleaned list of pairs, with a reason for every drop and a length-bias check.

Steps

  1. Read the seven pairs and guess which are broken before you run anything.
  2. Fill in problem(): empty answers, ties and near-duplicates.
  3. Run it and check which pairs are kept.
  4. Read the length check. Write one new pair where the shorter answer wins and add it.

Done when

  • Three pairs are dropped, each with its reason.
  • The script prints kept 4 of 7.
  • It flags length bias above 60%.

Open in the Playground No API key needed.

Starter code (Python)
# Audit a batch of preference pairs: drop broken ones, then check for length bias.
from difflib import SequenceMatcher

pairs = [
    {"prompt": "Parcel is late", "chosen": "Sorry for the wait. I've sent you a tracking link.", "rejected": "Please wait 5 to 7 days.", "tie": False},
    {"prompt": "Wrong size", "chosen": "Sorry about that. I can send the right size today.", "rejected": "Sorry about that. I can send the right size today!", "tie": False},
    {"prompt": "Refund status", "chosen": "Your refund was issued yesterday.", "rejected": "", "tie": False},
    {"prompt": "Change address", "chosen": "I've updated the address on your order.", "rejected": "Addresses can be changed in Settings.", "tie": True},
    {"prompt": "Item damaged", "chosen": "I'm sorry it arrived damaged. A replacement is on its way, and you can keep the broken one.", "rejected": "Please send photos.", "tie": False},
    {"prompt": "Cancel order", "chosen": "Done: your order is cancelled.", "rejected": "To cancel an order you need to go to the orders page, find the order, and then follow the steps shown there.", "tie": False},
    {"prompt": "Delivery date", "chosen": "I can't see a delivery date yet. I'll email you when it ships.", "rejected": "It will arrive at 3pm on Friday.", "tie": False},
]


def problem(p):
    # TODO: return "empty answer" if either answer is blank
    # TODO: return "tie" if the pair is marked as a tie
    # TODO: return "near-duplicate" if SequenceMatcher(None, chosen, rejected).ratio() > 0.95
    return None


kept = []
for p in pairs:
    why = problem(p)
    if why:
        print(f"drop  {p['prompt']:<15} ({why})")
    else:
        kept.append(p)
        print(f"keep  {p['prompt']}")

# TODO: work out the share of kept pairs where chosen is longer, and warn if it is above 60%.
print(f"kept {len(kept)} of {len(pairs)}")
Show a solution
# Audit a batch of preference pairs: drop broken ones, then check for length bias.
from difflib import SequenceMatcher

pairs = [
    {"prompt": "Parcel is late", "chosen": "Sorry for the wait. I've sent you a tracking link.", "rejected": "Please wait 5 to 7 days.", "tie": False},
    {"prompt": "Wrong size", "chosen": "Sorry about that. I can send the right size today.", "rejected": "Sorry about that. I can send the right size today!", "tie": False},
    {"prompt": "Refund status", "chosen": "Your refund was issued yesterday.", "rejected": "", "tie": False},
    {"prompt": "Change address", "chosen": "I've updated the address on your order.", "rejected": "Addresses can be changed in Settings.", "tie": True},
    {"prompt": "Item damaged", "chosen": "I'm sorry it arrived damaged. A replacement is on its way, and you can keep the broken one.", "rejected": "Please send photos.", "tie": False},
    {"prompt": "Cancel order", "chosen": "Done: your order is cancelled.", "rejected": "To cancel an order you need to go to the orders page, find the order, and then follow the steps shown there.", "tie": False},
    {"prompt": "Delivery date", "chosen": "I can't see a delivery date yet. I'll email you when it ships.", "rejected": "It will arrive at 3pm on Friday.", "tie": False},
]


def problem(p):
    if not p["chosen"].strip() or not p["rejected"].strip():
        return "empty answer"
    if p["tie"]:
        return "tie"
    if SequenceMatcher(None, p["chosen"], p["rejected"]).ratio() > 0.95:
        return "near-duplicate"
    return None


kept = []
for p in pairs:
    why = problem(p)
    if why:
        print(f"drop  {p['prompt']:<15} ({why})")
    else:
        kept.append(p)
        print(f"keep  {p['prompt']}")

longer = sum(1 for p in kept if len(p["chosen"]) > len(p["rejected"]))
share = longer / len(kept)
print(f"kept {len(kept)} of {len(pairs)}")
print(f"chosen is longer in {share:.0%} of kept pairs" + (": length bias, add pairs where shorter wins" if share > 0.6 else ""))
Quick checkIn 85% of your pairs, the chosen answer is much longer than the rejected one. What will preference tuning most likely teach?
How sure are you?
Pick an answer and how sure you are