# How Do You Sample Production Traffic for Evals?

> How to choose live chats to score for AI evals: random, stratified and flagged samples, privacy and weighting, for your AI interview.

**In short:** Take a sample of whole conversations from live traffic, not every chat. Use a random slice for the honest failure rate, and a fixed floor for rare, risky requests so their failures are not missed.

AI and LLM interview question Q265, Evaluation and observability. Intermediate, occasional (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/how-do-you-sample-production-traffic-for-evals

## Say it in 30 seconds

Production traffic is the real chats my AI gets after launch. I don't score every one, because a judge or a person has to read each chat. I take a random slice for the honest overall failure rate. I also keep a fixed floor of rare, risky chats, like fraud reports, so their failures are not missed. Before I quote a rate from the floor, I weight it back to real traffic. And I mask personal data before anyone reads a chat.

## Say it in 2 minutes

Production traffic is the real stream of questions users send after launch. I rarely score all of it, because every score takes the time of a judge, another AI model that grades answers, or of a person. So I sample. The first question is what the sample is for. If I want the honest failure rate for the whole bot, I use a random slice. Every chat has the same chance of being picked, so the rate reflects real traffic.

Random slices miss rare cases. In a card-help bot, maybe one chat in a hundred is a possible fraud report, and a small random slice may catch only two of them. So I add a stratified floor: a fixed number of fraud chats, picked on purpose. That finds failures in the risky group, but it tilts the numbers. Before I quote an overall rate, I weight each group back to its real share of traffic.

User thumbs-down clicks are a useful place to look for bugs, but they are self-selected, so they cannot give a rate. I also keep the setup honest in other ways. I set one rate for logging, which decides what is saved, and a second for scoring, which decides what is graded. I mask personal data before anything is stored or read, and a person reads a few scored chats each week to check the judge.

Each real failure goes into the test set, so the next release is checked for it. I also say the limit: a sample of a few hundred chats still wobbles, so I size it to the risk I must catch.

## What does sampling production traffic mean, in plain words?

Production traffic is the real stream of chats and requests that users send after the app goes live. Sampling means taking a small set of those chats to score, instead of scoring all of them. Every score needs a judge, which is another AI model that grades the bot's answers, or a person to read the chat. Both take time and money.

Think of a bank's call-quality team. They do not play back every call. Each week they listen to a random set of recorded calls, which tells them how the phone line is doing overall. They also listen to every call about a serious issue, such as a report of fraud, because one missed fraud call matters more than its small share of all calls.

An AI case works the same way. A made-up card-help bot gets about 10,000 chats a day. About 1 in 100 is a possible fraud report, and a bot that misses those is the failure that hurts customers most.

- **Production traffic:** The real chats and requests from users, after the app is live.
- **Trace:** The saved record of one chat: each step the bot took, the tools it used and its answer.
- **Stratified sample:** A sample that picks a set number from each group, so rare groups are not missed.
- **Sampling rate:** The share of chats kept. A rate of 0.1 means one chat in ten.
- **Test set:** The saved set of test chats that the team reruns before each release.

## Which chats should you sample?

There are three common ways to pick chats. Each one answers a different question, so a good team uses more than one.

- **Random: Every chat has the same chance.** A plain random slice of live chats. It gives the honest overall failure rate, but a rare, risky case may never be picked.
- **Stratified: A fixed floor for each group.** A set number is picked from each group, such as fraud reports. It finds rare failures, but its numbers tilt, so weight them before you quote a rate.
- **Signal-triggered: Chats that users flagged.** Thumbs-down clicks, chats passed to a human agent, and chats where a safety filter stepped in. Good for finding bugs to fix, but biased, so never quote a rate from it.

Anthropic's guide calls user feedback "sparse and self-selected", which is why thumbs-downs can point at bugs but cannot give a rate. OpenAI's guide makes a related warning: eval data can fail to "faithfully reproduce production traffic patterns".

> "Biased design: Creating eval datasets that don't faithfully reproduce production traffic patterns." (OpenAI, evaluation best practices)
>
> "Production monitoring kicks in post-launch to detect distribution drift and unanticipated real-world failures." (Anthropic, on agent evals)

*Diagram, Where the sampled chats go: Each saved chat is sorted into one of three groups, and every group is scored. A person reads a few scored chats each week, and each real failure joins the test set. Only the random slice gives an honest rate, and the floor group must be weighted before you quote it.*
1. Each chat is saved as a trace, with personal data masked.
2. Some saved chats are picked at random.
3. Rare, risky chats are picked on purpose.
4. Chats that users flagged are picked too.
5. Random picks are scored with code checks and a judge.
6. Floor chats go through the same scoring.
7. Flagged chats go through the same scoring.
8. A person reads a few scored chats each week.
9. Each real failure joins the test set.

Two settings are easy to mix up. The logging rate decides how many chats are saved as traces at all. The scoring rate decides how many saved traces get graded. A chat that was never logged cannot be scored later. LangSmith's docs describe the same idea: at high volume, you may not want to log every trace.

## How do you keep a sampled score honest?

The trap is quoting a rate from a sample that was tilted on purpose. Here is the made-up card-help bot again, with the numbers printed. The code uses a fixed seed, so every run prints the same result.

```python
# A made-up bank's card-help bot: 10,000 chats, about 1 in 100 is a possible fraud report.
# Made-up failure rates: the bot misses 1 in 10 fraud reports and 1 in 100 other chats.
import random

rng = random.Random(7)  # a fixed seed, so every run prints the same numbers
chats = [{"fraud": rng.random() < 0.01} for _ in range(10_000)]
for c in chats:
    c["failed"] = rng.random() < (0.10 if c["fraud"] else 0.01)

fraud = [c for c in chats if c["fraud"]]
other = [c for c in chats if not c["fraud"]]
rate = lambda group: sum(c["failed"] for c in group) / len(group)
print(f"Fraud chats: {len(fraud)} of {len(chats)}, true failure rate: {rate(chats):.1%}")

random_2pct = rng.sample(chats, 200)  # a plain random 2% slice
print(f"Random 2% sample: {sum(c['fraud'] for c in random_2pct)} fraud chats")

stratified = rng.sample(fraud, 100) + rng.sample(other, 200)  # a floor of 100 fraud chats
share_fraud = len(fraud) / len(chats)
print(f"Stratified sample, unweighted: {rate(stratified):.1%}")
weighted = share_fraud * rate(stratified[:100]) + (1 - share_fraud) * rate(stratified[100:])
print(f"Stratified sample, weighted to real traffic: {weighted:.1%}")
```

Output:

```text
Fraud chats: 106 of 10000, true failure rate: 1.1%
Random 2% sample: 2 fraud chats
Stratified sample, unweighted: 4.0%
Stratified sample, weighted to real traffic: 2.1%
```

A plain random 2% slice, 200 chats, caught only 2 fraud reports. That is too few to judge how the bot handles fraud. So the team takes a floor of 100 fraud reports and 200 other chats. Scored as they are, those 300 chats say 4.0%, which is too high, because fraud is over-represented. Weighted back to real traffic, the same chats say 2.1%. The true rate in this made-up data is 1.1%, so the weighted figure still wobbles with only 300 chats. The lesson is the direction of the tilt, not the exact figure.

*Diagram, Weighting a stratified sample: Each group is measured on its own sample. The fraud group gets its small real share and the other chats get their large one, so the total matches real traffic.*
1. The fraud group is scored on its own sample.
2. The other chats are scored on their own sample.
3. Fraud's rate gets its small real share.
4. The other chats' rate gets their large share.
5. The weighted total is the rate you quote.

### How would you set up sampling for a bank's card-help bot?

Start with the risk, not the traffic. The bot can freeze cards and open fraud cases, so a missed fraud chat hurts a real customer. A customer types "Someone used my card in another city, what do I do?" and the bot answers with a refund policy instead of opening a fraud case. That is the failure I must catch, even when it is rare.

1. **Mask, then store:** Save each chat as a trace, but mask card numbers, names and addresses before anything is stored or read. LangSmith's docs also suggest a dedicated tool for finding personal data (PII, personally identifiable information) in harder cases.
2. **Set the two rates:** Log every chat that mentions a card, using conditional tracing (a rule that always logs chosen requests), and sample the rest at a rate the team can afford to read. Then set a separate scoring rate on the saved traces.
3. **Keep a floor for fraud:** Each week, take a fixed set of fraud and freeze chats, so a rare failure always gets read. Weight the numbers before you quote them.
4. **Check with code first:** Code checks cheap facts first, such as whether a fraud case was opened. A judge model then grades the rest against a written scoring guide.
5. **Put a person on it:** A reviewer reads a few scored chats each week and checks that the judge agrees with them. Anthropic's guide says to sample transcripts to read weekly.
6. **Feed failures back:** Each real failure joins the test set, so the next release is checked for it.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Sample whole conversations, not single messages.
- [ ] A random slice for the honest overall rate.
- [ ] A fixed floor for rare, high-stakes groups, weighted before you quote a rate.
- [ ] Two settings: how many chats are logged, and how many are scored.
- [ ] Personal data masked before anything is stored or reviewed.
- [ ] Every real failure goes back into the test set.

**Common traps**

- Trap: "Score 20 chats a week and we have it covered." Better: Twenty chats cannot show a 1 in 100 risk. Size the sample to the risk you must catch.
- Trap: "Thumbs-down chats show our failure rate." Better: Thumbs-downs are a self-selected group. Use them to find bugs, and a random slice for the rate.
- Trap: "We log everything, so there is nothing to sample." Better: Logging everything costs storage and review time, and stores more personal data. Sample what you read, and mask what you keep.

## Can you spot the bias?

**Spot the bias:** A team reads only the chats users thumbs-down, then reports a 38% failure rate. Which statement is safe to make?

A. The bot fails 38% of all chats.
B. The 38% describes only the chats users thumbed down, so we review that group first.
C. The bot needs a bigger model, because 38% is too high.
D. Our sample is random, so 38% is the real rate.

**Answer:** B. Thumbs-down chats are a self-selected group, so 38% describes that group only. Use them to find bugs, and use a random sample for the overall rate.

**Quick check:** Which sample gives an honest overall failure rate for the whole bot?

A. The 200 chats users flagged
B. A random slice of live chats, taken as they arrive
C. Only chats from the bank's premium customers
D. The first hour of chats after launch

**Answer:** B. A random slice covers traffic as it really arrives. The other three pick a group on purpose or by accident, so the rate tilts.

## Can you answer these from memory?

**Flash cards**

- **What is production traffic?** The real chats and requests from users, after the app is live.
- **Why not score every chat?** A judge or a person has to read each one, which is slow and costs money.
- **What is a random sample for?** The honest overall failure rate for the whole bot.
- **What is a stratified sample for?** A floor of rare, high-stakes chats, so their failures are not missed.
- **Why weight a stratified sample?** Otherwise the over-sampled group pulls the overall rate toward its own rate.
- **Logging rate vs scoring rate?** Logging decides what is saved. Scoring decides what is graded.

## Likely follow-up questions

- Q247 Offline vs online evaluation? https://designervenkat.online/interview/ai/offline-vs-online-evaluation
- Q259 Which production metrics matter for a chatbot? https://designervenkat.online/interview/ai/production-metrics-for-a-chatbot
- Q260 What is tracing for LLM apps? https://designervenkat.online/interview/ai/what-is-tracing-for-llm-apps
- Q261 How do you detect drift? https://designervenkat.online/interview/ai/how-do-you-detect-drift
- Q268 How many eval examples are enough? https://designervenkat.online/interview/ai/how-many-eval-examples-are-enough
- Q248 What is a golden dataset, and how do you build one? https://designervenkat.online/interview/ai/what-is-a-golden-dataset
