100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
AI Guardrails & Safety Engineering
30 minadvanced

Rule-Based Guardrails and When They Beat Models

A classifier guardrail scoring a wire-transfer amount as "87% likely to be fraudulent" is a genuinely useful signal, and it is also the wrong tool for the actual requirement sitting right next to it: "never allow a transfer above $10,000 without a second human approval." That second requirement is not probabilistic at all — it is a fixed, known threshold with a fixed, known consequence, and running it through a classifier trained to output a confidence score adds latency, cost, and an unnecessary failure mode to a check that a single comparison operator handles perfectly and for free.

Rule-based guardrails are deterministic checks — regexes, allowlists, denylists, numeric thresholds, schema constraints — that produce the same output for the same input every single time, with zero training data and zero inference cost. The previous lesson built the case for classifiers precisely because rules cannot generalize past what they were explicitly written to catch; this lesson builds the opposite case, because the reflexive move toward the newer, fancier tool systematically undersells what a plain rule still does better, and getting this trade-off backwards is a common, expensive guardrail design mistake.

This lesson works through what rules are actually good at — exact-match policy boundaries, numeric limits, allowlists for anything with a fixed, enumerable set of safe values — the auditability advantage that comes from a rule being inspectable by a compliance reviewer with no ML background at all, and a decision framework for choosing between a rule and a classifier for a specific guardrail requirement before the next lesson combines both into one layered pipeline.

Analogy🏏Cricket
🏏 Think of it like cricket: the third umpire checking whether a delivery was a no-ball does not run a trained judgment model over the footage weighing dozens of contextual factors — the check is a single, deterministic measurement: did any part of the bowler's front foot land entirely behind the popping crease, yes or no. That rule produces the identical verdict on the identical footage every single time it's checked, with no training data, no confidence score, and no ambiguity about why the decision came out the way it did — any commentator, any fan, any player can look at the same frame and verify the same line themselves. Compare that to judging whether a fielder's throw at the stumps during a run-out was "deliberately" aimed to intimidate the batter, a judgment call the laws of cricket deliberately leave to an umpire's trained sense of the situation rather than to a hard measurable line, because no fixed rule could enumerate every version of that judgment in advance. The no-ball check works precisely because the underlying requirement is genuinely a fixed, known line — a hard rule is the right tool there, not an inferior substitute for a smarter one. The insight is that rule-based guardrails: when the actual requirement is a fixed, known boundary, a deterministic check is not a weaker version of a trained model, it is the exactly correct tool, faster, cheaper, and more inspectable than training a model to approximate a line that was never uncertain in the first place.
Lesson 10 of 35
0% complete