Skip to content

Benchmarking

Claude edited this page Nov 12, 2026 · 4 revisions

Checked against v0.7.6 on November 13, 2026.

Benchmarking

Kestrel compares models, or prompt versions, on the same labeled roles through one harness, kestrel/bench/harness.py, with two entrances. The Model check page (route /bench, reached from Models) queues the comparison as a background task and recommends a change in plain words. kestrel bench runs the Tier 2 part of it from a terminal and prints a table. This page describes both, what they measure, how the gold set (the answer key) works, and where the two differ. It is for people who change models, prompts or kestrel/bench/.

The harness calls only the models it is asked to test. 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 opportunity read from a local file. Related pages: Prompts and context budgets, Learning loop internals, Task queue and concurrency, Adding a page.

The Model check page

The page was the Bench page until its Run button, which made no model call, was replaced by a task that does (kestrel/bench/check.py states why: a feature may not need the command line, and a real comparison must not block the web loop). The route kept its name.

Piece Where
Route module kestrel/web/pages/bench.py (GET /bench)
Template and partials bench.html, partials/bench_panel.html, bench_result.html, bench_advanced.html, bench_table.html
View helpers kestrel/web/bench_view.py
The check itself kestrel/bench/check.py (queue_check, run_check, drain_checks, status, cancel_check)
Page script kestrel/web/static/js/bench.js, which defines the page bench. Its only start-up is asking the shared picker script model_combo.js to scan the page (keCombo.scan); the run, the progress poll and Cancel are htmx. See Adding a page.

Models has a Check my models button and, after a finished check, a banner that links back here. The page is not a navigation entry.

What a check does

Check my models posts to POST /bench/start, which calls queue_check and inserts one task row of type bench (max_attempts 2). Rules at queue time:

  • One check at a time (already_running).
  • At least five rated roles (MIN_RATINGS, hard rule 6). Below that the check is refused with "Rate at least 5 roles first".
  • Anything that would be sent to an online model must pass the same gates as everywhere else: a connected provider with a saved key, the person's approval of the current disclosure, the destination approval (online_approval) and a ticked confirmation. An untouched check refuses outright when the step's own model runs online. In confidential mode the current employer is replaced with a code before an online candidate is sent, or the send is held if no employer is chosen (_RedactingClient, plan_hosted_send).

The worker runs it. _worker_loop in kestrel/web/app.py calls drain_checks after every tier has drained, never beside them, so a check cannot swap models underneath scoring. drain_checks leases a bench task, renews the lease while it runs, and calls run_check.

The steps, in tier order (STEP_TIER):

Step Tier Question asked Prompt
Quick screen (quick_screen) tier1 Keep or skip, against the gold verdict (pass is skip, anything else keep). A reply under 0.6 confidence counts as keep, and a quarantined reply counts as keep (hard rule 4). triage/v2, triage_consulting/v2
Rating (rating) tier2 The verdict. This runs run_bench, the same code kestrel bench runs, with the step's tier standing in for tier2. evaluate/v2, evaluate_consulting/v2
Deeper read (deeper_read) tier3 The same as Rating, on the deep model. Optional. the same

Quick screen and Rating run by default. For each step the candidates are the model in use first, then up to MAX_ALTERNATIVES (3) other installed local models (embedding models are skipped), then any online models the person ticked Include online models for.

Progress, cancel and resume

Every finished (step, model) result is written into the task payload (results, progress) before the next model starts, so a re-leased task skips what is done (hard rule 5). The card polls GET /bench/panel every two seconds while a check is live. Cancel (POST /bench/cancel) marks the row cancelled, and the run stops before its next model. The final write completes the task only if it is still live (status IN (pending, leased)) and stores the finished check in the same transaction, so a cancel can never be overwritten. A quit stops the run and defers the task with its results kept.

A finished check is kept in the setting row bench.checks (the newest 10, HISTORY_KEEP). The CLI keeps nothing; the page does. JSON routes stay for tests and scripts: POST /bench/check, GET /bench/check/status, POST /bench/check/cancel.

The recommendation

recommend_step compares a step only with itself, in points per 100 roles of agreement with the answer key. Quick screen (keep or skip) and Rating (verdict) are never put side by side. With fewer than five roles in the answer key (n < MIN_RATINGS) the step reads "Too few roles in the answer key". A local model is preferred: an online one is recommended only when it beats the best local gain by ONLINE_MARGIN_POINTS (5) or more, and the best local option is always named. A change is recommended when the gain rounds to at least one point. build_summary turns the step verdicts into the line the card leads with.

Switching is POST /bench/apply (a local model becomes that step's override; an online one is saved as the step's hosted override and needs the tick) and POST /bench/undo. Advanced has a one-step, one-model form (POST /bench/run), Use a model for a step (POST /bench/promote), and Kestrel's instructions to the AI. The option "The version before it" is disabled while PREVIOUS_RUNS_SUPPORTED in bench.py is False, because the queue does not yet carry a previous prompt version through to the harness; every check uses the current instructions.

The answer key

The check scores models against the person's own rated roles once they press Use my ratings as the answer key (POST /bench/answer-key, build_answer_key, the in-app form of kestrel goldset regen). A track with fewer than five ratings keeps the shipped examples. Otherwise the check uses the shipped examples, and the page says so ("not your ratings"). See The gold set.

Inside Advanced, "Earlier comparison from your stored answers" is a third and different measurement (_comparison_rows in bench.py): exact-verdict agreement between stored evaluations and the person's labels, grouped by tier, model, prompt version and track. It is the same kind of figure the Models page shows (model_summary() in kestrel/analytics/models_history.py). It says which model has agreed with the person on roles it actually scored; the harness says which model agrees with the answer key now. A group with fewer than five pairs is labeled "too few, under 5". Each count is of roles, not copies: a role posted on several boards counts once.

Running the harness from the command line

kestrel bench --models qwen3:14b,qwen3:8b
kestrel bench --models qwen3:14b --prompt-version evaluate/v1,evaluate/v2

The model names 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 (SPEC-INTERFACES says so too). --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. One model and one version, or one model alone, is a smoke run.

Both evaluate/v1 and evaluate/v2 are registered, so the second example is a real comparison on the employment track. evaluate_consulting/v1 is not kept (P2C v2 added a required field the older output lacks), so a consulting prompt-version comparison has only one version today. See Prompts and context budgets for how versions are registered in SCHEMA_BY_VERSION.

Which prompt each track uses

Bench runs the prompt production runs: evaluate/v2 for the employment track and evaluate_consulting/v2 for consulting (DEFAULT_PROMPT_VERSION, which matches _VERSION in kestrel/pipeline/tier2.py). _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.

What a run does

For each track that has variants, run_bench():

  1. Loads the gold set for the track (load_goldset()).
  2. Loads the operator's real profile for that track (kestrel/pipeline/profile.py).
  3. Runs every variant in turn. For each variant it copies the settings, replaces the model on the tier2 entry, creates a client, and sends all gold entries through run_prompt() with an asyncio.Semaphore set to settings.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.

What is measured

_summarize() builds one VariantReport per track, model and prompt version. The CLI table:

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.

The Model check page reports a smaller set per model and step: agreement with the answer key (over every role in it, as StepResult.agreement), mean latency, first-attempt validity and the number quarantined.

Sample-size rule

In the CLI table, 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. The Model check page applies the same rule with MIN_RATINGS. This is hard rule 6, described in Analytics internals.

Fitness warnings

Before the CLI 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 effective num_ctx is below Tier 2's budget from required_num_ctx("tier2") in kestrel/doctor.py, so long inputs are silently truncated.
  • unknown_context: no explicit num_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. The Model check page does not print them; it tests the models that fit the computer.

The gold set

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, the CLI 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. The Model check page states the same thing in words: answer_key_info() returns "N of your own rated roles" or "N shipped example roles, not your ratings".

Regenerating from your own labels

kestrel goldset regen --track employment
kestrel goldset regen --track consulting

The Model check page does the same for both tracks with Use my ratings as the answer key. regenerate_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. The command writes fewer than five labels with a logged warning that the sample is thin; the page keeps the shipped examples for a track with fewer than five.

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:

  1. goldset.<track>.regenerated.jsonl in the evals folder (kind regenerated, your labels).
  2. goldset.<track>.jsonl in the evals folder (kind placeholder).
  3. The placeholder copy packaged under kestrel/resources/evals/, read through importlib.resources (kind packaged).

The packaged fallback applies only when no gold_dir is passed, so tests that pass one never see it. This is why the check 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 kestrel bench from the repository root; if the checkout has no evals/ folder, step 3 still finds a key.

Where the measurements differ

These are the places a reader can confuse one number for another.

  1. The CLI table and the Model check page both run the harness, but they report different things. The CLI reports validity, tokens, latency and agreement for the Tier 2 prompt only. The page reports agreement per step against the answer key and a recommendation. Rating on the page and agree% on the CLI use the same code and key but not the same denominator: the page divides by every role in the key (a reply that never parsed is a miss, _evaluation_step), the CLI by the entries that parsed. Compare numbers within one entrance.
  2. The CLI persists nothing. The table is printed and discarded; keep the output if you want to compare runs later. The page persists progress in the task payload while a check runs and the finished check in the bench.checks setting row (the newest 10).
  3. "Earlier comparison from your stored answers" on the page and the figures on the Models page compare stored evaluations with the person's labels. They say which model has agreed with the person on roles it scored. Neither runs a model. bench_summary() on the Models page reports only the state of the gold sets.
  4. Model check tests Quick screen on triage/v2 and triage_consulting/v2, which the CLI never runs.

Tests

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. For Model check, tests/test_model_check.py covers the queued, resumable task with a scripted runner, tests/test_model_check_online_gates.py the gates an online candidate passes, and tests/test_model_check_screen.py the page and every in-place action. tests/test_models_browser.py includes the page's mount, unmount and mount-again check; the page holds no listeners of its own, so it reads KUI.page._stats() directly instead of calling assert_page_remounts_clean (see Adding a page). tests/model_check_seed.py seeds ratings and a finished check for the page tests. No test calls a live model or an external service, in line with the fixture rule in CLAUDE.md.

Clone this wiki locally