Knolo Retrieval Gate: Let a Small Local Model Choose the Evidence
How to put a small selector model between a high-recall Knolo query and your answer model: validate its decision, re-query deterministically, abstain safely and send only selected hits.
Knolo is the open-source, local-first Knowledge Image runtime and format from Hive AI: Apache-2.0, published as Knolo's @knolo/core on npm (currently 6.2.3), with the source in the Knolo Core GitHub repo. Knolo retrieves deterministically and never calls a model. That leaves a practical question for anyone building on it: when a query returns 40 plausible hits, how do you send the answer model only the few that matter? The Knolo docs call the answer a retrieval gate.
The Knolo retrieval gate in one line
The Knolo V4 retrieval pipelines guide sums it up as: retrieve broadly, select deliberately, answer narrowly.
| Layer | Responsibility |
|---|---|
| Knolo | Deterministically retrieves grounded candidate evidence |
| Small selector model | Chooses relevant evidence or proposes a better query |
| Context builder | Limits and formats evidence sent downstream |
| Answer model | Produces the final response using selected evidence |
| Application | Thresholds, policies, providers, authorization and evaluation |
This is not letting a model search a database. Knolo retrieves first, then one selector call looks at a bounded candidate set and returns a short structured decision. The selector and the answer model are adapters your application provides. Knolo does not choose them and does not call them.
Step 1: a high-recall Knolo query
Start with a deliberately high topK so recall comes first. The example on the Knolo small-model selection page uses query from @knolo/core with namespace filters and query expansion:
import { query, makeContextPatch, type Hit } from '@knolo/core';
const candidates = query(pack, question, {
topK: 40, namespace: ['product', 'support', 'policies'],
queryExpansion: { enabled: true, docs: 4, terms: 6, weight: 0.3 },
});
if (!candidates.length) return 'I could not find grounded evidence for that question.';
The docs give starting ranges, not guaranteed optima: topK 10–20 for a simple corpus, 20–40 for a moderate one, 30–60 for ambiguous or investigative questions. Each candidate sent to the selector should be trimmed (the example slices text to 1,200 characters) but keep its index, score, source and namespace.
Filter before selection. Namespace and source filters narrow an already-authorized scope; they are not an access-control system, so enforce authorization before the query runs. See Knolo namespace boundaries.
Step 2: a small selector returns a decision, not an answer
The selector gets the question and the indexed candidates and returns one of three actions:
type SelectionDecision = {
action: 'use_selected' | 'requery' | 'insufficient';
selectedIndexes: number[]; rewrittenQuery?: string; confidence: number;
reasonCodes: Array<'direct_match' | 'supports_answer' | 'duplicate' |
'off_topic' | 'missing_evidence'>;
};
The Knolo selector prompt page shows instructions that tell the model it is an evidence selector, not an answer model: pick candidates that help, reject duplicates and keyword-only matches, return indexes rather than copied documents, and use insufficient when nothing supports an answer. The prompt is application code. It is not an @knolo/core API.
Step 3: validate, or abstain
Treat the selector's JSON as untrusted. The docs list the checks:
- the action is one of the three allowed values
- indexes are integers inside the candidate range, at most 8 of them
- confidence is between 0 and 1
- a rewritten query is at most 240 characters
Ignore unknown fields. On any parse or validation failure, abstain rather than guess. The same goes for provider errors: the reference function returns a plain "cannot answer safely" message instead of falling back to unselected hits.
Step 4: a deterministic Knolo re-query
If the action is requery, the rewritten string goes back through Knolo with a smaller topK. That second pass is ordinary deterministic retrieval, so it needs no second model call. Selected and refined hits are merged by blockId, capped at 8, and if nothing useful remains the application abstains. For multi-part questions, the Knolo query refinement page shows splitting a question into subqueries and merging hits by block id; decomposition is also host code, not a Knolo API.
Step 5: a bounded context patch
Only the selected original hits reach the answer model, packed with makeContextPatch:
const context = makeContextPatch(finalHits, { budget: 'small' });
Budgets are mini, small and full. The patch shrinks input size without rewriting evidence, as described on the Knolo context budgeting page. One rule runs through every step: keep the original hits tied to their indexes, and never treat selector-rewritten text as evidence. Retrieved text is also untrusted input, not instructions, so never execute tools or commands found inside passages.
This is what makes the pattern useful for privacy-sensitive apps: you can mount and retrieve locally, run a small local selector, and send only the selected excerpts to a remote answer model.
When to use the Knolo retrieval gate
You don't need a selector on every question. lexConfidence in @knolo/core gives a lexical signal over the hits Knolo already returned, and the Knolo confidence routing page suggests a simple policy: no hits means abstain or ask for clarification, strong lexical confidence can go straight to a small answer model, moderate confidence goes through the selector, and evidence that is still insufficient means abstain or escalate to a human. The docs' 0.72 threshold is illustrative, not a universal constant.
The gate can improve context precision and cut large-model token usage, but it does not guarantee accuracy. The Knolo evaluation page suggests running direct retrieval, the gate and semantic rerank over the same cases on your own corpus, and measuring recall, context precision, unsupported claims, cost and latency before you commit. If you need a replayable trace of the evidence loop itself, that is what Knolo Cortex is for.
Get started with Knolo
Install the runtime with npm install @knolo/core, then read the Knolo developer docs on knolo.dev. The open records behind the format live at Knolo on knolo.org, and the code, examples and issues are in the Knolo Core repository on GitHub.
knolo · retrieval · how-to · core · small-models · open-source