knowledge: subject guard + boundary matching + answer log (run H fixes)
Run H (his E2E of run G's fixes) answered Q1 'three longest rivers of
Italy' with the WORLD list (Nile/Amazon/Yangtze fanned out, 226 rows).
Three root causes, all deterministic code (one is an LLM-side miss the
code now guards):
1. THE SUBJECT GUARD (new, _list_from_page): proper nouns of the
question ('Italy') must appear in the article title or the tables'
caption/headers — whole token, stem, or word prefix ('Europe' ->
'European', the gentilici pattern). The disjointness guard was vacuous
(first hop, empty evidence) and the fetch order put the world list
first; the guard now refuses it BEFORE the SELECT_TABLE call (zero
budget spent), logged as 'subject guard: ... refusing LIST'. Live
verified: world article refused, Italy article answered 22 members,
top-3 by table order = Po, Adige, Tiber.
2. WORD-BOUNDARY MATCHING (run H's KG pollution): the harvest ingested
227 world rows as 'Outflow' edges because goal term 'flow' matched
'Outflow' by substring; the discharge-list page did the same with 929
rows. _term_hits/_tokens/_col_hits replace every substring goal-term
match (harvest goal_hit + val_i, promote val_i, skim notice filter);
the keyword fallback ('flow'/'discharge' in ANY header) is gone — the
column must carry a goal term. Live: 0 Outflow edges.
3. THE EXPERT ANSWER LOG (his ask): 'OUTPUT EXPERT: Q1 -> ANSWER
value=3 (list of 3 members: Po, Adige, Tiber) quote=... url=...
[knowledge_graph]' — the answer is now IN the log, not deduced from
the fan-out that follows. Every expert output line carries the qid.
Tests: knowledge/tests/guards.py (boundary matching incl. flow !=
Outflow, proper-noun extraction, subject guard both ways, harvest
boundary, the new ANSWER log format). store.py fixture now names its
subject in the title (predates the law). Suite 52/52. Live smoke: the
full run-H regression chain on real Wikipedia.
This commit is contained in:
+12
-5
@@ -162,16 +162,23 @@ class KnowledgeEngine:
|
||||
prov["parent_question"] = parent_question
|
||||
note = "" if value.upper() != "UNKNOWN" else "knowledge returned UNKNOWN"
|
||||
if streams is not None:
|
||||
# LIST rows: value is the COUNT — the members are the real answer;
|
||||
# render them (first 10, then +N) or the log shows an opaque '22'
|
||||
# THE ANSWER, in full view (run H: the first knowledge answer was
|
||||
# only deducible from the fan-out that followed). Q ref + every
|
||||
# field the machine will act on.
|
||||
qref = qid if qid else "Q?"
|
||||
if isinstance(ans.get("list_items"), list) and ans["list_items"]:
|
||||
items = ans["list_items"]
|
||||
shown = ", ".join(items[:10]) + (f" (+{len(items) - 10} more)" if len(items) > 10 else "")
|
||||
shown = ", ".join(items[:8]) + (f" (+{len(items) - 8} more)" if len(items) > 8 else "")
|
||||
streams.output("EXPERT",
|
||||
f"value={value} list={shown} [{src}]")
|
||||
f"{qref} -> ANSWER value={value} (list of "
|
||||
f"{len(items)} members: {shown}) quote="
|
||||
f"{(ans.get('quote') or '')[:60]} url="
|
||||
f"{ans.get('url') or ''} [{src}]")
|
||||
else:
|
||||
streams.output("EXPERT",
|
||||
f"value={value} quote={(ans.get('quote') or '')[:80]} [{src}]")
|
||||
f"{qref} -> ANSWER value={value} quote="
|
||||
f"{(ans.get('quote') or '')[:80]} url="
|
||||
f"{ans.get('url') or ''} [{src}]")
|
||||
return EvidenceRow(
|
||||
qid=qid,
|
||||
answer_type=answer_type,
|
||||
|
||||
Reference in New Issue
Block a user