Tuning thresholds
Score a golden set once, sweep every cut-off, and pick one number per action from the table.
A threshold you guessed is a guess. A threshold you measured is a decision.
This page turns a labelled set into precision and recall at each cut-off. You score the set once. Then you read the number you need off a table.
Build the labelled set first. Golden sets covers the size, the sampling, and the file format. Fifty to two hundred real examples is enough to move a threshold with confidence.
The two numbers per action
Raising the threshold raises precision and lowers recall. Decide which error hurts more before you look at the table.
Step 1 — score the set once
Send the whole set through one capability in batches of 32 texts. Keep the probability for every
record. Do not threshold yet.
Results come back in input order. Batching covers that ordering guarantee and the 32-text limit.
Step 2 — sweep the cut-offs
Count true positives, false positives, and false negatives at each candidate threshold. Eight lines do it.
Step 3 — read the table
The run below is real. It scores 24 support messages against the statement
The customer needs help urgently., with 11 of them labelled urgent.
Three things to take from a table like this one.
- The
answerboolean cuts at 0.5. That cut is not the best one here. It let one polite billing question through at0.543. - A plateau is where you want to sit. Between 0.6 and 0.8 nothing changes, so a small drift costs nothing.
- Precision maxes out before recall falls. Above 0.9 the flag starts to miss real cases and buys nothing back.
A 24-record set makes a demonstration, not a decision. Perfect scores on a small set mean the set is too easy. Add the cases your system got wrong last month, then sweep again.
Pick two numbers, not one
One threshold splits the set in two. Two thresholds give you a band for a person to check.
The confirm band holds one record at 0.892. A human sees 4% of the traffic and the automation keeps full recall.
Widen the band until the error count reaches zero. Then narrow it until a person complains about the workload.
Confidence routing has the code for the three branches.
Sweep confidence too
classify and rate return confidence: 1 − H(scores) / ln(n), where H is Shannon entropy. It is a second axis.
Sweep it the same way. Count the errors above and below each confidence cut-off, at a fixed probability for
classify or at a fixed level for rate.
A near tie between two scores drops confidence toward 0. Escalate those cases whatever the winner scored.
Levels 1 and 2 differ by 0.001 here, and rate returns no probability at all. Only a confidence floor catches this case.
When to re-tune
- You changed the statement, the labels, or the hints. The numbers do not carry over.
- Your input mix changed: a new channel, a new language, longer texts.
- Your escalation rate moved in production. Monitoring tells you when.
Store the thresholds in config, not in code. Re-running the sweep must be a one-line change.