How Do You A/B Test an LLM Feature?
How to split real users between two versions of an LLM feature, pick the outcome that matters and roll out safely, explained for your AI interview.
In short
Split real users at random between the current version and the new one, measure what those users actually do, and ship the new version only if it wins without hurting cost or safety. Because LLM answers vary and take time to judge, run offline tests and a shadow run first.
12 min readIntermediateCommon · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
I'd split real users at random between today's version and the new one, and keep each user in one group. I'd measure a real outcome, like a task finished or a chat not passed to a person, and watch guardrails for cost and safety too. Before any user sees the new version, I'd run it offline and in a shadow run. I'd fix the length and the sample size up front, and not peek at the results every hour.
An A/B test shows two versions of a feature to different real users at the same time, then compares what those users do. With an LLM feature there are three extra problems. The same question can get a different answer each time. A good answer is hard to judge with one click. And a test can look like a win for a few days just by chance.
So I'd start before any user sees the change. I'd score the new prompt or model on a test set of past questions, then run it in shadow on copies of real requests, where its answers are hidden. Only then would a small share of real users get it, split by user ID so nobody flips between versions.
I'd pick one change per test, and one outcome that matters, like a finished task or a chat that didn't need a person. I'd also watch guardrails: cost per chat, speed, and wrong answers that matter. A new version that wins on the main number but breaks a guardrail doesn't ship.
Finally I'd decide the length and the sample size before starting, and I wouldn't stop early because one day looked good. Anthropic says A/B testing needs sufficient traffic, and that it takes days or weeks to reach significance. Those are the limits I'd tell the team up front.
What is an A/B test, in plain words?
An A/B test shows two versions of a feature to different real users, then compares what those users do. Version A is what you have today. Version B is the change, such as a new prompt, a newer model or a different search setting. (LLM means large language model, the AI that writes the replies.)
Picture a bank testing a loan form. Half the applicants see the old layout, half see the new one, and the layout with more finished applications wins. An LLM feature needs more care, because the same question can get a different answer each time, and a good answer is hard to judge with one click.
A made-up case: a bank's support assistant gets a new prompt that makes it check the fee schedule before quoting a fee. The test asks whether customers finish their task more often, and whether fewer chats are handed to a human agent. Only then do you decide.
Key words
- Control
- The current version, Version A. Everything is compared against it.
- Variant
- The new version under test, Version B.
- Sticky split
- Each user is put into one group and stays there for the whole test.
- Shadow run
- The new version runs on copies of real requests with its actions switched off, such as refunds or emails, so it cannot act. Users only see the current answer.
- Guardrail
- A number you must not hurt, like cost per chat or wrong payouts.
How do you set up the test?
Five decisions come before any real user sees Version B.
- 1
Change one thing
Test one prompt, model or setting at a time. If three things change, you can't tell which one moved the number.
- 2
Pick a real outcome
Choose what users actually get, like a finished task or a chat that doesn't need a human. Anthropic describes A/B tests as measuring actual user outcomes, such as task completion.
- 3
Split by user
Put each user into one group at random, and keep them there. Splitting by request mixes both versions into one person's chat.
- 4
Ramp up in stages
Test offline first, then run a shadow run, then give a small share of users the change, then more. Microsoft's guide to safe rollouts uses the same middle steps, mirroring a share of traffic and then sending a small share. It says: "Mirror a percentage of live traffic to the green deployment to validate it." Its name for the new version is the green deployment.
- 5
Decide the length first
Work out how many users and how many days you need before you start. Anthropic is blunt: "Slow; days or weeks to reach significance and requires sufficient traffic." Significance means the gap is big enough that luck is unlikely to explain it.
How an A/B test runs
Real users
each user lands in one group
Random split by user
Version A (today)
the current prompt or model
Version B (new)
the one change under test
Log each outcome
task done, escalation, thumbs down
Compare the groups
ship B only if it wins
- 1Each user is put into one group, and stays there.
- 2Group A's results go to the log, tagged with the user's outcome.
- 3Group B's results go to the same log, tagged B.
- 4A simple statistics check decides whether B really won, or got lucky.
Stages before a full rollout
Offline test set
past real questions, scored first
Shadow run
new version runs, users never see it
Small A/B share
a few percent of real users
Full rollout
only if the test wins and guards hold
- 1Only a version that passes the offline scores moves on.
- 2Clean shadow results open the small live test.
- 3A small live test that wins and keeps its guardrails goes to everyone.
Which number do you compare, and why is it hard?
The obvious number is what users do: finished tasks, chats handed to a person, thumbs-down clicks, or people coming back. These matter, but they are slow and blurry. A thumbs-down can mean a wrong answer, or a user in a hurry who clicked by mistake.
- Offline
A fixed test set
Fast and cheap, and it can run on every change. But its questions may not look like real traffic.
- Online
Real users
Shows what people really do, and controls for other causes. Slow, and it needs real traffic.
- Judge
A model grades the answers
Scales to thousands of answers, but it needs calibrating against human grades for accuracy.
Worked example, with made-up numbers. An insurer's claims triage agent reads each new claim and sends it either to auto-approval or to a human adjuster. Version B adds a step that checks the policy clause first. Over two weeks, 20,000 claims are split at random, 10,000 each. Version B cuts wrongly routed claims from 12 in 100 to 9 in 100, but takes 4 seconds longer per claim and costs more in model fees (billed per token, the small pieces of text the model reads and writes). The team ships B only if the wrong-payout guardrail holds and the extra cost fits the budget.
Real results exist too. A 2026 paper on re-ranking (reordering search results with an LLM) for real estate search reports a production A/B test.
“A/B testing validates significant changes once you have sufficient traffic”
Anthropic
“a statistically significant increase in production of +5.3% in click-through rate and +4.8% in scheduled visits”
Real estate search paper (arXiv, 2026)
What goes wrong, and how do you avoid it?
A few mistakes come up again and again in these tests.
Peeking
Checking every hour and stopping when B looks ahead. Early swings are noise, so decide the length first.
Switching mid-run
Changing the split or the prompt while the test runs makes the two groups hard to compare.
Too little traffic
A small gain can't be told apart from luck. Plan the sample size, or test a bigger change.
Mixed groups
One user seeing both versions, or several users sharing one account, blurs the result. Split by user ID.
One number only
B can win on finished tasks while cost or wrong answers get worse. Keep the guardrails in the decision.
Trusting the judge
A model grader needs calibrating against human grades before you trust it. Check it on a sample.
Here it is in plain Python: a stable split by user ID, with made-up numbers. A hash of the user ID picks the group, so the same person always gets the same version, and nothing has to be stored.
import hashlib
EXPERIMENT = "refund-prompt-v2"
def bucket(user_id):
# The same user always gets the same version, so they never flip between the two.
digest = hashlib.sha256(f"{EXPERIMENT}:{user_id}".encode()).hexdigest()
return "B" if int(digest, 16) % 100 < 10 else "A" # 10% of users get version B
users = [f"cust-{i}" for i in range(10000)]
counts = {"A": 0, "B": 0}
for user in users:
counts[bucket(user)] += 1
print("users per version:", counts)
print("cust-42 group:", bucket("cust-42"))Output
users per version: {'A': 8999, 'B': 1001}
cust-42 group: BTwo things to notice. The split is fixed by code, so a busy week can't flip a user's version. And the counts land close to the 10 percent target, which is what a fair split should do.
How would you A/B test a hospital note summariser?
A wrong summary can hurt a patient, so you never start with patients. Begin with past notes that clinicians have already reviewed, and score the new prompt against their corrections.
Next, run the new version in shadow on copies of new notes. Clinicians then grade a random sample of both versions blind, without knowing which is which. Only after that does a small share of clinicians, not patients, see Version B in their work.
Set the guardrail with the clinical team before the test starts, for example no dropped medication change at all, whatever the win rate. A model grader can help with the bulk of the notes, but people check the sample.
Tip
Name the guardrail you would never trade for a better win rate. Interviewers want to hear that a metric can't buy a safety loss.
What does the interviewer want to hear?
A strong answer covers
- A random split by user, kept fixed for the whole test.
- One change at a time, with a clear outcome.
- Guardrails for cost, speed and safety, not only the win metric.
- Enough users and days, decided before the test starts.
- Offline and shadow checks before any real user sees Version B.
- Honest limits: a test shows what happened. It may not show why.
Common traps
Trap"We run it for a day and pick the higher number."
BetterOne day is rarely enough to tell two versions apart. Decide the length and the sample size first.
Trap"The judge model scored B higher, so we ship it."
BetterA model judge needs calibrating against human grades before you trust it.
Trap"Split by request, so both versions get tested."
BetterA user who sees both versions gives mixed data. Split by user and keep them in one group.
Can you spot the problem?
Spot the problem
A team runs an A/B test on a new prompt. Which step breaks the test?
Quick check
A new prompt raises finished tasks by 2 points (say 60% to 62%, made-up numbers), but cost per chat rises 30%. What is the right call?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
- Q247Offline vs online evaluation?11 min
- Q248What is a golden dataset, and how do you build one?11 min
- Q257How do you regression-test prompts?12 min
- Q259Which production metrics matter for a chatbot?10 min
- Q260What is tracing for LLM apps?10 min
- Q262"The model got worse after an upgrade." What do you do?12 min
Learn it in depth
Last updated on 26 November 2026
Shipping an LLM feature and not sure how to prove it works?
I design and build AI products and agents, including the tests and measurements behind them. Book a short call and tell me what you're shipping.