citeformer.verify.existence¶
Existence check — do cited IDs resolve to real sources?
Under Tier 1 (grammar-enforced backends, all current local backends) this
check is trivially always True because the decoder cannot produce a
citation to an out-of-range id. It’s still valuable to run:
Backwards-compatibility: a future API-provider backend (schema-level enforcement rather than grammar-level) may let an ID slip through.
Robustness: if a user hand-constructs a
GenerationResultor swaps backends, existence becomes a non-trivial assertion.Diagnostics: citeformer-internal bugs that emit malformed citations surface here.
No ML required; pure set arithmetic.
Module Contents¶
Classes¶
Outcome of the existence check. |
Functions¶
Verify every citation’s |
API¶
- class citeformer.verify.existence.ExistenceResult¶
Outcome of the existence check.
Attributes: all_exist: True iff every
Citation.source_idis in[1, len(sources)]. missing: The source_ids that were emitted but don’t resolve — empty ifall_existis True.
- citeformer.verify.existence.check_existence(citations: list[citeformer.core.Citation], sources: list[citeformer.core.Source]) citeformer.verify.existence.ExistenceResult¶
Verify every citation’s
source_idpoints to a real source.Args: citations: The citations emitted in generation. sources: The sources that were in scope for the generation call.
Returns: An
ExistenceResultcarrying the verdict + any missing ids.