Abstract
Retrieval-augmented large language models (LLMs) have been remarkably competent in various NLP tasks. However, it was observed by previous works that retrieval is not always helpful, especially when the LLM is already knowledgeable on the query to answer. Motivated by this, Adaptive Retrieval-Augmented Generation (ARAG) studies retrieving only when the knowledge asked by the query is absent in the LLM. Previous works of ARAG either require accessing the pre-training corpus or prompting with additional model inferences. Aiming to avoid such drawbacks, we propose to determine whether the model is knowledgeable on a query via inspecting the (contextualized) pre-trained token embeddings of LLMs. We hypothesize that such embeddings capture rich information on the model’s intrinsic knowledge base, which enables an efficient way of judging the necessity to retrieve from an external corpus. Extensive experiments demonstrate our ARAG approach’s superior performance across various benchmarks.
Introduction
Retrieval-Augmented Generation (RAG) has become the industry standard for grounding Large Language Models (LLMs) in external facts. However, "indiscriminate" retrieval—fetching documents for every single query—is inefficient. It increases latency, inflates token costs, and can even degrade performance if the model already knows the answer.
Adaptive RAG (ARAG) aims to trigger retrieval only when necessary. Current ARAG approaches face two major challenges: frequency-based methods often require access to proprietary or massive pre-training corpora, while prompt-based methods (asking the LLM "Do you know this?") are slow and prone to overconfident hallucinations. This paper introduces EI-ARAG (Embedding-Informed Adaptive RAG), which leverages the model's internal "gut feeling"—its token embeddings—to decide when to trigger a search.
Methodology
The core hypothesis of EI-ARAG is that pre-trained token embeddings capture the model's intrinsic knowledge base. Tokens that appeared frequently during training exhibit distinct geometric layouts in the embedding space compared to rare tokens. Visualizations using t-SNE confirm that these internal representations cluster based on exposure during pre-training.
The EI-ARAG pipeline functions as follows:
- Embedding Extraction: The system extracts embeddings for each token. Research indicates that the first contextualized layer (Layer 1) provides the optimal signal for knowledge assessment.
- Sentence Pooling: Token embeddings are average-pooled into a single vector representing the query.
- The Classifier: A lightweight, three-layer Multi-Layer Perceptron (MLP) acts as a gatekeeper, trained to predict whether a query requires retrieval.
- Dynamic Execution: If the classifier predicts a need for retrieval, the system fetches external documents; otherwise, the LLM generates an answer using its internal weights.
Experimental Setup
The framework was evaluated across several models, including GPT-Neo (1.3B, 2.7B) and LLaMA 2 (7B), using two primary benchmarks:
- PopQA: An entity-centric dataset of 14,000 questions focusing on "long-tail" knowledge.
- TriviaQA: A dataset for general reading comprehension and multi-hop reasoning.
Results
EI-ARAG demonstrates superior accuracy and efficiency compared to existing ARAG baselines. On the PopQA dataset using LLaMA 2 (7B), EI-ARAG achieved an accuracy of 33.08%, outperforming DARAG (31.99%) and TAARE (29.21%).
Key performance insights include:
- Lower Retrieval Rates: EI-ARAG is more selective, retrieving only 57.89% of the time on PopQA, compared to TAARE's 95.15%, indicating a better grasp of the model's internal knowledge boundary.
- Efficiency: The decision-making process is nearly instantaneous. EI-ARAG takes just 0.0443 seconds to decide whether to retrieve, representing a roughly 9x improvement in decision latency over prompting-based methods.
- Layer Selection: While deeper layers capture complex semantics, the first contextualized layer serves as the "sweet spot," providing sufficient information to judge retrieval necessity with minimal computational overhead.
Discussion and Conclusion
EI-ARAG provides an efficient, embedding-based mechanism for adaptive retrieval. By moving the decision logic from expensive LLM self-reflection to a tiny MLP, the system significantly reduces latency and unnecessary external calls. While the system requires a small labeled dataset to train the gatekeeper for a specific model, its ability to outperform frequency-based and prompt-based methods makes it a robust solution for modern RAG pipelines. Future work will focus on refining the classifier for even more diverse, non-factoid queries.
Summary updated