Repository navigation
Benchmarking
Checked against v0.6.1 (commit 3b06892) on October 19, 2026.
kestrel bench compares models, or prompt versions, on the Tier 2 evaluation prompt. It is the supported way to ask whether a candidate model or a prompt edit is better before you change a default. This page describes what the command does, what it measures, how the gold set works, and where the current behavior differs from what the specs and user docs say. It is for people who change models, prompts or kestrel/bench/.
The harness calls only the model you name. It never touches a live job board, ATS or SEC endpoint, and it never sends or submits anything for the user (hard rule 1 in CLAUDE.md). Each gold entry is a self-contained synthetic opportunity read from a local file.
kestrel bench --models qwen3:14b,qwen3:8b
kestrel bench --models qwen3:14b --prompt-version evaluate/v1,evaluate/v2The model names above are examples. Use names ollama list shows. The command is defined in kestrel/cli.py (bench, _bench) and the work is in kestrel/bench/harness.py. --models is required. --prompt-version is optional and takes a comma-separated list.
The design rule is that exactly one variable changes per comparison. validate_bench_args() raises BenchArgError if you pass more than one model and more than one prompt version. The error is raised before any model is called, and the CLI exits with code 2. Passing one model and one version, or one model alone, is a smoke run.
The second example above uses evaluate/v2, which does not exist in the repository today. Only evaluate/v1 and evaluate_consulting/v1 are registered (see Prompts and Context Budgets for how to add a version).
Bench runs the same prompt production runs: evaluate/v1 (P2) for the employment track and evaluate_consulting/v1 (P2C) for consulting (DEFAULT_PROMPT_VERSION). _track_of_version() routes an explicit --prompt-version to its own track by looking at the schema the prompt is registered with, and refuses anything that is not a Tier 2 evaluation prompt.
build_variants() returns one list of variants per track. When models vary, every model runs on both tracks, with the explicit version (if any) applied to its own track and the default on the other. When prompt versions vary, the single model runs each version on the track that version belongs to.
For each track that has variants, run_bench():
- Loads the gold set for the track (
load_goldset()). - Loads the operator's real profile for that track (
kestrel/pipeline/profile.py). - Runs every variant in turn. For each variant it copies the settings, replaces the model on the
tier2entry, creates a client, and sends all gold entries throughrun_prompt()with anasyncio.Semaphoreset tosettings.concurrency.tier2(default 2).
Each gold entry becomes a synthetic opportunity object with just the fields build_tier2_values() reads (_synthetic_opportunity()). The prompt is built exactly as in production, with three deliberate omissions: no few-shot block, no compensation corpus line, and no organization history. This keeps the run independent of the application database. It also means a bench number does not reflect the learning loop's few-shot effect.
Every call goes through the guard in kestrel/llm/guard.py, so a bad reply is a datapoint and never a crash: one repair, then quarantine. See Prompts and Context Budgets. The result of a parsed reply is post-processed with scoring.post_process(), the same code Tier 2 uses, so the verdict and displayed score being compared are the system's verdict and score, not the model's raw ones.
Only the model name is replaced. The tier2 backend is whatever your settings name. If Tier 2 points at a hosted backend, the same external-backend gate that applies everywhere applies here too (LLMClient.complete).
If a track has no gold set file or an empty one, that track is recorded in BenchReport.skipped_tracks, printed, and the other track still runs. A file with a malformed line raises GoldSetError and the command exits with code 2.
_summarize() builds one VariantReport per track, model and prompt version.
| Column in the table | Meaning |
|---|---|
n |
Gold entries run |
valid% |
Share of entries that parsed on the first attempt: the call succeeded and no repair was needed |
tok_in, tok_out
|
Mean prompt and completion tokens, summed across attempts |
latency_ms |
Mean latency per entry, summed across attempts |
items/min |
Entries divided by wall-clock minutes for the whole variant at the configured concurrency |
agree% |
Exact verdict match with the gold verdict, over entries that parsed |
MAE |
Mean absolute difference between the displayed score and the gold score, over parsed entries |
proj_500(min) |
500 divided by items/min
|
valid% is a first-attempt rate, so a model that always needs the repair call scores low even though every item eventually parses. Throughput depends on concurrency, so compare items/min only between runs with the same concurrency.tier2.
SPEC.md section 8.6 sets a target of above 98 percent first-attempt validity. That target is not enforced in code. The table only reports the rate.
Agreement and MAE are shown only when at least five entries parsed (_MIN_SAMPLE = 5, sufficient_for_agreement). Below that, render_table() prints insufficient (n=<parsed>) for agreement and insufficient for MAE. Validity, tokens and latency are always shown because they are computed over every entry. This is hard rule 6, described in Analytics Internals.
Before the table, _warn_unfit_models() calls check_model_fitness() and prints any warnings. A warning means the numbers are not comparable to a real Tier 2 candidate:
-
off_tier: the model is configured for another role (Tier 1 triage, document selection, trigger). Its job and prompt budget differ, so its structured-output rate says nothing about Tier 2 fitness. This exists because a triage model's 70 percent rate on a placeholder gold set was once recorded as a quality signal. -
under_provisioned: the model's effectivenum_ctxis below Tier 2's budget fromrequired_num_ctx("tier2")inkestrel/doctor.py, so long inputs are silently truncated. -
unknown_context: no explicitnum_ctx, or it could not be read. Ollama then applies a default far below what Tier 2 sends.
The context check uses the native Ollama client, because the OpenAI-compatible endpoint cannot report num_ctx. The warnings do not block the run. They are there so the operator cannot mistake an off-label number for a comparable one.
Two files ship in evals/ at the repository root, and byte-identical copies ship inside the package as kestrel/resources/evals/: goldset.employment.jsonl and goldset.consulting.jsonl. Each holds 20 synthetic entries with "placeholder": true. The employment set has 5 apply, 7 consider and 8 pass entries, and the consulting set has 5 pursue, 7 consider and 8 pass. An entry looks like this:
{
"track": "employment",
"title": "VP of Information Technology",
"org": "Acme Robotics",
"description_md": "Acme Robotics seeks a VP of IT to own infrastructure and security.",
"location": "Remote, US",
"comp_min": 210000,
"comp_max": 250000,
"remote_type": "remote",
"gold_verdict": "apply",
"gold_score": 4.8,
"placeholder": true
}This example is shortened and uses a fictional organization. GoldEntry in kestrel/bench/harness.py requires track, title, org, description_md, gold_verdict and gold_score, and ignores unknown keys. Consulting figures are day rates and employment figures are annual salary (_COMP_INTERVAL).
Agreement and MAE against the placeholder files are invented data. They say nothing about any operator's judgment. Before the table, _bench prints one answer key: line per track, "your labels" or "the shipped examples" (goldset_label()). After the table it prints a note whenever a track still uses the placeholder (_goldset_is_placeholder()). Validity, tokens and latency remain real.
kestrel goldset regen --track employment
kestrel goldset regen --track consultingregenerate_goldset() in kestrel/evals/goldset.py converts the operator's labels into gold entries. It uses labeled_examples() from the learning loop, so a label and a verdict override share one definition of "the operator's judgment" (see Learning Loop Internals). The gold verdict is the operator's verdict when given, otherwise the verdict the thresholds derive from the score. It writes goldset.<track>.regenerated.jsonl in the evals folder and never overwrites the placeholder. Fewer than five labels are still written, with a logged warning that the sample is thin.
paths.evals_dir() resolves to evals/ under the current working directory in a source checkout, and to an evals folder in the data directory in a frozen install. goldset_source() in kestrel/bench/harness.py picks the answer key in this order, and load_goldset() reads whatever it picks:
-
goldset.<track>.regenerated.jsonlin the evals folder (kindregenerated, your labels). -
goldset.<track>.jsonlin the evals folder (kindplaceholder). - The placeholder copy packaged under
kestrel/resources/evals/, read throughimportlib.resources(kindpackaged).
The packaged fallback applies only when no gold_dir is passed, so tests that pass one never see it. This is why kestrel-cli bench works in the installed app without any file in the data folder. In a source checkout step 2 depends on the working directory, so run it from the repository root; if the checkout has no evals/ folder, step 3 still finds a key.
These are the places where the code differs from what the specs or user docs lead a reader to expect.
- The Bench page does not run the harness.
kestrel/web/pages/bench.pystates why: a real run takes minutes per comparison and would block the shared event loop. Its Run button makes no model call. The table on the page is agreement between stored evaluations and the operator's labels, which is a different measurement from the CLI table.SPEC-INTERFACES.mddescribes the page as running the gold set. The page can still promote a model to a tier. - The same label-versus-evaluation agreement appears on the Models page (
model_summary()inkestrel/analytics/models_history.py). It says which model agrees with you. The bench CLI says which model agrees with the reference answers.bench_summary()on that page reports only the gold set state, because bench stores no results. - Bench persists nothing. The table is printed and discarded. Keep the output if you want to compare runs later.
-
SPEC-INTERFACES.mdshows--modelsas optional in the command table. The CLI requires it.
tests/test_bench.py covers argument validation, variant building, gold set loading (including the shipped files), and runs against stub clients for a good, wrong, flaky and bad model. tests/test_bench_guard.py covers the fitness warnings without calling a model. tests/test_goldset.py covers regeneration. No test calls a live model or an external service, in line with the fixture rule in CLAUDE.md.
Start here
Interfaces
Extending Kestrel
How it works
- Prompts and context budgets
- Document engine
- Learning loop internals
- Analytics internals
- Task queue and concurrency
- Database schema
Shipping and safety
- Packaging and releases
- Preflight and diagnostics
- Security and privacy model
- Outbound calls
- Benchmarking
Workarounds and Troubleshooting