Author SHA1 Message Date
onibot 86af2c968d Merge pull request 'fix: completeness beats budget — no claim cap, dedup by code, budget 200' (#29) from fix/no-claim-cap into main 2026-10-26 20:29:31 +01:00
onibot 964189387d fix: completeness beats budget — no claim cap, dedup by code, budget 200
Owner ruling (26/10): 'the budget has never been a priority and must
never harm us here.' The cap=6 from #28 (my call, never agreed) cut the
Socialist International claim — it was #7 of 46 in the lead chunk of
live run 20261026-170521 — so the KG never held the third presidency
reading and the judge could not offer it.

- claims_from: NO cap, NO semantic filter. Code-only honesty: exact
  repeats dropped (live finding: glm listed its 46-claim list with ~26
  exact repeats + thinking leakage as items). Case/whitespace-insensitive
  dedup keeps the FIRST occurrence. Every unique claim gets its TYPE
  call.
- max_claims_per_chunk: deprecated in config (kept only for the
  table-frags legacy path).
- budget.max_llm_calls: 80 -> 200 (bounds runaway runs only).

TDD: two_pass_extract 6/6 (new: dedup keeps unique claims verbatim).
Suite: 30 test files green.
2026-10-26 20:29:27 +01:00
onibot 2ee3b54661 Merge pull request 'fix: two-pass Pass 2 needs the chunk text (invented quotes) + claim cap' (#28) from fix/two-pass-contract into main 2026-10-26 17:05:16 +01:00
4 changed files with 51 additions and 12 deletions
+3 -1
View File
@@ -35,7 +35,9 @@ lm[ExtractSignature]:
# on slow local models (the 40-min arithmetic) # on slow local models (the 40-min arithmetic)
budget: budget:
max_llm_calls: 80 # per FLOOP run (children get a slice; fan-outs multiply # owner ruling 26/10: completeness beats budget — the budget must never
# silently truncate extraction; it bounds runaway runs only
max_llm_calls: 200 # per FLOOP run (children get a slice; fan-outs multiply
# entity questions — a 3-river fan needs ~3x a scalar) # entity questions — a 3-river fan needs ~3x a scalar)
min_child_budget: 6 min_child_budget: 6
max_depth: 2 # recursion cap (PIPELINE.md §8.4) max_depth: 2 # recursion cap (PIPELINE.md §8.4)
+7 -6
View File
@@ -164,10 +164,10 @@ class KnowledgeConfig:
semantic_tau: float = 0.45 # calibration: rivers 0.49-0.52 in, Pedro semantic_tau: float = 0.45 # calibration: rivers 0.49-0.52 in, Pedro
# cross-question 0.35-0.38 out, spouse-noise ~0.67 # cross-question 0.35-0.38 out, spouse-noise ~0.67
max_facts_per_chunk: int = 12 # question-blind extraction needs a cap max_facts_per_chunk: int = 12 # question-blind extraction needs a cap
max_claims_per_chunk: int = 6 # two-pass: each claim costs a TYPE call — max_claims_per_chunk: int = 6 # DEPRECATED (owner ruling 26/10:
# the budget is finite (80/run); without a # completeness beats budget) — no longer
# cap one big article starves the run # read by the two-pass loop; kept only for
# (live finding 26/10: 70 claims -> 80/80) # the table-frags legacy path
extract_mode: str = "two_pass" # "two_pass" (claims -> typed Facts, short extract_mode: str = "two_pass" # "two_pass" (claims -> typed Facts, short
# outputs) | "single" (legacy one-call typed # outputs) | "single" (legacy one-call typed
# array — table frags keep using it) # array — table frags keep using it)
@@ -1183,8 +1183,9 @@ class KnowledgeExpert:
claims = claims_from(self, entities=ent_str, claims = claims_from(self, entities=ent_str,
heading=chunk.heading_path, heading=chunk.heading_path,
text=chunk.text, charge_llm=charge_llm) text=chunk.text, charge_llm=charge_llm)
# budget law: each claim costs a TYPE call — cap per chunk # owner ruling 26/10: completeness beats budget — every
for claim in claims[: self.cfg.max_claims_per_chunk]: # unique claim gets its TYPE call (no cap, dedup only)
for claim in claims:
fact = fact_from_claim(self, claim, text=chunk.text, fact = fact_from_claim(self, claim, text=chunk.text,
charge_llm=charge_llm) charge_llm=charge_llm)
if fact is None: if fact is None:
+27 -1
View File
@@ -101,10 +101,36 @@ def test_honest_empty():
print("ok: no claims -> no facts; untypeable claim -> None, no invention") print("ok: no claims -> no facts; untypeable claim -> None, no invention")
def test_claims_from_dedupes_exact_repeats():
"""Pass 1 sometimes repeats its own list (live: glm listed 46 claims,
~26 were exact repeats/thinking leakage). Dedup is CODE, cheap and
deterministic — the claim list must not be capped or filtered
semantically, only made honest: no exact duplicates survive."""
calls = []
class E: # minimal expert double
def claims(self, entities, heading, text):
calls.append((entities, heading))
class Out:
claims = ["Pedro Sanchez is prime minister of Spain.",
"pedro sanchez is prime minister of spain. ",
"Pedro Sanchez is Secretary-General of the PSOE.",
"Pedro Sanchez is prime minister of Spain.",
"from the text. I need to list factual claims"]
return Out()
got = claims_from(E(), entities="Pedro Sanchez", heading="h", text="t")
assert got == ["Pedro Sanchez is prime minister of Spain.",
"Pedro Sanchez is Secretary-General of the PSOE.",
"from the text. I need to list factual claims"], got
print("ok: exact repeats deduped (case/space-insensitive); the rest kept")
if __name__ == "__main__": if __name__ == "__main__":
test_extract_claims_signature() test_extract_claims_signature()
test_type_claim_signature() test_type_claim_signature()
test_claims_from_dedupes_exact_repeats()
test_claims_from_runs_pass1() test_claims_from_runs_pass1()
test_fact_from_claim_types_one_fact() test_fact_from_claim_types_one_fact()
test_honest_empty() test_honest_empty()
print("\ntwo_pass_extract: 5/5 ok") print("\ntwo_pass_extract: 6/6 ok")
+14 -4
View File
@@ -15,16 +15,26 @@ from __future__ import annotations
def claims_from(expert, entities: str, heading: str, text: str, def claims_from(expert, entities: str, heading: str, text: str,
charge_llm=None) -> list[str]: charge_llm=None) -> list[str]:
"""Pass 1: the chunk's claims as plain strings, coreferences resolved.""" """Pass 1: the chunk's claims as plain strings, coreferences resolved.
The list is made honest by CODE only: exact repeats are dropped
(live finding 26/10: glm sometimes lists its whole list twice, and
thinking leakage leaks in as list items). Dedup is case- and
whitespace-insensitive; the FIRST occurrence's exact text is kept.
NO cap, NO semantic filter: completeness beats budget (owner ruling
26/10) — every unique claim gets its TYPE call.
"""
if charge_llm: if charge_llm:
charge_llm() charge_llm()
pred = expert.claims(entities=entities, heading=heading, text=text) pred = expert.claims(entities=entities, heading=heading, text=text)
out = [] seen: dict[str, str] = {}
for c in (pred.claims or []): for c in (pred.claims or []):
c = (c or "").strip() c = (c or "").strip()
if c: if c:
out.append(c) key = " ".join(c.lower().split())
return out if key not in seen:
seen[key] = c
return list(seen.values())
def fact_from_claim(expert, claim: str, text: str, charge_llm=None): def fact_from_claim(expert, claim: str, text: str, charge_llm=None):