Skip to content
AI.info

Research

QuCo-RAG: Quantifying Uncertainty from the Pre-training Corpus for Dynamic Retrieval-Augmented Generation

Overview Research area: Natural Language Processing / Retrieval-Augmented Generation (dynamic RAG, hallucination detection, uncertainty quantification in LLMs). Technical level: Advanced. It assumes f

arXiv
2512.19134
Published
2025-12-22
Authors
Dehai Min, Kailin Zhang, Tongtong Wu, Lu Cheng

AI summary

Overview

Research area: Natural Language Processing / Retrieval-Augmented Generation (dynamic RAG, hallucination detection, uncertainty quantification in LLMs).

Technical level: Advanced. It assumes familiarity with RAG architectures, LLM calibration, decoding-time interventions, and entity/knowledge-triplet extraction.

Scope: The paper proposes QuCo-RAG, a dynamic RAG framework that decides when to retrieve by querying pre-training corpus statistics (entity frequency and entity co-occurrence) rather than model-internal confidence signals.

What This Paper Is About

Large language models (LLMs) are poorly calibrated: they often produce incorrect content with high confidence, so existing dynamic RAG methods that decide when to retrieve based on internal signals such as logits, entropy, or attention weights can miss hallucinations entirely. QuCo-RAG replaces these subjective signals with objective statistics computed from the model's own pre-training corpus, triggering retrieval when the question contains rare entities or when a generated claim links entities that never co-occur in the corpus. The goal is a principled, practically model-agnostic way to detect and mitigate hallucinations during generation.

Key Contributions

  1. A corpus-grounded uncertainty framework: QuCo-RAG shifts the retrieval trigger from internal model states to pre-training corpus statistics, formulated as a binary decision (retrieve or not) rather than a continuous confidence score with an arbitrary threshold.

  2. A two-stage detection design: (1) Pre-Generation Knowledge Assessment, which flags low-frequency entities in the question as long-tail knowledge risks, and (2) Runtime Claim Verification, which extracts knowledge triplets per generated sentence and triggers retrieval when head-tail entity co-occurrence is zero.

  3. Efficient trillion-token verification infrastructure: Both stages use Infini-gram for millisecond-latency queries over the OLMo-2 pre-training corpus of about 4 trillion tokens, alongside a distilled 0.5B triplet extractor (89.9% entity-level F1) distilled from GPT-4o-mini using 40K annotated examples.

  4. Broad empirical validation: State-of-the-art results on multi-hop QA across OLMo-2 7B/13B/32B, cross-model transfer to Llama-3-8B, Qwen2.5-32B, GPT-4.1 and GPT-5-chat, plus task generalization to long-form generation (ASQA) and biomedical QA (PubMedQA).

Main Findings

  • Large EM gains on matched-corpus models: On OLMo-2-7B, QuCo-RAG reaches 32.7 EM on 2WikiMultihopQA and 35.3 EM on HotpotQA, beating the best baseline by +7.4 and +5.6 points. OLMo-2-13B shows +12.0 EM on 2WikiMultihopQA and OLMo-2-32B shows +10.8 EM on HotpotQA. The abstract summarizes this as 5–12 point EM gains with OLMo-2 models.

  • Internal-signal methods are inconsistent: FLARE, DRAGIN, ETC, and SeaKR vary widely across settings. DRAGIN achieves only 17.5–19.5 EM on HotpotQA across all OLMo-2 model sizes, substantially underperforming even single-round retrieval (SR-RAG).

  • Transfer to undisclosed-data models: Using the OLMo-2 corpus as a proxy, QuCo-RAG improves Qwen2.5-32B by +14.1 EM on 2WikiMultihopQA, Llama-3-8B by +4.9 EM on 2WikiMultihopQA, GPT-4.1 by +8.1 EM on HotpotQA, and GPT-5-chat by +8.7 EM on 2WikiMultihopQA. The abstract states improvements of up to 14 EM points.

  • Built-in web search underperforms: GPT models with the agentic web search tool performed substantially worse than the no-retrieval baseline (Web-Tool: 42.9 EM on 2Wiki and 8.9 EM on HotpotQA for GPT-4.1; 48.3 and 19.8 for GPT-5-chat).

  • Favorable efficiency: On HotpotQA with OLMo-2-13B, QuCo-RAG achieves the highest EM (35.0) while consuming 87 tokens and 1.84 LLM calls on average, both the lowest among dynamic RAG methods, with 1.70 retrievals per question. FS-RAG and DRAGIN consume 2–4 times more tokens at lower performance; SeaKR incurs 10.28 LLM calls.

  • Both stages matter, runtime check more: Ablating the pre-generation check costs 2.5 EM, while ablating the runtime claim verification costs 5.1 EM. The pre-generation check alone reaches 27.6 EM with 0.76 retrievals, still above SR-RAG's 23.7 EM at 1.00 retrieval.

  • Long-form generation holds up: On ASQA with OLMo-2-7B, QuCo-RAG achieves 28.9 ROUGE-L, 28.5 DR, and 23.3 LLM_DR with 1.72 retrievals. Aggressive retrieval (FS-RAG at 11.15 retrievals, FLARE at 4.53) degrades ROUGE-L below the no-retrieval baseline.

  • Domain generalization without tuning: On PubMedQA with OLMo-2-7B, QuCo-RAG reaches 66.4% accuracy with 0.93 retrievals and 54.9 tokens, versus FLARE at 63.4% accuracy and 516.8 tokens, and DRAGIN and ETC performing at or below the no-retrieval baseline.

  • Frequency-stratified behavior: In low-frequency bins (0–10), QuCo-RAG outperforms the no-retrieval baseline by 10–17 EM points while DRAGIN and FLARE match it. In high-frequency bins (>1k), baselines degrade while QuCo-RAG continues to improve.

  • Runtime profile: LLM generation dominates 55–74% of total per-question time, with corpus-based detection adding modest overhead.

Methodology in Plain English

The authors reinterpret the retrieval decision as inherently binary: a system either retrieves or it does not, so instead of squeezing a continuous confidence score out of the model, they ask discrete factual questions about the training corpus.

Stage 1 (before generation). A lightweight entity extractor pulls the key entities out of the input question. Each entity's frequency in the pre-training corpus is queried, and the average is compared to a threshold (default 10^3). If the average falls below the threshold, the entities are long-tail knowledge the model likely never memorized well, so documents are retrieved with the original question and prepended to the context.

Stage 2 (during generation). For each generated sentence, a distilled 0.5B model extracts knowledge triplets of the form (head entity, relation, tail entity). The system checks how often the head and tail entities appear together within a window (default 1,000 tokens) in the pre-training corpus. The minimum co-occurrence across all triplets is compared to a threshold (default 1). If any pair never co-occurs, the claim has no evidential support in the corpus and is treated as a hallucination risk. Retrieval is then triggered with a semantic-oriented query built from the head entity and relation, and the sentence is regenerated.

The authors explain why they check entity co-occurrence rather than full triple co-occurrence: relational predicates vary lexically ("employed by" versus "worked at") while named entities are more stable. They also note the evidence is asymmetric: positive co-occurrence does not guarantee correctness, but zero co-occurrence strongly signals hallucination risk. Stage 2 uses a minimum (one unsupported claim is enough) while Stage 1 uses an average (to capture overall knowledge coverage).

All statistics come from Infini-gram, a suffix-array engine providing millisecond-latency queries over the roughly 4-trillion-token OLMo-2 corpus. Retrieval itself uses BM25 over the Wikipedia dump from Karpukhin et al. (2020) with top-3 documents. Datasets are the first 1,000 validation examples each of 2WikiMultihopQA and HotpotQA, plus ASQA and PubMedQA. Models run greedy decoding with a 128-token limit per step and 6-to-8-shot chain-of-thought prompting, on NVIDIA H200 GPUs (141GB HBM3e).

Why This Matters

Impact on research. The paper challenges the default assumption in dynamic RAG that internal model signals track correctness, and shows a corpus-statistics alternative transfers across model families with undisclosed training data. It connects hallucination detection to the memorization-versus-generalization debate and to work arguing that perfectly calibrated models must still hallucinate on rarely-seen facts.

Real-world applications (from the paper's framing):

  • Selective answering: systems that decline to answer when corpus evidence is absent, useful in safety-critical deployments.
  • Correctness prediction: well-grounded confidence scores for generated claims rather than miscalibrated model probabilities.
  • Training data curation: using identified knowledge gaps to decide what to collect during continued pre-training or post-training, instead of only patching gaps at inference.
  • Synthetic data filtering and model editing: verifying LLM-generated training examples against corpus statistics, and distinguishing facts that require targeted injection from those already reliably learned.

Industry relevance. The method reuses infrastructure that already exists for trillion-scale corpus search, adds no task- or domain-specific tuning, works as a proxy for proprietary models without access to their training data, and keeps token and LLM-call costs lower than competing dynamic RAG methods. The paper reports the Infini-gram index for the OLMo-2 corpus needs roughly 28 TB of disk and about 300 MB query-time RAM with no GPU, with a one-time construction cost of about 100 hours on 128 CPUs, and notes Infini-gram Mini compresses the index to 0.44 times the corpus size (about 4 TB).

Future Directions

  • Entity linking and canonicalization to reduce false-positive retrievals caused by alias mismatches (for example, "NYC" versus "New York City"), which the limitations section identifies as the main weakness of exact lexical matching.

  • Temporal corpus maintenance: static corpora cannot verify claims about events that postdate the index, so periodic corpus updates and index maintenance are needed for evolving knowledge.

  • Extending beyond entities: the authors list multilingual verification through cross-lingual statistics, time-stamped corpora for temporal dynamics, coverage of events, relations, and numerical claims, and integration into agentic systems as a self-verification tool invoked before acting.

  • Theoretical foundations: formally characterizing the relationship between corpus statistics and model knowledge, and deriving information-theoretic bounds on hallucination probability given corpus statistics.

Target Audience

Researchers and engineers working on retrieval-augmented generation, hallucination mitigation, and LLM uncertainty quantification; practitioners who need dynamic retrieval policies that work across both open-weight and proprietary models; and those interested in reusing pre-training data at inference time. Readers without background in RAG evaluation metrics (EM, F1, ROUGE-L, DR) and LLM calibration will find the experimental sections harder to follow, but the core two-stage idea is described concretely enough to grasp without deep theoretical preparation.

Authors’ abstract

Dynamic Retrieval-Augmented Generation adaptively determines when to retrieve during generation to mitigate hallucinations in large language models (LLMs). However, existing methods rely on model-internal signals (e.g., logits, entropy), which are fundamentally unreliable because LLMs are typically ill-calibrated and often exhibit high confidence in erroneous outputs. We propose QuCo-RAG, which shifts from subjective confidence to objective statistics computed from pre-training data. Our method quantifies uncertainty through two stages: (1) before generation, we identify low-frequency entities indicating long-tail knowledge gaps; (2) during generation, we verify entity co-occurrence in the pre-training corpus, where zero co-occurrence often signals hallucination risk. Both stages leverage Infini-gram for millisecond-latency queries over 4 trillion tokens, triggering retrieval when uncertainty is high. Experiments on multi-hop QA benchmarks show QuCo-RAG achieves EM gains of 5--12 points over state-of-the-art baselines with OLMo-2 models, and transfers effectively to models with undisclosed pre-training data (Llama-3, Qwen2.5, GPT-4.1/5-chat), improving EM by up to 14 points. Generalization to long-form generation and biomedical QA further validates the robustness of our paradigm. These results establish corpus-grounded verification as a principled, practically model-agnostic paradigm for dynamic RAG. Our code is publicly available at https://github.com/ZhishanQ/QuCo-RAG.

Read the original paper