324-item eval set split: 180 positive (120 shaped + 48 PII + 12 prose) vs 144 negative (6 kinds x 24 trap items)

A local LLM is a different machine depending on what question you ask it. Ask it to decide a whole request and it hedges. Ask it to decide a single step with a pinned type and it answers. That gap is the reason my router has a 324-item eval set and a tree of rules in front of the LLM.

local-step-router is the companion code for a book I wrote on routing agent work between a local Qwen model on an RTX 4070 and Claude Code in the cloud. The number that started the whole thing: 96 of 100 of my daily requests had to go to the frontier model. A number I did not enjoy when I first printed it. Split the same work into single steps and about half of 200 could stay local. The rest of this post is what is inside the repo, not inside the book: the 324-item eval set and the decision tree that reads it.

Why 324 items instead of a benchmark run

Public LLM benchmarks run on tasks. local-step-router is not trying to grade a model's coding ability. It has to answer a different question at the gate before a request reaches the frontier orchestrator: does this text contain a secret, named personal data, or confidential prose that should not leave the machine as-is? That question has a shape, and the eval set has to match that shape.

The 324 items are split 180 positive and 144 negative. Both halves are generated from data/build_gate_set.py with a fixed seed, so you can rebuild them on your machine and nothing is taken from my real logs.

The positives break down into three groups the gate has to stop for different reasons:

  • Shaped secrets (120 items, 10 kinds). ghp_ tokens, AWS access keys, Slack bot tokens, Stripe sk_live_ keys, OpenAI sk-proj- keys, OpenSSH private keys, JWTs, Postgres URLs with passwords, Luhn-valid card numbers, My Number IDs with the check digit. These look like themselves. A regex should catch them.
  • Personal data (48 items, 4 kinds). Name + mobile + email, name + Japanese address, name + date of birth, name + bank account. These do not carry a label that says "secret." Regex alone misses most of them.
  • Prose passwords (12 items). Sentences like "the initial VPN password is xyz." The password itself is random, but the carrier phrase is what makes it stop-worthy.

The negatives are not boring. They are the stuff a naive gate mistakes for a hit.

  • topic_only: "How should I store API keys safely?" (no secret, just a topic)
  • doc_example: AKIAIOSFODNN7EXAMPLE, 4111 1111 1111 1111, user@example.com (exact strings from official docs)
  • masked: sk-proj-****, ghp_xxxxxxxxxxxxxxxx, ${DB_PASSWORD}, <YOUR_API_KEY>
  • hash_uuid: git SHAs, UUIDs, sha256:... digests
  • number_not_pii: order numbers, JAN codes, company main-line phone numbers
  • public_info: public API endpoints, published corporate addresses, public phone services

Each of those six kinds appears 24 times. If you only look at the positives, your gate is a sieve. The negatives are where the thresholds get set and the false-alarm rate gets paid.

The decision tree before the judge runs

The repo draws a line that most "LLM as a judge" writeups blur: a rules-first decision tree sits in front of the probability judge, and most steps never reach the judge at all.

steprouter/router.py is 60 lines. It holds a list of Rule objects, walks them top to bottom, and returns the first match. A rule is a dict like {"tool": "WebFetch"} -> local or {"tool": ["Agent", "Task"]} -> frontier. The probability function is there, but it is None by default. From the example examples/routing.yaml:

rules: - match: {tool: WebFetch} route: local - match: {tool: [Agent, Task]} route: frontier - match: {kind: commit_message} route: frontier # frontier until a probability judge is added  probability: null # off until measured with the same judge model default_route: frontier 

The order is the point. WebFetch steps settle at the first rule. Agent and Task steps settle at the second. Commit-message steps settle at the third. A local judge could plausibly handle them, but the config opts out until the judge is measured on that specific step type. Everything else falls through to the default. The probability function never fires in this config. A judge model that costs 400 to 600 ms per call is not consulted when a 20 ns dict lookup already has the answer.

This is the piece a lot of "route with an LLM" posts skip. A one-line rule beat a 9B judge model on the single prompt that returns its probability, on the same eval set, consistently. The judge's probability is not useless; it is wasted on decisions a rule can make. I spent a weekend tuning the judge before I accepted the dict lookup was going to win.

Two separate structures, not one

The entrance gate in steprouter/gate.py is a different beast from the step router. It runs on the full request text before the frontier orchestrator sees it. The 324-item eval set is for the gate, not the router.

The gate stacks three layers:

  1. Regex: gitleaks for standard credential shapes, plus Japan-specific PII rules in steprouter/jp_rules.py (mobile numbers, bank account formats, My Number with checksum, Luhn-valid cards, "password is..." sentences).
  2. Local judge: if regex says nothing, steprouter/judge.py reads a one-character answer from Ollama's native API using logprobs: true, top_logprobs: 20, and returns the probability of the "Y" candidate.
  3. Threshold: compare the probability to a line drawn from your own labeled data, not 0.5. steprouter/threshold.py is a CLI that computes AUROC and a 5-fold CV with the "lowest P among positives × margin" rule. The default in the example config is 0.0071, a number that comes from the author's labels and has no meaning on yours.

If a request trips the gate, it has three exits based on the hit kind: redact the matched span and hand it to the frontier, keep the whole task local (for one-shot tasks), or return it to a human. The router at the step level is a separate structure that only starts after this gate passes.

Keeping them separate matters because they fail differently. The gate's cost of a miss is a leaked secret. The router's cost of a miss is a slightly worse answer or a slightly bigger bill. One wants very high recall; the other wants a cheap default and a short rule table.

What the eval set does not cover

Three things worth naming so the 324-item number is not misread:

  • The values are synthetic. Real ghp_ tokens have random payloads but real prefixes; build_gate_set.py keeps the prefix and randomizes the rest. Real secrets committed by real teammates in real diffs look different enough that the regex rules sometimes stop them and sometimes do not. The book covers the gap; the repo does not.
  • The language is Japanese + English templates. The PII rules are Japan-specific. If your gate has to stop a US Social Security Number or a UK NIN, you write those rules yourself in the same shape as jp_rules.py.
  • The threshold is one person's. 0.0071 comes from my qwen3.5:4b, one prompt version, and one definition of "confidential." The threshold CLI is there so you draw yours; the number on the shelf is not yours.

If you ignore all three and copy-paste the config, you get a gate tuned for a different machine. The LP ships numbers so you can compare, not so you can inherit.

What this routing is good at

The shape it is built for is a Claude Code harness driving a lot of steps on an RTX 4070. For that shape, the measured outcomes in the book are: 96% of whole requests had to go to the frontier model, half of the 200 single steps I counted could stay local, and the threshold worksheet cut missed secrets from 20 to 2 on my definition. The llama.cpp cpu-moe flag that gets Qwen3-35B-A3B to 34.6 tok/s on a 4070 is covered in a separate post; it is the throughput prerequisite that makes "local for half the steps" an actual option and not a theoretical one.

The hour-of-day cost crossover is in this breakeven analysis if the question is "which plan at which daily volume." The structural answer has three parts: rules in the front, a probability judge behind them, a gate at the very entrance. That is what local-step-router encodes. Clone it, rebuild the eval set with data/build_gate_set.py, point the threshold CLI at your own labeled examples, and the numbers that come out will be yours.

The full method is in the book: counting requests and steps, running the regex gate, drawing your own threshold, designing the typed return value a local worker sends back. Local LLM or Claude Code? (Kindle Unlimited, $4.99). The companion code (MIT) is here.