diff --git a/code/config.yaml b/code/config.yaml index dffed8b..ad8095c 100644 --- a/code/config.yaml +++ b/code/config.yaml @@ -35,7 +35,9 @@ lm[ExtractSignature]: # on slow local models (the 40-min arithmetic) 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) min_child_budget: 6 max_depth: 2 # recursion cap (PIPELINE.md §8.4) diff --git a/code/knowledge/expert.py b/code/knowledge/expert.py index db80de2..76a53e6 100644 --- a/code/knowledge/expert.py +++ b/code/knowledge/expert.py @@ -164,10 +164,10 @@ class KnowledgeConfig: semantic_tau: float = 0.45 # calibration: rivers 0.49-0.52 in, Pedro # cross-question 0.35-0.38 out, spouse-noise ~0.67 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 — - # the budget is finite (80/run); without a - # cap one big article starves the run - # (live finding 26/10: 70 claims -> 80/80) + max_claims_per_chunk: int = 6 # DEPRECATED (owner ruling 26/10: + # completeness beats budget) — no longer + # read by the two-pass loop; kept only for + # the table-frags legacy path extract_mode: str = "two_pass" # "two_pass" (claims -> typed Facts, short # outputs) | "single" (legacy one-call typed # array — table frags keep using it) @@ -1183,8 +1183,9 @@ class KnowledgeExpert: claims = claims_from(self, entities=ent_str, heading=chunk.heading_path, text=chunk.text, charge_llm=charge_llm) - # budget law: each claim costs a TYPE call — cap per chunk - for claim in claims[: self.cfg.max_claims_per_chunk]: + # owner ruling 26/10: completeness beats budget — every + # unique claim gets its TYPE call (no cap, dedup only) + for claim in claims: fact = fact_from_claim(self, claim, text=chunk.text, charge_llm=charge_llm) if fact is None: diff --git a/code/knowledge/tests/two_pass_extract.py b/code/knowledge/tests/two_pass_extract.py index 93780cc..26aadd6 100644 --- a/code/knowledge/tests/two_pass_extract.py +++ b/code/knowledge/tests/two_pass_extract.py @@ -101,10 +101,36 @@ def test_honest_empty(): 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__": test_extract_claims_signature() test_type_claim_signature() + test_claims_from_dedupes_exact_repeats() test_claims_from_runs_pass1() test_fact_from_claim_types_one_fact() test_honest_empty() - print("\ntwo_pass_extract: 5/5 ok") \ No newline at end of file + print("\ntwo_pass_extract: 6/6 ok") \ No newline at end of file diff --git a/code/knowledge/two_pass.py b/code/knowledge/two_pass.py index 8847afc..31957f6 100644 --- a/code/knowledge/two_pass.py +++ b/code/knowledge/two_pass.py @@ -15,16 +15,26 @@ from __future__ import annotations def claims_from(expert, entities: str, heading: str, text: 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: charge_llm() pred = expert.claims(entities=entities, heading=heading, text=text) - out = [] + seen: dict[str, str] = {} for c in (pred.claims or []): c = (c or "").strip() if c: - out.append(c) - return out + key = " ".join(c.lower().split()) + if key not in seen: + seen[key] = c + return list(seen.values()) def fact_from_claim(expert, claim: str, text: str, charge_llm=None):