knowledge: answer-level count corroboration (DESIGN §12) — LIST rows verified via prose

- VerifyCountSignature: LLM finds ONE verbatim sentence in the article prose
  (tables excluded by construction) stating the set's count
- _verify_count: code checks containment + digit equality — no LLM compares
  numbers; NOQUOTE -> count_corroborated=false (honest, one call, never loops)
- row verified <=> complete_per_source AND count_corroborated
- DESIGN §12 documents now vs deferred (extension, criteria, cross-article)
- live: EU question cold — E1 (50) + E2 (27) both corroborated with quotes,
  23 computed; 25/25 tests
This commit is contained in:
2026-10-19 14:47:18 +02:00
parent b14915079e
commit 852db78c99
6 changed files with 235 additions and 10 deletions
+19
View File
@@ -47,6 +47,25 @@ class AnswerFromKG(dspy.Signature):
confidence: str = dspy.OutputField(desc="high medium low")
class VerifyCountSignature(dspy.Signature):
"""You are the VERIFY step of a knowledge machine. A list answer has been
ingested from a table in one article (set_name, N elements). Find ONE
sentence in the article prose that states the expected count of that set
(independently of the table). Quote it VERBATIM. If no such sentence
exists, write NOQUOTE.
Example:
set_name: European Union member states
count: 27
GOOD quote: "The European Union (EU) is a supranational union of 27
member states that are party to the EU's founding treaties"
BAD (not a count statement): a row of the table itself."""
set_name: str = dspy.InputField()
count: str = dspy.InputField()
text: str = dspy.InputField(desc="the article prose WITHOUT the tables")
quote: str = dspy.OutputField(desc="verbatim sentence stating the count, or NOQUOTE")
class SelectTableSignature(dspy.Signature):
"""You are the SELECT TABLE step of a knowledge machine. Given a question
and the tables found in an article (index, caption, header columns, row