knowledge: remove the TRANSLATE LLM — deterministic query composition

His 23/10 weights-tightness audit found the TRANSLATE step composing
search queries from its own knowledge of the entities: 'Pedro Sánchez
2018 investiture President of the Government of Spain' for a term-start
question (the '2018' IS the answer, steered into retrieval from weights),
'Po, Adige, Tiber' proposed as entities for a question that named only
Italy. Measured over every logged TRANSLATE call of runs 22-23/10: 5/10
calls carried untraceable query terms, 6/10 untraceable entity terms.

Probed against real Wikipedia before deciding: queries composed
deterministically from question ∪ evidence put the decisive article at
top-1/2 of the search in 8 of 9 cases — the LLM's world knowledge was
never load-bearing; the search engine's own relevance was. So the step
becomes code (the law: LLMs translate, fixed code composes — and here
nothing is left to translate).

- NEW knowledge/queries.py: compose_queries() + proper_nouns/keywords
  (moved here, single source — the expert delegates). Laws: every query
  token traces to the question or an evidence row; deterministic; never
  empty. Top-N asks slice the FIRST N evidence members by source order
  (never dump all members); enumerations with one subject NE get the
  list-article shape ('List of rivers of Italy'); sentence-initial
  capitals are dropped when other NEs exist ('During', 'Ranked').
- DELETED TranslateSignature + the Predict + the stage map entry;
  the gather charges one LLM call less.
- expert.py: COMPOSE at the gather head; the context var (rendered
  only for the dead prompt) removed — evidence feeds the probe seeds,
  the composer and the guards directly.
- Tests: knowledge/tests/queries.py (12) — the sonde's cases as the
  contract, incl. the traceback law over the logged questions.
- DESIGN.md §4 + code/README honest map updated.

Suite 17/17. Live probe (real Wikipedia): rivers/Pedro/France/Po all
fetch the decisive article at top-1.
This commit is contained in:
2026-10-23 15:15:02 +02:00
parent 30d0a48f7a
commit dec1fccb53
7 changed files with 370 additions and 62 deletions
+19 -9
View File
@@ -118,8 +118,13 @@ One routed knowledge question = one internal pipeline run, bounded by budget:
```
question instantiate (already done by the machine)
│
▼ TRANSLATE (LLM): question + answer_type → retrieval focus:
│ keywords, entry entities, what shape of fact closes the gap
▼ COMPOSE (engine, 23/10 — the old TRANSLATE LLM removed): question ∪
│ evidence → queries + entity terms. Every token traces to the
│ question or an evidence row; the model's own knowledge of the
│ entities can no longer steer retrieval (it was putting the
│ ANSWER into queries). Top-N asks slice the first N evidence
│ members by source order; enumerations get the list-article
│ shape ('List of rivers of Italy').
▼ KG PROBE (engine): BFS from seeds → candidate edges + linked quotes
│ gap report: is the question's answer_type coverable from what's found?
│ YES → skip gather, go to SELECT
@@ -135,10 +140,14 @@ question instantiate (already done by the machine)
▼ return: top-k rows payload {quote, url, access_date, kg_corroboration}
```
LLM calls: TRANSLATE, EXTRACT-per-chunk (+ retries), and nothing else — the
probe, search, chunking, checking, merging, selecting are all engines. That is
the law compliance: the LLM translates; deterministic code decides what is
valid, what is dedupe, what is ranked.
LLM calls: EXTRACT-per-chunk (+ retries), SELECT TABLE (lists), VERIFY
COUNT, SKIM PROMOTE, and ANSWER — and nothing else. The query
composition, probe, search, chunking, checking, merging, selecting are
all engines. That is the law compliance: the LLM translates; deterministic
code decides what is valid, what is dedupe, what is ranked — and since
23/10 even the retrieval focus is code (the old TRANSLATE LLM became
`knowledge/queries.py`: every query token traces to question ∪ evidence,
so no model weight ever steers retrieval).
## 5. Context budget & chunking (the 16–32k constraint)
@@ -307,9 +316,10 @@ against the stored table text — the same string the parser produced — so the
check stays verbatim and deterministic. The wikitext raw form is kept in the
document artifact for audit.
**Budget law in the LIST path.** TRANSLATE + SELECT TABLE are the only LLM
calls (2 + retries); ingestion and aggregation are free. A 500-row table
costs the same LLM budget as a 5-row one — the cost of an enumeration is
**Budget law in the LIST path.** SELECT TABLE (and the optional VERIFY
COUNT) are the only LLM calls; ingestion and aggregation are free (the
query composition is engine since 23/10). A 500-row table costs the
same LLM budget as a 5-row one — the cost of an enumeration is
O(1) in the size of the list.
## 12. Answer-level verification — the CHECK step for answers (2026-10-19)