Retrieval as Reasoning: Learning to Select and Generate with LLMs

Qiwei Di, Yuhang He, Qi Chen, Quanquan Gu, Peng Cheng, Jing BaiOpenReview 2026 · Submission to ICLR 2026 · Rejected

TL;DR

This paper proposes a unified framework that transforms an LLM into a self-contained retrieval and generation engine. By replacing external retrievers with internal "hierarchical semantic IDs" and a lightweight self-reflection module, the model learns to select only the most useful documents (typically just 2-3) and generate answers in a single, end-to-end differentiable process.

What Problem Does This Paper Address?

While Retrieval-Augmented Generation (RAG) is the standard fix for LLM hallucinations, it suffers from a fundamental "handshake" problem between its components.

  1. Objective Misalignment: Traditional retrievers are trained on semantic similarity (how much does this look like the query?), but generators need utility (does this help answer the query?). A document can be semantically similar but factually useless or even misleading.
  2. Context Bloat and Positional Bias: To ensure the answer is "in there somewhere," RAG systems often stuff dozens of documents into a prompt. This creates massive computational overhead and triggers the "lost in the middle" phenomenon, where LLMs struggle to use information buried in the center of a long context.
  3. Pipeline Complexity: Managing separate retrievers, rerankers, and generators makes the system brittle and difficult to optimize as a whole.

Methods

The authors introduce a framework where retrieval is treated as an internal reasoning step rather than an external database query.

  • Hierarchical Semantic IDs: Instead of using vector embeddings, every document in the corpus is assigned a structured ID (e.g., 3-17-25-0) based on its position in a semantic cluster tree. To "retrieve," the model simply generates these ID tokens autoregressively.
  • The Self-Reflection Module: The authors modify the standard Transformer block. They add a dedicated "retrieval pathway" consisting of separate query-specific attention heads ($Q'$) and a retrieval-specific MLP. This allows the model to develop internal representations of "relevance" that are distinct from the representations used for linguistic fluency.
  • Cross-Attention Bridge: To ensure the generation process actually uses the retrieved evidence, a cross-attention layer explicitly links the retrieval-enhanced hidden states with the generation stream.
  • End-to-End Joint Training: The model is trained in two modes. Mode 1 uses ground-truth document IDs to supervise the retriever. Mode 2 is "unsupervised," where the model samples documents, generates an answer, and is optimized based on whether that answer is correct. This forces the retriever to prioritize documents that actually lead to better answers.

Datasets

The researchers evaluated their approach using two hallmark open-domain QA benchmarks:

  • Natural Questions (NQ): Real-world queries from Google Search paired with Wikipedia evidence.
  • TriviaQA: A reading comprehension dataset with complex questions and multiple supporting documents.

They used Llama-3.1-8B-Instruct and Qwen3-4B-Instruct as the backbone models for their experiments.

Key Insights and Ideas

  • Retrieval as Token Generation: By treating document IDs as tokens, the model can use its existing autoregressive machinery to "find" information. This unifies the vocabulary of searching and speaking.
  • Internalizing the Reranker: Because the model has a dedicated retrieval pathway, it effectively performs "reranking" internally. It doesn't just find similar documents; it learns to "promote" the most helpful ones to the top of its internal priority list.
  • The Power of Sparsity: Unlike standard RAG which might use 10-20 documents, this model is optimized to be highly selective. The authors found that selecting just the top 2-3 documents was sufficient for state-of-the-art performance, significantly reducing context length and inference cost.
  • Mimicking Human Reasoning: The hierarchical ID approach mimics how humans navigate information—starting with broad categories and narrowing down to specific details.

Key Results

The unified approach consistently outperformed both "No RAG" (closed-book) and "Vanilla RAG" (using a standard Dense Passage Retriever).

  • On Natural Questions (NQ): Using Llama-3.1-8B, the proposed method achieved a score of 51.3, compared to 47.7 for Vanilla RAG and 28.8 for the base model.
  • On TriviaQA: The method reached 71.9, a significant jump over Vanilla RAG’s 64.1.
  • Efficiency: The model maintains high accuracy while conditioning on significantly fewer documents, addressing the "lost in the middle" problem and reducing the computational footprint of long-context processing.

Limitations and Future Work

  • Label Constraints: For TriviaQA, the authors only used the first annotated answer to save on training costs. They suggest that using all valid answers could further boost performance.
  • Scaling the Corpus: While hierarchical IDs help, the paper doesn't deeply explore the latency implications of navigating a tree containing billions of documents versus traditional vector search.
  • Training Intensity: Joint training is more computationally expensive than simply plugging a frozen retriever into a frozen LLM. The authors noted that the generation training phase took roughly double the time of the retrieval warm-up.
  • Dynamic Updates: The paper focuses on a static corpus. Future work would need to address how to efficiently update the hierarchical ID tree when new documents are added to the database without retraining the entire model.

Summary updated

Abstract

Retrieval-Augmented Generation (RAG) (Lewis et al., 2020) has become a practical solution for addressing hallucination in large language models (LLMs) by conditioning responses on retrieved documents. However, existing RAG systems face two major limitations: (1) retrieval objectives are often misaligned with the downstream generation task, leading to irrelevant documents harmful to the generation; (2) concatenating many retrieved documents into long prompts strains model capacity and introduces positional biases that degrade performance. To overcome these issues, we propose a unified framework where the LLM itself learns to perform document selection and answer generation in an end-to-end manner. Inspired by human reasoning, our model organizes documents via hierarchical semantic IDs and selects relevant content through a self-reflection mechanism composed of query-specific attention and an additional feed-forward MLP layer. This architecture enables the model to promote helpful documents directly during generation, eliminating the need for separate retrievers or rerankers. Through joint training, the model learns to select the most informative 2-3 documents. We conduct experiments to validate the effectiveness of our design.
BibTeX
@misc{di2026retrieval,
  author = {Qiwei Di and Yuhang He and Qi Chen and Quanquan Gu and Peng CHENG and Jing Bai},
  title = {{Retrieval as Reasoning: Learning to Select and Generate with LLMs}},
  year = {2026},
  url = {https://openreview.net/forum?id=NuA9XtWY6s},
  howpublished = {OpenReview},
  note = {Submitted to ICLR 2026},
}
Figure