research(knowledge): semantic KG retrieval + question-blind extraction (doc only)
His diagnosis after the local qwen run (no ambiguity flagged, 'Spain' after a long search, '15' as a term-start): the question-conditioned extractor filters rows BEFORE the audit can see them — alternative readings never enter the store. The redesign (his proposal + agreed refinements, OPEN QUESTIONS, and a verification plan) lives in knowledge/RESEARCH-semantic-kg.md. Research branch by design: parkable — if it stalls we continue from main (other experts / pending backtracking). No code yet.
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
# RESEARCH: semantic KG retrieval + question-blind extraction
|
||||
|
||||
Status: RESEARCH BRANCH (research/semantic-kg). Parkable by design — if
|
||||
this direction stalls or gets us lost, we shelve it and continue from
|
||||
main with the other experts or the pending backtracking design.
|
||||
|
||||
Opened: 2026-10-22, after his local qwen run.
|
||||
|
||||
## The trigger (his report)
|
||||
|
||||
Local run on "Who was the President before Pedro Sanchez?":
|
||||
- INIT fine (he LIKES the 3-subquestion shape: presidency-of-what /
|
||||
term-start / predecessor — the date subq may be unnecessary but is
|
||||
not wrong).
|
||||
- The auditor flagged NO ambiguity. The KG came back "Spain" after a
|
||||
long search — the PSOE/Socialist International readings never
|
||||
surfaced.
|
||||
- The term-start question answered "15" — not a date — making the
|
||||
predecessor question unclear downstream.
|
||||
|
||||
## Root cause (his diagnosis, agreed)
|
||||
|
||||
The EXTRACTOR is question-conditioned: it sees "extract facts that help
|
||||
answer the question". That filter acts BEFORE the ablation audit can
|
||||
see anything: the KG only holds the reading the question preferred.
|
||||
The alternative readings never entered the store — no audit can recover
|
||||
signal that was never ingested. Same class as the run-L interleaved
|
||||
quotes, but one level deeper: not "the mask ate too much", but "the
|
||||
rows were never extracted".
|
||||
|
||||
## The redesign (his proposal)
|
||||
|
||||
1. QUESTION-BLIND EXTRACTION. The extractor must NOT know the question.
|
||||
It knows only the ENTITIES for which it seeks relations/facts.
|
||||
Per extracted chunk (or per document end), we check whether the
|
||||
extracted relations can contain the answer.
|
||||
|
||||
2. SEMANTIC RETRIEVAL — not string matching of relations, not an LLM.
|
||||
Embedding distance of facts against the question: a semantic search
|
||||
of the question in the KG. (kg probe becomes: nearest edges by
|
||||
embedding, threshold τ.)
|
||||
|
||||
3. STOP_TABLE MOVES TO SKIM. The extractor's side-duty (deciding a
|
||||
table cannot contribute) moves to the skim pass, where it needs an
|
||||
LLM call: for long tables, given header + first rows, decide whether
|
||||
the table plausibly holds useful info. Fires BEFORE any extraction
|
||||
spend, once per table — instead of burning one extract call to
|
||||
discover the same thing.
|
||||
|
||||
## Agreed refinements (this session, not yet his-blessed)
|
||||
|
||||
- Embedding distance is the CHEAP GATE; the JUDGE (AnswerFromKG) stays
|
||||
LLM, called ONCE per question when retrieval says so — not per chunk
|
||||
as today. Semantic hit ≠ answer: "PM since 2018" sits near "When did
|
||||
his term begin?" but the 2018 must be READ from the fact, not from
|
||||
the distance. (LLMs propose/judge; retrieval is deterministic math.)
|
||||
- Keyword probe stays as OFFLINE FALLBACK (gateways do go down).
|
||||
- Extraction per (document, entities) is CACHEABLE across questions:
|
||||
the KG fattens with neutral facts and later questions on the same
|
||||
entities get cheap runs. Aligns with his roadmap (article cache +
|
||||
index). The fat KG is the point — active, reusable memory.
|
||||
|
||||
## Open questions (park if we can't resolve them)
|
||||
|
||||
- Early exit vs completeness: neutral extraction processes more per
|
||||
chunk; ambiguity usually declares in the intro paragraph, but a
|
||||
late-chunk reading can still be cut by an early exit. Options: keep
|
||||
early exit (start here), exit only after the first full document,
|
||||
or audit-directed fetching.
|
||||
- Volume: per-entity extraction ingests much more (birth, marriage,
|
||||
career...). Needs a per-chunk fact cap. Ingest growth is accepted
|
||||
(the fat KG is the point) but must stay bounded per run.
|
||||
- Embedding model: configurable endpoint (local ollama, e.g. bge-m3);
|
||||
vectors stored in the KG keyed by (model, text hash) so switching
|
||||
models invalidates cleanly. At hundreds of edges, numpy brute force
|
||||
suffices — no vector DB.
|
||||
- DATE answer type: "term-start" answered "15" and the dependent
|
||||
question became unclear. Proposal: AnswerType.DATE + judge desc +
|
||||
a deterministic looks-like-a-date check that rebuts bare numbers.
|
||||
SMALL and orthogonal — could ship to main independently of this
|
||||
research branch (asked; awaiting his call).
|
||||
|
||||
## Verification plan (before this branch is mergeable)
|
||||
|
||||
1. Unit: embedding client + cosine ranking over a fixture KG; τ chosen
|
||||
so the Pedro fixtures rank the three office readings above the
|
||||
career noise.
|
||||
2. Integration (scripted extractor, no network): the run-L paragraph
|
||||
yields ALL THREE readings under question-blind extraction; the audit
|
||||
flags 2 alternatives (the fix the dst-first mask never fully got).
|
||||
3. Live E2E (glm + his qwen): the Pedro question flags the ambiguity;
|
||||
the rivers question stays green (regression guard); judge calls per
|
||||
question drop to 1 (the "searched a lot" cost).
|
||||
4. His log (pending): confirm which rung died in the local run —
|
||||
extractor filtered the rows / probe never surfaced them / judge saw
|
||||
them and was strict. The redesign fixes the first two BY DESIGN;
|
||||
the third (strictness with "as President") lives in the judge by
|
||||
agreement.
|
||||
|
||||
## What stays untouched
|
||||
|
||||
- The mask/ablation audit (dst-first law, run-L fix) — it gains signal.
|
||||
- Anonymization before INIT (PR-16/17) — orthogonal.
|
||||
- The branching design — still pending discussion; this branch may
|
||||
feed it better questions, but does not implement it.
|
||||
Reference in New Issue
Block a user