TypeClaim does not need to rewrite the quote/verbatim

This commit is contained in:
2026-11-01 17:12:32 +01:00
parent 4e7229c92c
commit 3d541ec8d6
5 changed files with 112 additions and 88 deletions
+21 -18
View File
@@ -5,17 +5,18 @@ of typed Facts with verbatim quotes + temporal restrictions + sibling
order assertions — the output budget behind the 40-minute arithmetic.
Two-pass shortens every output: Pass 1 lists the claims, each with its
VERBATIM quote (extracted while the text is in front of the model);
Pass 2 types ONE claim at a time into the same Fact schema the store
already eats — typing ONLY, the verbatim given as an input and the
TYPE call never carrying the chunk (owner 1/11: the VERBATIM is
obtained before).
Pass 2 types ONE claim at a time — the model sees ONLY the claim and
returns FactNoQuote; code composes the Fact the store already eats:
Fact = FactNoQuote + verbatim (owner 1/11: the VERBATIM is obtained
before, the TYPE model never sees nor rewrites it).
Orders: NEVER produced here — one claim per call has no siblings to
reference. The legacy single-pass path (and table frags) keeps them.
reference, and the TYPE schema (FactNoQuote) has no orders field at
all. The legacy single-pass path (and table frags) keeps them.
"""
from __future__ import annotations
from .extract import Claim
from .extract import Claim, Fact
def claims_from(expert, entities: str, heading: str, text: str,
@@ -48,18 +49,20 @@ def claims_from(expert, entities: str, heading: str, text: str,
def fact_from_claim(expert, claim: str, verbatim: str, charge_llm=None):
"""Pass 2: ONE claim -> one typed Fact (or None, honestly declined).
TYPING ONLY: the VERBATIM was obtained in Pass 1 and enters as an
input — the TYPE call never sees the text. Code PINS the Fact's
quote to it (LLMs propose, code decides): a paraphrased copy would
fail the containment check and lose the fact (live finding 26/10:
without grounding, 69/70 invented quotes were rejected). The
store's checks validate everything downstream as before. No
orders: no siblings by construction.
TYPING ONLY: the model sees ONLY the claim — no text, no verbatim
(owner 1/11: the VERBATIM is Pass 1's and the TYPE model never sees
nor rewrites it). Code COMPOSES the store's Fact: FactNoQuote +
verbatim (LLMs propose, code decides) — the quote is Pass 1's span
BY CONSTRUCTION, and the store's checks validate it downstream as
before (a temporal field not contained in the quote rejects the
candidate; live finding 26/10: without grounding, 69/70 invented
quotes were rejected). No orders: no siblings by construction, and
FactNoQuote has no orders field at all.
"""
if charge_llm:
charge_llm()
pred = expert.typeclaim(claim=claim, verbatim=verbatim)
fact = getattr(pred, "fact", None)
if fact is not None:
fact.quote = verbatim # the law: the Fact's quote IS Pass 1's verbatim
return fact
pred = expert.typeclaim(claim=claim)
nq = getattr(pred, "fact", None)
if nq is None:
return None
return Fact(**nq.model_dump(), quote=verbatim)