Hive Intelligence

Documentation

/ Guides

Calibrating the semantic layer

0.9.0 docs, commit 05e2eb4PyPI packages at 0.9.0docs/guides/calibrating-the-semantic-layer.mdpublic repository on GitHub

The semantic layer is off unless a key is configured. With one, it asks a System One model how relevant each shareable candidate card is to the query and reorders the candidate union by those judgments. Whether that helps at all depends on one number, SYSTEMONE_RELEVANCE_FLOOR, and that number ships as a placeholder.

Do not claim the layer improves retrieval until you have measured it on your own questions. This guide is how to measure it, and what has and has not been measured so far.

What the floor does

semantic.reorder moves every candidate the model judged at or above the floor to the front, most relevant first, and leaves every other candidate behind them in the deterministic order. Nothing is added or dropped. A floor of 0 is a plain sort by the model's scores; a floor above every score changes nothing.

A floor set too high leaves a good model's ranking mostly unused. One set too low lets a weak model reshuffle an order that was working. Only candidates the model was allowed to see are judged, so when a union holds client cards or cards not attested shareable: true, a low floor also moves every judged card ahead of every card that was not judged. Calibration measures that effect too, because it scores the union exactly as serving built it, judged and unjudged cards alike.

This guide calibrates the relevance floor only. The sufficiency floor is not wired into any path yet (see what is wired today). The confidence floor is live wherever facet routing is, when FACET_TAXONOMY_PATH is set: it decides which facets widen the union. A run measures the relevance floor with routing as configured and does not calibrate the confidence floor, so leave that at its default unless you have measured it too.

Before you start

  • The model's key, as TYPESAFE_API_KEY, and the model id you mean to use as SYSTEMONE_MODEL. Recording is the only step that calls the model. Keep the key in .env or the environment, never in the repository.
  • The corpus settings, CONCEPTS_DIR, and CLIENTS_DIR whenever any row selects a client or expects a client card - serving would put that client's memory cards in the row's union either way. A CLIENTS_DIR that names no directory is refused when a row needs client context, and reported once on stderr otherwise, so the run never silently measures unions serving would not build.
  • A labelled set in the eval-set format: one JSON object per line with question and expected_card_ids, and optionally id, client, product and split. A row names its split as calibration or heldout; a row without one is assigned by a hash of its id, half and half unless --heldout-fraction says otherwise. Below 30 judged questions in either split the only verdict is insufficient_data, and more questions make the interval narrower.
  • A decision that the corpus may be sent. A calibration run sends the service exactly what serving with a key would send, through the same code: the query with any SYSTEMONE_QUERY_DENYLIST names redacted, and the title and description of each candidate card attested shareable: true. No card body, no client card, no card id, no caller identity. So whether to run it is the same data-sharing decision as turning the layer on for that corpus, made before the run and not during it.

Record once

python -m hiveserve.calibrate <qa-set> --records .data/calibration/records.jsonl

<qa-set> is a set name resolved under EVAL_DIR, or a path to a .jsonl file. For each question the run builds the candidate union exactly as find_concepts does and records one relevance judgment for it, sent the way serving sends it: every eligible candidate of the query in one request, or a few bounded ones for an unusually wide union (see one request per read). It counts the logical requests and their request-body bytes as they are sent and times each read; a request's own HTTP retries (429/529, timeout, transport error) are not counted separately, and their time is included in the read's wall time.

The configured model is measured as though it were already calibrated, because calibrating is how it earns that; your serving configuration is not changed.

Standard output is aggregates only: no question, card id, case id or client name. The records file holds case ids, gold and candidate card ids and the model's scores, never the question text. Card ids name client directories and topics, so the records file is as private as the corpus: keep it out of the repository and wherever the corpus itself is not allowed to go. The command enforces the first half: --records refuses, before any paid call, a destination inside a git work tree that git does not ignore (checked from the repository root and the working directory, with git in a pinned environment so no translated message, discovery ceiling or filesystem boundary can steer it) and a destination that is already a directory - the records are written to one file. It also refuses a destination whose path, as given, runs through something that exists and is not a directory - a regular file or a dangling symlink, even one a later .. steps back out of - since the records file could never be written there. --records needs git installed to make that proof; without git every destination is refused, so install git or omit --records. A destination whose repository metadata git cannot verify - a .git pointer that leads nowhere, or a repository git will not read - is refused as well: repair the pointer or repository, choose another destination, or omit --records.

Replay as often as you like

python -m hiveserve.calibrate --replay .data/calibration/records.jsonl

Replay needs no key and no corpus, and calls nothing. It reproduces the report exactly, including the bootstrap interval, which is seeded (--seed, default 20260923). A replay never writes a records file - --records is refused with --replay - so analyse from the records; do not record again to look at the same judgments differently.

Reading the report

Field What it tells you
model the model id that was measured
queries how many questions each split holds
rows_without_gold_skipped rows with no expected_card_ids, which cannot be scored; non-zero usually means a mislabelled set
judged_queries, degraded_queries, fallback_reasons how many reads the model actually judged; how many failed on a transient/permanent error or an open breaker; and why the rest kept the deterministic order
union_recall the share of questions whose answer is in the candidate union at all: the ceiling for any floor and any model
remote_calls_per_query logical requests per question, measured: one for relevance unless the union is unusually wide, plus one when facet routing is configured; a request's own HTTP retries are not counted separately
request_bytes_per_query bytes of logical request bodies sent per question, measured; a retry re-sends the same body and is not counted again
judge_wall_ms wall time of each read - facet routing when configured, building the candidate union, and the judgment - its HTTP retries included, measured on this run's network and machine
sweep MRR and hit@1/5/10 for each split, in the deterministic order and at every floor from 0.00 to 0.95
chosen_floor the floor with the best calibration MRR, or null when none beat the deterministic order
configured_floor the floor serving is configured with now
heldout the held-out split in the deterministic order, at the chosen floor and at the configured one, with the MRR difference and its 95% paired-bootstrap interval
verdict, verdict_note what the evidence supports, below

The floor is chosen on the calibration split and judged on the held-out split, never on the questions it was chosen on. A tie goes to the deterministic order, then to the highest floor: when the evidence cannot tell two choices apart, the one that changes serving least wins.

Acting on the verdict

Verdict Meaning What to do
calibrated_gain the chosen floor beat the deterministic order on held-out questions, with the whole interval above zero set SYSTEMONE_RELEVANCE_FLOOR to chosen_floor; for a model other than jev-1.13.0, also declare it in SYSTEMONE_CALIBRATED_MODELS
no_calibrated_gain no floor helped beyond noise leave the layer off for this corpus, and do not claim it helps
insufficient_data a split has fewer than 30 judged questions label more questions, then record again
degraded_trial a transient/permanent failure or an open breaker degraded at least one recorded read, so the trial is not a clean measurement fix the outage and record again; see degraded_queries and fallback_reasons for what was lost
no_judgments the model judged nothing read fallback_reasons: no attested cards, a failing key, or an open breaker

A gain holds for the corpus, the labelled questions and the model version it was measured on. Record again when any of them changes, and when the union changes shape: SYSTEMONE_KEYWORD_LIMIT, SYSTEMONE_MAX_CANDIDATES or FACET_TAXONOMY_PATH.

What has been measured, and what has not

Measured on 2026-09-23 on public data only. None of it is a measurement of Jev.

Requests per read: measured

The layer used to send one request per candidate, one after another; it now sends one per read. A recording fake counted the requests through find_concepts on a public corpus with 40-candidate and 60-candidate unions. It confirmed that batching reduced request counts and total request-body bytes (see one request per read). The stand-in run below also exercised batching over 1,109 queries.

Latency: not measured

No key was used, so the wall-time saving from batching is not established here. The vendor's comparison and its request limit do not measure this workload:

  • TypeSafe's parallel questions cookbook reports faster batched handling of 13 questions than sending them one after another, on jev-1.12. That workload is one large shared document; here the shared state is only the query, and each question carries its own card, so the saving here may be different.
  • Jev-1.13's documented limit is 1,200 requests a minute, which the vendor says may change. Batching reduces pressure on that limit; facet routing adds a request of its own.

Whether batching changes a model's answers: not measured

The service evaluates each question of a request independently, and the vendor reports no batching effect for many questions over one shared document. Hive's requests are a different shape, each card inside its own question, and whether a model answers them exactly as it did one card per request has not been measured. Calibration does not depend on it: it records the batched request, which is the one serving sends.

The floor on public data, with a stand-in model: measured, and not Jev

To exercise the whole calibration path on a real, non-fake judge, the public SciFact benchmark (Wadden et al., Fact or Fiction: Verifying Scientific Claims, EMNLP 2020; claims CC BY 4.0, abstracts ODC-By 1.0), as packaged by BEIR, was converted to 5,183 attested cards: the paper title as the title, the abstract's first sentence as the description, the abstract as the body. BEIR's own split gave 809 calibration and 300 held-out questions. The union was the default keyword arm, up to 40 candidates, with no facet taxonomy; SciFact has no related links.

A local cross-encoder, BAAI/bge-reranker-v2-m3 (revision 953dc6f), answered the engine's own batched requests on the local machine, so nothing left it, with the sigmoid of its raw score as each Noul. hiveserve.calibrate recorded and evaluated unchanged. The chosen floor of 0.00 improved held-out mean reciprocal rank (MRR) and hit rates over the deterministic order. The 95% interval for the MRR difference lay above zero, so the verdict for that model on that corpus was calibrated_gain. Three things follow, and they are the reason for the harness rather than a result about any model Hive would use:

  • The placeholder is not a safe default. At the placeholder floor of 0.50 the stand-in kept only a small part of the gain it made at its chosen floor. It ranked the relevant abstracts well, but scored many of those in the union below 0.5, leaving them in the deterministic order. A floor is a property of one model's scores on one corpus, and a number that suits one model can waste most of another's ranking.
  • Recall bounds everything. The answer was absent from the union for a meaningful share of held-out questions, so no floor and no model could reach those answers. That is the recall-versus-ranking gap alongside an existing RAG system describes.
  • The harness works end to end through serving's batched, privacy-projected path, with one request per question.

It says nothing about Jev. The stand-in's scores are not calibrated probabilities, its chosen floor means nothing for any other model, and scientific claim verification is not the domain Hive is built for. The stand-in's read timings included building the keyword union over all 5,183 cards plus the stand-in's local inference. Those timings say nothing about a remote service either.

The floor for Jev: not measured

That needs a key and labelled questions from the corpus Hive will serve. For a private corpus it is a separately authorized run: the key stays out of the repository, the records file stays with the corpus, and only the aggregate report leaves. Until that report says calibrated_gain, no claim about Jev's retrieval quality, on its own or against any other retrieval system, is supported.