Mitigating Hallucinations in Large Language Models via Self-Refinement-Enhanced Knowledge Retrieval

Mengjia Niu, Hao Li, Jie Shi, Hamed Haddadi, Fan Mo

TL;DR

Post-generation knowledge graph (KG) verification can prevent large language models from hallucinating in high-stakes fields like healthcare, but verifying every single generated statement is slow, costly, and error-prone. Re-KGR (Self-Refinement-Enhanced Knowledge Graph Retrieval) detects high-uncertainty tokens using internal model logits and layer divergence, extracting and verifying only the triples containing those risky entities. This "refine-then-retrieve" design cuts KG retrieval time by 63–75% while simultaneously improving factual truthfulness over unrefined baselines.

What Problem Does This Paper Address?

In domain-specific applications like medicine, hallucinations—specifically factual inconsistencies—can lead to hazardous advice. While Retrieval-Augmented Generation (RAG) is commonly used to ground answers, prompting an LLM with external documents does not fully eliminate hallucinations due to the model's reasoning lapses.

Post-processing methods address this by converting generated answers into structured knowledge triples (e.g., <Subject, Predicate, Object>) and verifying them against a Knowledge Graph. However, existing KG-based verification frameworks try to query and verify every claim in a response. This creates heavy computational bottlenecks and frequently introduces errors when benign or redundant triples are misaligned during graph matching.

Methods

Re-KGR introduces a post-generation verification pipeline consisting of four main stages:

  1. Entity Detection: Before touching the external graph, the system flags tokens with a high probability of hallucination by inspecting predictive uncertainties. The authors evaluate three criteria:
  2. Maximum predictive probability ($c_m$)
  3. Predictive entropy ($c_e$)
  4. Jensen-Shannon divergence between final and intermediate layer representations ($c_{js}$, adapted from DoLa) Tokens with anomalous uncertainty values are identified via quartile-based thresholding.

  5. Triple Extraction & Refinement: The LLM extracts factual statements from the generated response into <Subject, Predicate, Object> triples. Instead of verifying all of them, Re-KGR filters the set to retain only triples containing the identified high-risk entities.

  6. KG Retrieval: Entities and relations are expanded using synonym matching and queried against an external graph database using Cypher queries.
  7. Knowledge Verification & Rectification: A semantic-similarity model (using spaCy) compares extracted triples with retrieved graph triples. If the similarity score falls below a threshold $\tau$, the faulty triple is substituted with the verified graph fact, followed by a light grammar correction pass to preserve natural fluency.
Intermediate Response + Logits 
       │
       ▼
[Entity Detection] ──► Identify High-Risk Entities (Entropy / Layer Divergence)
       │
       ▼
[Triple Extraction] ──► Extract Triples & Filter to Only Critical Entities
       │
       ▼
[KG Retrieval] ───────► Query Medical KG (CKG + PrimeKG) via Synonyms
       │
       ▼
[Verification & Fix] ─► Replace Incorrect Triples & Polish Output Grammar

Datasets

  • MedQuAD: A medical question-answering dataset sourced from National Institutes of Health websites, covering 37 question types (e.g., treatments, diagnoses, side effects). The authors filtered pairs to ensure target diseases existed in the graph database.
  • Knowledge Graphs: The authors constructed a combined graph backend in Neo4j by merging the Clinical Knowledge Graph (CKG) with PrimeKG (to incorporate disease symptoms and precision medicine relationships). No new benchmark dataset was released.

Key Insights and Ideas

  • Less retrieval is actually more accurate: Intuitively, verifying every claim seems safer. In practice, querying every triple degraded answer quality (e.g., dropping LLaMA's GPT-4 score from 0.537 to 0.518). Unnecessary queries often extract sub-statements that misalign during semantic matching, causing the model to overwrite correct text with incorrect edits.
  • Entropy vs. Divergence Trade-Off:
  • The predictive entropy criterion ($c_e$) delivered the highest factual accuracy (0.610 score).
  • The layer-divergence metric ($c_{js}$) extracted fewer entities, enabling the fastest retrieval (14.13 seconds vs. 26.13 seconds for $c_e$) while retaining strong factuality (0.604 score).
  • Contrastive decoding sharpens uncertainty signals: Pairing Re-KGR with DoLa (a contrastive decoding technique) yielded much stronger gains (+15.75% over base LLaMA) than pairing with vanilla LLaMA (+1.90%). DoLa's contrasting mechanism appears to push internal logits toward states where uncertainty correlates more reliably with genuine errors.

Key Results

  • Factuality (Evaluated by GPT-4 on a 0–1 scale):
  • Vanilla LLaMA-7b: 0.527 $\rightarrow$ with Re-KGR: 0.537 (+1.90%)
  • DoLa baseline: 0.591 $\rightarrow$ with Re-KGR: 0.610 (+15.75% over vanilla LLaMA, +3.21% over DoLa)
  • Latency Reduction:
  • For vanilla LLaMA, retrieval time dropped from 64.88s (unrefined) to 16.14s with Re-KGR (a 75% reduction).
  • For DoLa, retrieval dropped from 71.29s to 26.13s (standard Re-KGR) and 14.13s when using the $c_{js}$ divergence criterion.

Limitations and Future Work

  • Domain & Model Scope: Experiments were restricted to a 7B-parameter model (LLaMA-7b) and medical QA. It remains unclear how well internal logit signals scale to larger models (e.g., 70B+) or other knowledge domains.
  • Dependency on Structured KGs: The system relies on a well-curated knowledge graph containing the relevant entities and synonyms; incomplete KGs will limit rectification.
  • Pipeline Latency: Because rectification happens entirely in a post-generation stage, overall response latency remains higher than standard single-pass generation. The authors propose integrating the retrieval process directly during decoding in future work.

Summary updated

BibTeX
@inproceedings{niu2024mitigating,
  author = {Mengjia Niu and Hao Li and Jie Shi and Hamed Haddadi and Fan Mo},
  title = {{Mitigating Hallucinations in Large Language Models via Self-Refinement-Enhanced Knowledge Retrieval}},
  booktitle = {Gen-IR @ SIGIR},
  year = {2024},
  url = {https://openreview.net/forum?id=H6Kz3tRugR},
}
Figure