citeformer.verify.entailment¶
Per-citation NLI entailment check.
For every Citation in a GenerationResult, we look up the sentence that
contains the marker and check whether the cited source entails it. The
output is one CitationSupport record per citation carrying the NLI
entailment score and a supported boolean thresholded at the caller’s
preferred value.
The premise is normally the source content (truncated on the NLI’s
512-token budget); the hypothesis is the sentence containing the
citation. When the backend has populated :attr:Citation.cited_text
(Anthropic’s Citations API does — see ADR-013), we use that span as the
premise instead — sharper signal than the whole document, especially on
long sources where the relevant assertion is buried past the 512-token
horizon.
Module Contents¶
Functions¶
Score every citation’s entailment against its cited source. |
API¶
- citeformer.verify.entailment.score_entailment(citations: list[citeformer.core.Citation], sentence_spans: list[citeformer.verify.sentences.SentenceSpan], sources: list[citeformer.core.Source], *, nli: citeformer.verify.nli.NLIModel, threshold: float = 0.5) list[citeformer.verify.report.CitationSupport]¶
Score every citation’s entailment against its cited source.
Args: citations: The citations to score. sentence_spans: Sentence spans over
GenerationResult.text(fromciteformer.verify.sentences.split_sentences). sources: All sources in scope; used to look up content by source_id. nli: The NLI backend. threshold: Entailment probability above whichCitationSupport. supportedis True.Returns: One
CitationSupportper citation, in the same order.