Skip to main content

Module quant_graph_grounding

Module quant_graph_grounding 

Source
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-fact plus cold-path strings for prompt needles, answer tokens, and repair text.

Expand later: load from SPARQL / Wellfair graph / CBOR-LD package.

Structs§

GroundingFact
Cold-path fact: NQuin + strings for matching and repair.
GroundingResult
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.