Back to Blog
Published:
Last Updated:
Recently Updated
Enterprise GraphRAG & Knowledge SystemsChapter 3

Anti-Hallucination via Runtime Grounding Against a Domain Vocabulary

6 min read
1,300 words
medium priority
Mudassir Marwat

Mudassir Marwat

Founder & CEO, Cognilium AI

Anti-Hallucination via Runtime Grounding Against a Domain Vocabulary — Cognilium AI

TL;DR

A startup-loaded domain vocabulary the generator must match against, plus framework rules baked into every prompt — a low-cost pattern that catches hallucinated terminology before the user sees it.

Domain-specific generation has a recurring failure mode: the LLM produces output that is fluent and confident but uses terminology that does not exist in the domain. A K-12 writing methodology has 298 specific terms; the generator may produce "voiceful sentence" or "stylistic figure" — words that sound right and are not in the framework. End users notice, trust evaporates.

A validator that runs at output time and compares generated terminology against a startup-loaded vocabulary catches this before the user sees it, at 2-5ms of latency. The pattern is cheap and underused.

Vocabulary loading

At process startup, the validator loads the domain vocabulary from a versioned source — for our K-12 system it is a 298-term file extracted from the framework documentation. The vocab is parsed into a set with synonyms and inflection variants pre-computed. Total size: ~2KB in memory.

Validation flow

Every generated output gets one validation pass. The pass runs the structured output through a regex-based extractor that finds named-entity-style terms (capitalized, multi-word, or matching domain patterns). Each extracted term is checked against the vocabulary set.

  • Match: pass.
  • No match, fuzzy-match within edit distance 1: log + auto-correct (covers typos in generation).
  • No match, no fuzzy match: validation fails.

What happens on failure

Failure triggers a retry with a stricter prompt that lists the allowed vocabulary inline ("Use only these terms for craft elements: ..."). After two retries the system falls back to the closest valid term by embedding similarity and flags the output for human review. The flag goes to a queue; an editor sees the original prompt, the failed generation, and the auto-correction within hours.

Why not just put the vocabulary in the system prompt?

You can. It costs tokens on every call. With 298 terms (roughly 4KB of text), that is ~1,000 tokens per request times every request. The validator approach loads the vocab in process memory and keeps system prompts short. The cost trade is real and worth measuring.

What we measured

  • Validation latency: 2-5ms (regex + set lookup, no LLM call)
  • Hard-fail rate after two retries: <0.5%
  • False positives caught (terms LLM invented): ~3-5% of raw generations
  • Vocab size: 298 terms, ~2KB resident memory
  • Editor flag queue: ~10-20 items per day at 30K queries/month, manageable for a part-time reviewer

Share this article

Enterprise GraphRAG & Knowledge Systems

Topic Cluster

The work behind this series

How we design the graph schema, the retrieval path and the evaluation harness behind these articles.

Mudassir Marwat

Mudassir Marwat

Founder & CEO, Cognilium AI

Mudassir Marwat's argument is that ERP systems record decisions they never optimise.

Founder & CEO of Cognilium AI; 37 AI agents in production across four products; 4 production AI products built and operated; three clouds in production (AWSGCPAzure)
Agentic AIRAG → GraphRAG retrievalVoice AIMulti-Agent Orchestration

Frequently Asked Questions

Find answers to common questions about the topics covered in this article.

Evals run offline on a sample. This runs online on every output, before delivery, in <100ms. It is a validator, not a measurement.
The vocab is loaded at startup from a versioned source (in our case, a curated domain vocabulary file with 298 terms). New terms ship via PR; the validator never silently approves an unknown term. False positives become a curation signal.
You can. GPT-4o hallucinates terms less than GPT-4o-mini. But cost and latency triple. The validator lets you keep the cheaper model for generation and pay 2-5ms of validation overhead instead.
The system retries the generation with a stricter prompt that lists the allowed vocabulary inline. After two retries, it falls back to the most-similar valid term and flags the output for human review. Hard fail rate: <0.5%.
Less well. It works best when the output is structurally constrained — terminology must come from a known set. For free-form prose, use it on the named-entity layer (only check that proper nouns and technical terms match the vocab) and let the connective tissue be free.

Still have questions?

Get in touch with our team for personalized assistance.

Contact Us

Still have a question this did not answer?

The person who wrote this article answers these. Describe your setup and what you are stuck on — you will get a straight answer, including where we think the approach is wrong.

Related Articles

Continue exploring related topics and insights from our content library.

The 8-Stage Document Intelligence Pipeline
11 min
1
Mudassir Marwat
May 5, 2026

The 8-Stage Document Intelligence Pipeline

Parse, classify, evidence-map, extract, validate, score, graph, link. The eight-stage pipeline for legal/financial document AI.

words
Read Article
Zero-Trust Multi-Tenant Firestore: Middleware, Claims, and 60+ Wildcard Permissions
9 min
2
Mudassir Marwat
May 5, 2026

Zero-Trust Multi-Tenant Firestore: Middleware, Claims, and 60+ Wildcard Permissions

Hard tenant isolation on Firestore: middleware, immutable claims, wildcard permissions. The architecture that makes leakage structurally impossible.

words
Read Article
Organizational Memory: RAG Across Slack, Confluence, and Loom
9 min
3
Mudassir Marwat
May 5, 2026

Organizational Memory: RAG Across Slack, Confluence, and Loom

A single retrieval surface over Slack, Confluence, Loom, and meeting transcripts — with cross-source ranking and source attribution that survives ingestion.

words
Read Article

Explore More Insights

Discover more expert articles on AI, engineering, and technology trends.

Personalized for You

Curated content recommendations based on your current reading and interests.

Hybrid Retrieval With Prefetch-Time Metadata Filtering — Cognilium AI
Trending
119%

Hybrid Retrieval With Prefetch-Time Metadata Filtering

Same topic cluster: Enterprise GraphRAG & Knowledge Systems
Same author: Mudassir Marwat

Why filtering after RRF fusion loses the right chunks, and how a "drop trait → mode → grade" progressive relaxation ladder keeps narrow queries answerable without dropping retrieval quality.

Mudassir Marwat
8 min read
Enterprise GraphRAG & Knowledge Systems
Read Article
Trending
32%

Does Dynamics 365 match product receipts to invoices automatically?

High priority content
Similar reading time

Yes, in the background, hourly or daily, where a three-way policy exists. It also has a retry limit, so some lines stop being tried altogether.

Ali Ahmed
5 min read
Procure-to-Pay Agent Operations
Read Article
You cannot retrieve your way out of a bad graph. In a GraphRAG system, answer quality is decided at construction, not retrieval, because the graph is built once and queried forever. Where quality is won, in four points: schema first, with typed nodes and typed edges; extraction as a pipeline of eight stages, not one prompt; entity resolution at write time, so one entity becomes one node; and provenance on every edge, so every claim is one you can check. Build it like it matters.
Trending
112%

You Cannot Retrieve Your Way Out of a Bad Graph

Same topic cluster: Enterprise GraphRAG & Knowledge Systems
Same author: Mudassir Marwat

A team comes to us with a GraphRAG system that gives wrong answers, and they have spent three weeks on retrieval. It will not help. The retrieval is fine. The graph it is retrieving over was built by a loose extraction prompt that produced three copies of every company and edges nobody typed. In GraphRAG, answer quality is decided at construction, not retrieval, because a graph is a stateful artifact where one wrong edge corrupts every query that traverses it, and multi-hop traversal compounds the error. Design the schema before you extract, run extraction as a staged pipeline rather than one prompt, resolve entities at write time so one entity is one node, make provenance first-class so every claim traces to a source span, and validate at insertion so bad data never lands. Test it with a real three-hop query: build the graph right and multi-hop just works, build it wrong and no retriever recovers it. You cannot retrieve your way out of a bad graph.

Mudassir Marwat
16 min read
Enterprise GraphRAG & Knowledge Systems
Read Article
Architecture diagram showing the retrieval ceiling between plain vector RAG and GraphRAG hybrid retrieval pipelines.
Trending
108%

RAG vs GraphRAG: When the Vector Database Stops Being Enough

Same topic cluster: Enterprise GraphRAG & Knowledge Systems
Same author: Mudassir Marwat

Plain vector RAG hits a ceiling around 100K documents. This is where graph-augmented retrieval becomes the right tool — and how to know if you need it.

Mudassir Marwat
12 min read
Enterprise GraphRAG & Knowledge Systems
Read Article
Organizational Memory: RAG Across Slack, Confluence, and Loom — Cognilium AI
For You
106%

Organizational Memory: RAG Across Slack, Confluence, and Loom

Same topic cluster: Enterprise GraphRAG & Knowledge Systems
Same author: Mudassir Marwat

A single retrieval surface over Slack, Confluence, Loom, and meeting transcripts — with cross-source ranking and source attribution that survives ingestion.

Mudassir Marwat
9 min read
Enterprise GraphRAG & Knowledge Systems
Read Article
A spiral staircase seen from directly above
For You
85%

What is agentic RAG, and when is the extra loop worth it?

Same topic cluster: Enterprise GraphRAG & Knowledge Systems
Matches your interests

Classic RAG retrieves once and answers. Agentic RAG lets the model decide whether to retrieve, what to ask for, and when to stop. Here is what that costs.

Ali Ahmed
6 min read
Enterprise GraphRAG & Knowledge Systems
Read Article

Smart Recommendations

Our AI analyzes topic clusters, author expertise, and content relationships to surface the most relevant articles for you.

Topic Matching
Author Expertise
Content Quality
Personal Interests

Questions on this?

Talk to an engineer

Schedule a call