FDE Times dataFDE jobs open 928▲21 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 85Companies hiring 200Remote-friendly 24%Median US pay $200kTop hirer Databricks 107
中文VI

The newspaper of the Forward Deployed Engineer

Guides

The best eval set is already in your client's logs, once anonymized

Six steps turn raw production logs into a golden set, with a clear point at which to stop reading traces.

ShareLinkedInFacebookX

In brief

  • Scrub PII before the data reaches the eval runner, then review by hand, because tools do not catch everything
  • Sample randomly first, then sample by cluster so you do not test the same behavior over and over
  • Read at least 100 traces with pass/fail labels, until no new failure modes appear
Dot plot on a scale from 0 to 1,000. About 10 items are enough to explore a single problem (orange dot). Error analysis should read at least 100 traces. A full regression set is a band from 100 to 1,000 items.
A golden set should start at about 10 items for a single problem. A full regression set needs 100 to 1,000 items. Source: OpenRouter's guide to building a golden set; the 100-trace threshold is Hamel Husain's recommendation.

When a client hands you a raw production log in the first week of an engagement, the first thing to do with it is nothing. Leave it unopened.

OpenRouter’s guide to building golden sets puts this condition ahead of any sampling technique: PII anonymization must finish before the data reaches the eval runner, and the terms of service must be checked before anyone touches the logs.

The rule sounds obvious, yet it is easy to break. With a log in hand, an engineer’s reflex is to start reading, and that is also why client logs are so valuable: they show what real users ask, how they misspell things and where the system breaks.

But as Fireworks observes, using raw logs directly as an eval is not feasible; you have to cluster them and sample representatives from each cluster.

This guide walks through six steps that turn logs into a usable golden set. You need Python 3, a log file in JSONL format (one trace per line, with input and output), access the client has approved in writing, and someone on the client side who knows the business.

Step 1: anonymize first, and do not trust the tools completely

For detecting private entities, you can use Microsoft Presidio’s built-in modules. Presidio’s own documentation, however, states that there is no guarantee it will find all sensitive information, so you still need a manual review on top.

The code below is simplified: the scrub() function is where you plug in Presidio or whatever anonymization pipeline the client has approved. The regex check is only a second safety net; it does not replace anonymization.

import json, re

def scrub(text):
    # Simplified: replace with the client-approved anonymization pipeline (e.g. Presidio)
    return text

EMAIL = re.compile(r"[\w.+-]+@[\w-]+\.[\w.]+")

with open("raw_logs.jsonl") as src, open("logs_scrubbed.jsonl", "w") as dst:
    for line in src:
        t = json.loads(line)
        t["input"], t["output"] = scrub(t["input"]), scrub(t["output"])
        if EMAIL.search(t["input"] + t["output"]):
            print("Email still present in trace", t.get("id"))
        dst.write(json.dumps(t, ensure_ascii=False) + "\n")

Check: no warnings remain, and you have opened a few dozen random traces and read them yourself. For a third layer of checking, you can use Lilac, the tool Fireworks uses to find duplicates, PII and unusual content in traces.

Step 2: why sample randomly first?

Take one to two weeks of logs, draw a random sample first and only then look at what you got, in the order OpenRouter recommends. If you hand-pick from the start, you will only pick the failures you already expected.

import json, random
random.seed(42)  # so the next run produces the same sample

with open("logs_scrubbed.jsonl") as f:
    traces = [json.loads(line) for line in f]

batch = random.sample(traces, 100)

The figure of 100 has a basis. Hamel Husain considers reading traces by hand, or error analysis, the most important activity in evals, and he recommends looking at at least 100 traces.

Step 3: sample by cluster so you do not read the same failure fifty times

A random sample reflects the true proportions but wastes reading effort. Take a customer-service chatbot where most questions are order lookups: 100 random traces will give you dozens of near-identical questions, while the rare kind of question that causes failures may not appear even once.

Fireworks’ answer is to cluster and take representatives from each cluster, so you avoid testing the same behavior as many as 50 times. The code below runs on its own but assumes each trace already has a cluster_id from a clustering step of your choice (this is the simplified part).

import json, random
from collections import defaultdict
random.seed(42)

with open("logs_scrubbed.jsonl") as f:
    traces = [json.loads(line) for line in f]

by_cluster = defaultdict(list)
for t in traces:
    by_cluster[t["cluster_id"]].append(t)

per_cluster = [dict(random.choice(items), source="cluster") for items in by_cluster.values()]
random_part = [dict(t, source="random") for t in random.sample(traces, 30)]
batch = per_cluster + random_part

The random_part line is there for a reason. Every batch should keep a share of random traces, as Husain advises; targeted sampling is only a supplement for hunting rare failures. Drop the random share and the eval set will gradually drift away from reality.

Step 4: read traces with pass/fail labels

Open each trace and give it one label: pass or fail. The reason for a binary choice, according to Husain, is that it forces graders to think more clearly and label more consistently. When a trace fails, write a short phrase describing the failure mode.

{"id": "t-0193", "input": "...", "output": "...", "label": "fail", "failure_mode": "invented return policy", "source": "cluster"}

When do you stop? Husain’s criterion is to keep reading until new traces no longer reveal new failure modes or change the ones you already have. Check: count the distinct failure_mode values after every 20 traces. When the number stops moving, you are close to saturation.

Step 5: who writes the correct answers?

For each input, someone with enough expertise has to write what the correct output looks like, and OpenRouter is explicit about this. At an insurance company, that person is a claims specialist, not you. Your job is to prepare clean traces and ask the right questions.

Size depends on purpose: about 10 items is enough to explore a single problem, while a full regression suite needs 100 to 1,000 items, according to OpenRouter. So start with the 10 worst failing traces, have the expert write answers, and only then expand.

Step 6: does the eval set still look like production?

One anti-pattern OpenAI warns about is an eval set that does not faithfully reproduce the pattern of production traffic. Anthropic’s documentation also asks for evals that mirror the real distribution of tasks, with one addition: do not forget the edge cases.

Keeping production proportions and keeping enough edge cases pull in opposite directions, and step 3 has already given you a way to balance them. The random share preserves the real proportions; the cluster share preserves the edge cases. The source field added in step 3 lets you score each share separately.

If you use an LLM to grade automatically, you need human feedback to calibrate it, as OpenAI advises. The pass/fail labels from step 4 are that calibration data: run the grader over them and see where it disagrees with the humans.

The mistakes that force a full rebuild

The most expensive mistake is anonymizing after the logs have already been uploaded to a third-party eval tool. By then the data is out of your control, and no later step can fix that.

The second is picking only the “interesting” traces. The eval set looks sharp, but its scores say nothing about what most users experience. The third is letting engineers write answers for a business they do not understand, then optimizing the model against wrong answers.

What this skill looks like on site

In the first week of an engagement, ask for one to two weeks of anonymized logs and ask about the data-use terms at the same time, before any discussion of models. Bring this six-step process to the first meeting and the client will see that you thought about privacy before they had to raise it.

For your career, look for phrases such as “evals”, “error analysis” or “production data” in job postings. On your CV, do not just write “built evals”; say how many traces you read, how many failure modes you found and how many expert-labeled items the final regression suite contained.

Every model will eventually be replaced. A clean golden set, true to the production distribution and with expert-written answers, stays with the client, and that is what gets you invited back.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
6 sources
Read next on the roadmap · Stage 3: Applied AIThe CDRs a telco gives its AIOps team are often filtered firstMediation cleans call records for the billing team, so compare them with the raw data before an anomaly model learns from them.