Expand description
QuantGraph mode — selective grounding / repair against a NQuin fact graph.
Aggressive quantization can drop nuance; this module is the neuro-symbolic counterpart: after the LLM proposes text, high-stakes fact patterns are checked against an in-process fact graph (NQuin triples + human repair strings).
Gated by crate::inference_modes::quant_graph_grounding_enabled.
Does not run in Portable or CudaTc modes.
§Graph model
Each fact is a parity-valid NQuin:
- subject = place / entity (
q_hash) - predicate =
q42:capitalOf(or other relation) - object = answer entity hash
- context =
q42:grounding-factplus cold-path strings for prompt needles, answer tokens, and repair text.
Expand later: load from SPARQL / Wellfair graph / CBOR-LD package.
Structs§
- Grounding
Fact - Cold-path fact: NQuin + strings for matching and repair.
- Grounding
Result - Result of a grounding pass.
Constants§
- CTX_
GROUNDING - Graph context for all grounding facts.
- P_
CAPITAL_ OF - Predicate IRI for capital facts (hashed into quins).
Functions§
- export_
fact_ quins - Export all fact quins (for tests / graph dump / later SPARQL seed).
- fact_
count - Number of facts currently registered.
- ground_
generation - Unconditional grounding pass (tests / CLI).
- load_
facts_ from_ tsv - Load facts from a TSV file path. Returns count added (merge by reason).
- lookup_
capital_ object - Lookup object hash for a subject entity if a capital fact exists (graph API).
- maybe_
ground_ generation - Apply quant-graph grounding when the mode is active; otherwise identity.
- parse_
facts_ tsv - Parse TSV lines: reason \t needles; \t answer_ok; \t repair \t place_iri \t city_iri
- register_
capital_ fact - Convenience: capital-of fact from IRIs + match strings.
- register_
fact - Register (or replace by reason id) a grounding fact. Cold path.
- reset_
fact_ store_ to_ defaults - Reset store to seed defaults (tests) — re-reads bundled TSV when present.
- seed_
facts_ from_ bundled - Re-seed from bundled TSV (or QUALIA_GROUNDING_FACTS), replacing current store.