NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DRAGIN: Dynamic Retrieval Augmented Generation based on the Real-time Information Needs of Large Language Models

Weihang Su, Yichen Tang, Qingyao Ai, Zhijing Wu, Yiqun Liu

Introduction

Retrieval-Augmented Generation (RAG) has emerged as a powerful technique to mitigate hallucinations in Large Language Models (LLMs) by providing external context. However, traditional RAG implementations are often "static," retrieving information only once at the beginning of a prompt. This approach is insufficient for complex, multi-step tasks where a model's information needs evolve during the generation process.

Existing dynamic RAG methods attempt to address this but suffer from two primary limitations:

  1. Rigid Timing: Retrieval is often triggered by fixed rules (e.g., every $n$ tokens) or simple confidence thresholds, leading to redundant or missed retrievals.
  2. Narrow Query Formulation: Queries are typically formed using only the most recent tokens, ignoring the broader context that might define the model's actual information need.

To overcome these challenges, we present DRAGIN, a framework that enables truly dynamic RAG by monitoring the LLM's internal states in real-time.

Methodology: Listening to the Model's "Cries for Help"

DRAGIN introduces two plug-and-play components that require no additional training: RIND and QFS.

RIND: Real-time Information Needs Detection

RIND determines when to retrieve by calculating a "necessity score" ($S_{RIND}$) for each generated token. This score integrates three key metrics:

  • Uncertainty: High entropy in the next-token distribution indicates the model is "confused."
  • Influence: Using self-attention weights, RIND identifies tokens that significantly impact future generation.
  • Semantic Significance: A filter ensures retrieval isn't triggered by common stop-words like "the" or "is."

QFS: Query Formulation based on Self-attention

Once a need is detected, QFS determines what to retrieve. Unlike methods that use a fixed window of recent text, QFS leverages the LLM's self-attention mechanism to identify which parts of the entire preceding context the model is currently focused on. By selecting the top $n$ tokens with the highest attention weights, QFS constructs a query that is semantically aligned with the model's internal reasoning.

The DRAGIN workflow: RIND detects information needs via uncertainty and influence, while QFS formulates queries using global self-attention.

Experimental Evaluation

DRAGIN was evaluated on four knowledge-intensive benchmarks: 2WikiMultihopQA, HotpotQA, StrategyQA, and IIRC. These datasets require multi-step reasoning and external knowledge. Testing was conducted using LLaMA-2 (7B/13B) and Vicuna-13B models.

Key Results

DRAGIN consistently outperforms baseline RAG methods, including single-round (SR-RAG) and popular dynamic frameworks like FLARE.

Performance comparison of DRAGIN against various RAG methods across multiple benchmarks and LLMs.

As shown in the results, DRAGIN achieves significant gains in F1 and Exact Match (EM) scores. For instance, on 2WikiMultihopQA with LLaMA2-13B, DRAGIN reached an F1 of 0.3931, a substantial improvement over FLARE's 0.3076. Notably, DRAGIN is often more efficient than sentence-based retrieval (FS-RAG), making fewer retrieval calls while achieving superior accuracy.

Insights and Discussion

  • Internal Alignment: The core strength of DRAGIN lies in its use of the model's own attention heads. The model effectively "knows" what it needs; DRAGIN simply provides the mechanism to act on that internal state.
  • Uncertainty vs. Importance: A model might be uncertain about a word, but if that word has low influence on the rest of the sentence, retrieving information is a waste of compute. RIND’s inclusion of an "influence" metric prevents unnecessary overhead.
  • Robustness: Ablation studies show that the framework is relatively insensitive to hyperparameter tuning (like the threshold for triggering RIND), making it practical for real-world deployment.

Limitations and Future Work

DRAGIN is a "white-box" method, requiring access to internal logprobs and attention weights, which currently limits its use with closed-source APIs like GPT-4. Additionally, smaller models (like LLaMA-7B) can sometimes be overwhelmed by excessive retrieved context. Future research will focus on helping smaller models better synthesize information in very long-context scenarios.

Summary updated

BibTeX
@inproceedings{su2024dragin,
  author = {Weihang Su and Yichen Tang and Qingyao Ai and Zhijing Wu and Yiqun Liu},
  title = {{DRAGIN: Dynamic Retrieval Augmented Generation based on the Real-time Information Needs of Large Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.702},
}
Figure