Evaluation lab · San Francisco · London · Zürich
Reinforced Labs Request a briefing
Research note

Guardrail thresholds under low base rates

A classifier that catches 95% of attacks with AUC 0.96 sounds production-ready. At a 0.1% attack rate, 99.5% of what it blocks is legitimate traffic. That isn't a defect of the model; it's arithmetic. The fix is to choose thresholds from costs, and to put deterministic controls where the costs are asymmetric.

A minimal model of a guardrail classifier#

Let a detector assign each request a score . Benign requests have and attacks have . This equal-variance binormal model is the standard textbook model of a detector, and its single parameter maps to a familiar summary:

We use , so , a strong classifier by any leaderboard standard. At threshold , and . Setting requires , which gives .

0.00.20.40.60.81.00.00.20.40.60.81.0False-positive rateTrue-positive rate (recall)
Figure 1. ROC curve of the modelled detector (AUC 0.961). Every operating point is a trade between the two error types; the curve alone doesn't tell you which point to use.

Precision collapses at low base rates#

The quantity operators experience is precision, the probability that a blocked request was really an attack. Bayes' rule gives it in terms of the attack base rate :

Attacks are rare in most enterprise traffic. Figure 2 shows precision at the 95%-recall operating point across base rates.

0.1%1%10%100%0.01%0.03%0.1%0.3%1%3%10%Attack base rate π (log)Precision of a block (log)
Figure 2. Precision at 95% recall. At precision is 0.48%: about 1 in 207 blocks is a real attack. Even at it is only 35%. Computed in guardrail_thresholds.py.

This is the base-rate fallacy familiar from medical screening and intrusion detection. It explains a pattern we see constantly: a guardrail that looked excellent on a balanced red-team set is switched to "log only" within a week of launch, because support tickets about wrongly blocked customers outnumber real attacks a hundred to one.

Choosing a threshold from costs#

The right operating point minimises expected cost per request. With the cost of a missed attack and the cost of wrongly blocking a legitimate request:

Differentiating, the optimum sits where the likelihood ratio of the score equals the cost-weighted odds:

for the binormal model. The threshold depends on base rate and cost ratio together, so a single threshold shared across deployments with different exposure is almost always wrong for most of them. We solved for numerically on a fine grid and tabulated the consequences per million requests:

πCfn:Cfpt*RecallFPRFalse blocks / 1MMissed attacks / 1MPrecision
0.1%10:13.0927.7%0.10%99572321.8%
0.1%100:12.1762.9%1.50%14,9703714.0%
0.1%1,000:11.2589.4%10.57%105,6351060.8%
0.1%10,000:10.3398.5%37.13%370,896150.3%
1.0%10:12.1763.0%1.51%14,9663,69629.6%
1.0%100:11.2589.5%10.64%105,3181,0497.8%
1.0%1,000:10.3398.5%37.26%368,8651482.6%
1.0%10,000:1-0.6099.9%72.44%717,168101.4%

Reading the table. At with a 100:1 cost ratio, a fairly severe miss cost for a support bot, the optimal threshold gives only 63% recall and still wrongly blocks 14,970 legitimate requests per million. To get recall near 99% you must accept blocking more than a third of all traffic. No threshold on this classifier makes a high-impact action safe at an acceptable false-positive cost.

π = 0.01%π = 0.1%π = 1%
0.00.51.01.5-1012345cost of never blockingThreshold tRelative expected cost
100 : 1

Axes: left→right threshold t (−1 to 5) · front→back attack base rate π (0.01% to 10%, log) · height relative expected cost. Drag to rotate.

Figure 3 (interactive). Relative expected cost (vertical, normalised to the cost of never blocking) over threshold t and attack base rate π from 0.01% to 10%, for the same detector (AUC 0.961). The green line traces the cost-optimal threshold for each base rate; green dots are the optimal operating points from the table above when the slider sits on 10, 100, 1,000 or 10,000. Drag to rotate. Without WebGL, the 2D slice at a 100:1 ratio is shown.

What this means for architecture#

The table argues for splitting the problem by consequence rather than tuning one classifier harder:

  • Low-impact paths (answering a question, summarising a document): use the classifier at a cost-optimal threshold, and act on flags softly by stripping suspicious spans, adding a warning or logging.
  • High-impact actions (payments, sending email externally, changing permissions): don't rely on a probabilistic detector. Use deterministic tool-call policy and provenance rules, whose false-positive rate on legitimate actions you control directly, and human approval above a limit. These controls don't suffer the base-rate problem because they don't classify text; they constrain actions.
  • Raise the effective base rate before classifying. Running the expensive detector only on content from untrusted channels, such as external email, web pages and uploaded files, increases within the screened stream by orders of magnitude, and precision with it.

Our note on correlated layers makes the complementary point: these deterministic controls also fail independently of the classifier, which is what makes layering worthwhile.

Measuring your own operating point#

  1. Estimate per channel from production samples labelled by humans. Don't use your red-team set, whose base rate you chose.
  2. Measure TPR on an adversarial corpus and FPR on a large benign sample from the same channel. FPR needs tens of thousands of benign cases for a tight interval near 0.1%; see sample sizes.
  3. Agree with the business owner, per action class.
  4. Compute per channel and action class, deploy in dry-run, and compare the observed block rate with the prediction before enforcing.

Do two-stage cascades rescue precision?#

A common response is to stack a second, more expensive detector (often an LLM judge) on whatever the first one flags. If the two stages were independent given the class, the cascade's rates would multiply:

Take two copies of our detector, each at 95% recall (). The cascade has 90.3% recall and an FPR of about 3.85%, and at its precision is

That is better than 0.5%, but it is still a stream of blocks of which 98 in 100 are mistakes, and that is the optimistic case. Two ML detectors looking at the same text are positively correlated, so the real FPR product is larger, by the same mechanism our correlated-layers simulation quantifies. Cascades are good for cost, since they run the expensive check only on flagged traffic. They don't escape the base rate.

Translating rates into an operations budget#

A threshold choice is also a staffing decision whenever flagged items go to human review. With daily volume , the review load is . From the table, at and a 100:1 cost ratio, roughly 15,599 alerts per million requests. A product doing 5 million requests a day would generate about 77,993 review items a day, of which about 3,146 are real. Few teams can staff that, which is the practical reason to keep classifiers on soft actions and put hard actions behind deterministic policy.

Limitations#

The equal-variance binormal model is an idealisation; real score distributions are skewed, and attacks are a mixture of easy and hard payloads, which typically makes the low-FPR region of the ROC worse than modelled. Costs are treated as constant per event. No real classifier was evaluated in this note. Code: methods.

Frequently asked questions#

Why does my prompt injection classifier have so many false positives?

Because attacks are rare. With a 0.1% attack rate, even a detector with 95% recall and 20% false-positive rate (AUC ≈ 0.96 in our model) has precision below 1%: almost every block is a legitimate request.

How should I set a guardrail threshold?

Minimise expected cost: C_fn·π·(1−TPR) + C_fp·(1−π)·FPR. The optimal threshold depends on both the attack base rate and the cost ratio, so it should differ by channel and by action class.

Sources#

  1. J. A. Hanley and B. J. McNeil. The meaning and use of the area under a receiver operating characteristic (ROC) curve. Radiology 143(1):29–36, 1982. doi.org
  2. S. Axelsson. The base-rate fallacy and the difficulty of intrusion detection. ACM Transactions on Information and System Security 3(3):186–205, 2000. doi.org

Know the number before you ship.

A 45-minute working session with an evaluation engineer. Bring one use case; leave with a threat model, a draft eval plan with sample sizes, and an honest read on where you stand.