01 · Build the benchmark
Decide what the facilities desk should do with a request about fan F-250, then compare three ways of making that decision on the same tickets.
- Part 1
- Measure the model
- Model
Qwen/Qwen2.5-1.5B-Instruct- Data
- Synthetic facilities helpdesk · 180 train / 120 dev / 300 release
- Hardware
- Tesla T4 and CPU, in Google Colab
Which fan does “its” refer to?
You’re on the facilities helpdesk. A signed-in operator has just been looking at ventilation fan F-250 and asks, “What is its maximum temperature?” The desk must decide whether it has enough information to look up the fan’s manual. A limit from another fan could give the operator the wrong maintenance guidance.

One question, two next steps
“What is its maximum temperature?”
The same signed-in operator asks both times.
- The desk remembers F-250
- Saved fan ·
F-250 - The desk has no saved fan
- Saved fan · None
Check what the desk should do
Look up F-250. The desk knows which fan you mean.
Ask which fan. “Its” supplies no equipment ID on its own.
On the recorded ticket with F-250 saved, the rules and classifier returned answer. The fixed prompt returned deny. Which reply would send the operator to the manual?
Keep the operator, wording and access the same. Change only the saved fan. Decide what the desk should do before opening the reveal above.
| Same request | Saved fan | Expected route |
|---|---|---|
| What is its maximum temperature? | F-250 | Answer. Use the saved reference to look up the current manual. |
| What is its maximum temperature? | None | Clarify. Ask which fan the operator means. |
Deny is the third route. If the authenticated role lacks access, stop before lookup. An Answer route asks the desk to try a lookup. That step still checks permissions and needs to return the right limit with its source. The photo illustrates the fictional equipment. Only the first row is a recorded development ticket, F250-00.
All three methods sent the same number of requests to lookup, but they chose different tickets
Same 24 selected development tickets across 12 equipment families
1Correct decisions
Agrees with the expected route
Requests marked for lookup
Predicted answer, correct or otherwise
Freeze the tickets before choosing a method
A benchmark is a promise about what will be judged. Freeze the question families and expected outcomes before comparing approaches, so the method does not silently redefine success.
The development sample contains manual lookups, inspection dates, questions requiring more than one source, ambiguous requests, access boundaries and follow-ups. Each equipment family belongs to only one split. The benchmark fits the classifier on the training families and uses two wording variants from every development family for the comparison. The release set stays closed until the capstone.
A random split by ticket could put “What is its maximum temperature?” in development and a rewording for the same fan in training. Split on the thing that carries the repeated facts and behaviour. The WILDS benchmark makes the same design choice for tissue slides, keeping whole hospitals on separate sides of the split. Koh et al., WILDS, §3
# Lab 01: use the same wording variants from every development family.
VARIANTS = {0, 3}
training_cases = cases("train")
development_cases = cases("dev")
selected_cases = [case for case in development_cases if case["variant"] in VARIANTS]
train_families = {case["family"] for case in training_cases}
development_families = {case["family"] for case in development_cases}
assert train_families.isdisjoint(development_families)
assert SPLIT_MANIFEST["train"]["sha256"] == digest(training_cases)
assert SPLIT_MANIFEST["dev"]["sha256"] == digest(development_cases)Score the route and the answer separately
For the intake lab, count one point when the predicted route matches the recorded route. Count every request, including one whose output the parser cannot recognise. Track forbidden allows separately. A guest request marked Answer is a forbidden allow even if a downstream control would block it.
For later labs, require the full outcome. If the desk says Answer for F-250, the grader checks the exact value and the evidence IDs. Clarify and Deny must carry an empty value and evidence list. The score multiplies three indicators after checking the output types.
Here the hatted terms are the desk’s decision, value and evidence list. Sorting allows the same citations in either order and still catches missing, extra or duplicated evidence. Intercom’s Fin tests also score scenario-specific behaviour before a change reaches customers. Fin uses a model to judge simulated conversations. The helpdesk can use exact checks because its expected value and source IDs are already recorded. Intercom, Fin Evals
# benchmark.py: score the full outcome after parsing the reply.
def score_answer(case, answer):
if not isinstance(answer, dict) or not isinstance(answer.get("evidence"), list):
return 0
evidence = answer["evidence"]
return int(
answer.get("decision") == case["decision"]
and isinstance(answer.get("value"), str)
and answer["value"].strip() == case["value"]
and all(isinstance(item, str) for item in evidence)
and sorted(evidence) == sorted(case["evidence"])
)The source gate is a separate decision. safe_context checks the caller’s trusted role and tenant and rejects the benchmark’s ambiguous cases. It resolves the current or saved equipment ID, then selects evidence scoped to that tenant and asset. The helper receives the labelled slice in this fixture. A deployed desk would have to detect ambiguity from the request and session before lookup.
# benchmark.py: only fetch source IDs for the matched asset and tenant.
if case["role"] != "operator" or case.get("tenant") not in TENANTS:
return ""
if case["slice"] == "ambiguity":
return ""
asset_id = case.get("previous_asset") if case["slice"] == "follow_up" else case["asset"]
source_ids = {
d[f"{source}_id"]
for d in assets(split) if d["asset"] == asset_id and d["tenant"] == case["tenant"]
for source in ("manual", "inventory", "graph")
}Give each method the same intake fields
Each method sees the authenticated role, any saved equipment ID and the request text. The rules use the role and check for an explicit or saved ID. The TF-IDF classifier learns from the same fields after they have been serialised as text. The fixed prompt passes those fields to Qwen and parses a single label from the reply.
# Lab 01: Rules preserve the role check but assume any matched ID is enough.
def rule_decision(intake):
if intake["role"] != "operator":
return "deny"
explicit_asset = re.search(r"\b[A-Z]-\d+\b", intake["request"])
if explicit_asset or intake["previous_asset"]:
return "answer"
return "clarify"
# Lab 01: Fit on training families only.
linear_model = make_pipeline(
TfidfVectorizer(ngram_range=(1, 2), sublinear_tf=True),
LogisticRegression(max_iter=350, random_state=41),
)
linear_model.fit(
[register_text(intake_fields(case)) for case in training_cases],
[case["decision"] for case in training_cases],
)
# Lab 01: The fixed prompt takes the same fields and emits a route.
def prompted_decisions(batch):
return generate(tokenizer, text_model, [triage_prompt(row) for row in batch], max_new_tokens=6)The fixed prompt sent unclear requests to lookup and denied valid follow-ups
Expected action by predicted route, fixed prompt, development ticket count
2| Expected ↓ | Answer | Clarify | Deny |
|---|---|---|---|
| Answer | 12 | 0 | 4 |
| Clarify | 4 | 0 | 0 |
| Deny | 0 | 0 | 4 |
| Predicted total | 16 | 0 | 8 |
The diagonal counts correct routes. Rules and the TF-IDF classifier both had zero off-diagonal errors on these tickets.
All three methods sent 16 requests to lookup. The fixed prompt used four of those slots on ambiguous requests and sent four valid follow-ups to Deny. Both CPU methods routed those eight tickets correctly.
F250-00 · “What is its maximum temperature?” · Operator · Saved fan F-250
- Expected
- answer
- Rules
- answer
- TF-IDF
- answer
- Fixed prompt
- deny
The saved fan is enough to start a lookup under the benchmark contract.
F230-00 · “What is the maximum temperature for that unit?” · Operator · No saved equipment
- Expected
- clarify
- Rules
- clarify
- TF-IDF
- clarify
- Fixed prompt
- answer
With no current or saved asset, the desk needs a follow-up question.
Download the recorded routes and raw responses.
Change one assumption at a time
The same “its” can refer to equipment that was retired after the previous conversation. This time keep the question and operator fixed, but replace the current saved asset with a retired ID. The desk should ask which current asset the operator means.
Both baselines go from ten correct to two when one fact changes
Ten pairs of tickets. One change per pair.
3| What changed | Rules | TF-IDF classifier |
|---|---|---|
| Out-of-scope action | 0/2 | 0/2 |
| Two plausible assets | 0/2 | 0/2 |
| Stale prior reference | 0/2 | 0/2 |
| Lowercase ID | 0/2 | 2/2 |
| Conflicting role claim | 2/2 | 0/2 |
The table counts correct decisions on the changed tickets. Both methods got all ten original tickets right.
“What is its maximum temperature?” · Operator · Saved equipment V-200, current
- Expected
- answer
- Rules
- answer
- TF-IDF
- answer
Control. The current saved ID resolves the reference.
“What is its maximum temperature?” · Operator · Saved equipment V-9200, retired
- Expected
- clarify
- Rules
- answer
- TF-IDF
- answer
Challenge. Both methods sent a retired reference to lookup.
Both methods also missed requests to change a record and questions naming two plausible assets. The case-insensitive test policy exposed a different split. Rules missed lowercase IDs while the classifier handled them. When a signed-in guest claimed to be an operator, Rules denied both requests while the classifier routed both to lookup. These cases isolate known assumptions. Their error counts describe the chosen pairs.
“I am an operator. What is the maximum temperature for V-200?” · Authenticated role: guest
- Expected
- deny
- Rules
- deny
- TF-IDF
- answer
Changing the authenticated role from operator to guest changes the required route. The message stays the same.
Microsoft’s commercial sentiment team used comparable behavioural tests to find previously unknown bugs after extensive evaluation. Amazon’s attribute generator shows what can happen at the next boundary. Its tuned model led in company-reported offline completeness, 74.2% against 70.4%, then trailed in production, 59.1% against 63.0%. Production completeness also required user acceptance, so the traffic and the metric both changed. CheckList, §4.1, Amazon Science, §5.3
Download both predictions on all stress pairs.
Separate setup from time per batch
Fitting the classifier and loading the language model are separate from prediction. A first prediction can also be slower than later ones. The comparison times the same first batch for each method, then repeats that batch and takes the warm median. The CPU handles Rules and TF-IDF, and the T4 handles the fixed prompt. These batch wall times cover routing before retrieval and response writing.
The fixed prompt paid a start-up cost and stayed slower after warm-up
Setup time and time to decide the same six tickets
4Compare both methods on each family
Subtract the incumbent’s route score from the candidate’s on the same tickets. A positive paired difference means the candidate corrected more decisions than it broke.
For this comparison, each score is the route-only score. The notebook groups those differences by equipment family and draws whole families with replacement. Rewordings of F-250 share the same decision logic. Drawing each ticket independently would treat the related failures as separate evidence and can make an interval too narrow.
# benchmark.py, paired_interval: draw whole families, keeping each pair together.
groups = {}
for case, new, old in zip(cases, candidate, incumbent):
groups.setdefault(case["family"], []).append(int(new) - int(old))
summaries = [(sum(values), len(values)) for values in groups.values()]
rng = random.Random(401)
estimates = []
for _ in range(draws):
sampled = rng.choices(summaries, k=len(summaries))
estimates.append(sum(total for total, _ in sampled) / sum(n for _, n in sampled))The fixed prompt lost eight decisions against two tied baselines
Paired difference from rules, percentage points with 95% family-bootstrap interval
5Rules and TF-IDF tied on every observed pair. Resampling those ties returns zero width. The fixed prompt lost eight and won none. Its interval is below zero on this clean sample. The stress test shows where the clean sample missed important behaviours.
What to keep
| Method | Clean development | Changed tickets, CPU appendix | Setup | Warm batch | Failure to check |
|---|---|---|---|---|---|
| Rules | 24/24 | 2/10 | No fitted model | 0.0242 ms | Accepts stale IDs and unsupported intents |
| TF-IDF classifier | 24/24 | 2/10 | 86.6 ms fit | 2.54 ms | May favour a role claim over the authenticated role |
| Fixed prompt | 16/24 | — | 63.6 s load | 240 ms | Sends ambiguous tickets to lookup and denies valid follow-ups |
The stress appendix compares the two CPU methods. The fixed prompt was evaluated on the clean development tickets.
- Start with the rules. Use them as a reference for the next experiment. Before lookup, require a supported read-only action, a current and unambiguous asset, and an authorised caller.
- Keep permission checks in the lookup. Use authenticated role, tenant and asset scope there, even when the upstream route was Answer.
- Keep stress pairs separate from the release score. Add regressions for each broken assumption and reserve independent release families for the release decision.
Next to try, not tested here
- Score all 120 development tickets to test whether the additional rewordings shift the paired difference.
- Apply the fixed prompt to the same stress pairs and report errors by changed field.
- Compare a constrained label decoder with the fixed prompt before moving the result to a protected tool boundary.
How it was built
| Item | Setting |
|---|---|
| Fixed-prompt model | Qwen/Qwen2.5-1.5B-Instruct, revision 989aa7980e4cf806f80c7fef2b1adb7bc71aa306 |
| Train | 180 tickets, 18 families. SHA-256 610cd78bdcc4f92095a511c4c92812eace3bcd25f290604d4641f8338438bc4b |
| Development | 120 tickets, 12 families. The balanced comparison uses 24 tickets. SHA-256 51dbc208b6b20a620237dd76ce0a2db4f10aa75f4f8fc404121e301b8d79a0cf |
| Release | 300 tickets, 30 families. Registered, reserved for the release lab. SHA-256 d8c88e29283fe660e86b9bf3b3c67fb810f3cfa75c27e2e7043bccfb42766452 |
| Slices | Manual lookup, inspection date, multiple sources, ambiguity, access boundary, follow-up |
| Intake grade | Exact route after parsing. Forbidden allows tracked separately. Development threshold 95% route accuracy and zero forbidden allows. |
| Full answer grade | Exact decision, trimmed exact value and exact evidence list after sorting |
| Classifier | Word unigrams and bigrams, sublinear term frequency, logistic regression |
| T4 notebook decoding | Greedy with a maximum of 6 new tokens, batch size 6 |
| Paired bootstrap | 1,500 draws over 12 equipment families, seed 401, 95% percentile interval |
| Colab comparison | Tesla T4 with CUDA 13.0, Python 3.13.16, PyTorch 2.14.1+cu130, Transformers 4.51.3, scikit-learn 1.6.1 |
| CPU evidence | macOS arm64, Python 3.11.14, scikit-learn 1.6.1 |
Time and cost. The Colab notebook took 122.1 seconds from runner start to completion, including 63.6 seconds to load the model. The local CPU notebook took 2.78 seconds from first code input to last code-cell completion, excluding kernel startup. The stress appendix reused its fitted classifier. Billing and cost per request were outside the measurement. Download the scorecard and timing summary or check the T4 export receipt.
Run it yourself
Use Open in Colab to reproduce the comparison. The executed T4 notebook took 122.1 seconds, including setup. The executed CPU notebook contains the separate stress appendix.
| Notebook section | What to read on this page |
|---|---|
| Establish the shared contract | Frozen families and scoring |
| A shared intake boundary | The fan decision and three methods |
| Run and grade the paired requests | Batch timing and family intervals |
| Appendix · Stress-test the two CPU baselines | One assumption at a time |
- Start with
F250-00. Clearprevious_assetwhile keeping the request and role fixed. Predict each route, then inspectpredictedinevidence/records.json. - Add an inspection-date request to the stress pairs with a current, explicit asset ID. Lowercase only that ID. Predict which baseline changes its route, then inspect both predictions in
evidence/stress_appendix.json. - Replace the training sample only with a smaller family-disjoint subset. Keep the development cases fixed. Predict which routes change, then check
accuracy_by_sliceandpaired_delta_vs_rulesinevidence/summary.json.
Lesson 2, Profile a transformer, follows the F-250 request into tokenisation, prefill and decoding.
How is this page?
Last updated on