OpenRAG: Optimizing RAG End-to-End via In-Context Retrieval Learning

Jiawei Zhou, Lei Chen

TL;DR

Traditional information retrieval (IR) metrics don't reflect what large language models (LLMs) actually need in retrieval-augmented generation (RAG). OPEN-RAG bridges this gap by training a lightweight 0.2B retriever end-to-end using feedback from the LLM, bypassing the massive compute overhead of corpus re-indexing and autoregressive generation. Tuning just the retriever yields a 4.0% average accuracy boost—often beating computationally expensive 8B LLM fine-tuning.

What Problem Does This Paper Address?

Most RAG systems pipe off-the-shelf neural retrievers (e.g., DPR, Contriever, E5) directly into an LLM without joint training. However, what is "relevant" in traditional IR does not always match what is useful in RAG:

  1. The In-Context Relevance Gap: In IR, retrieved documents are shown to human users, so containing the exact answer string denotes success. In RAG, documents serve as context for an LLM. An answer-containing document might confuse the generator, while a document without direct answers might provide crucial background reasoning.
  2. Computational Bottlenecks in End-to-End Tuning: Prior attempts to train retrievers end-to-end against LLMs face severe bottlenecks. Generating responses autoregressively to compute rewards is too slow, and updating retriever parameters typically requires frequently re-indexing millions of Wikipedia passages.

Methods

OPEN-RAG optimizes the retriever against the LLM end-to-end in under a day using four A100 GPUs through three key design choices:

[Query + Doc] ──> Single LLM Forward Pass ──> RAG Score (Likelihood)
                         │
                         ▼
             Approximate Positive / Negative
                         │
                         ▼
        Contrastive Loss on Semi-Parametric Retriever (SiDR)
             (No full corpus re-indexing required!)
  • Offline Warmup & Threshold Calibration: For each training query, the system retrieves top candidates using the initial retriever, generates full responses with the LLM to assign ground-truth binary RAG Labels (task success/failure), and calculates RAG Scores (the sequence likelihood $P_\phi(y \mid x)$ using a single LLM forward pass). This stage determines score thresholds separating positive and negative contexts.
  • Online Contrastive Sampling via Score Approximation: During online training, OPEN-RAG avoids slow multi-token autoregressive generation. Instead, it approximates labels on-the-fly: documents whose single-pass likelihood exceeds offline negative thresholds become positive samples, while low-likelihood documents become hard negatives.
  • Re-index-Free Retrieval with SiDR: Rather than rebuilding a dense index whenever the retriever updates, OPEN-RAG leverages the semi-parametric retriever SiDR. It performs first-stage search over a fixed, non-parametric bag-of-tokens index, followed by an on-the-fly parametric re-ranking of top-$m$ documents ($m=20$).
  • Contrastive Optimization: The retriever is updated using InfoNCE-style contrastive loss, pulling the query closer to LLM-beneficial documents and pushing it away from misleading distractors.

Datasets

The authors evaluate OPEN-RAG using an English Wikipedia corpus across four standard benchmarks:

  • Free-form OpenQA: Natural Questions (NQ) and TriviaQA (TQA).
  • Closed-set Fact-Checking: PubHealth (verifying biomedical claims).
  • Closed-set Multi-choice Reasoning: ARC-Challenge (grade-school science questions).

Note: No new datasets were introduced; the authors used established public benchmarks and standard evaluation prompts.

Key Insights and Ideas

  • IR Gains $\neq$ RAG Gains: Improving a retriever for standard IR benchmarks does not guarantee better RAG performance. In fact, after OPEN-RAG fine-tuning, retrieval accuracy under traditional IR metrics occasionally decreased even as downstream generation accuracy significantly improved.
  • Tuning the Retriever Beats Tuning the LLM: A 0.2B parameter retriever tuned via OPEN-RAG outperformed 8B parameter instruction-tuned or RAG-tuned models (like Self-RAG). Small retrievers offer a much higher return-on-compute when adapting to domain-specific context needs.
  • LLM Generative Distributions are Too Complex for Distillation: Replacing contrastive learning with KL-divergence (matching the retriever score distribution directly to LLM generation probabilities, as in REPLUG) plateaued early. Bi-encoders struggle to capture the full probability distribution of large generative models; hard positive/negative discrimination works significantly better.
  • Limited Cross-Model Transfer on Closed-Set Tasks: Retrievers tuned on free-form QA transfer reasonably well across LLM backbones (e.g., Llama-3 to Mistral). However, for closed-set tasks where labels consist of single tokens, retrievers heavily overfit to the exact next-token calibration of the specific base LLM, requiring model-specific tuning.

Key Results

  • Overall Performance: OPEN-RAG achieved an average +4.0% absolute improvement over the base $\text{SiDR}_{\text{MS}}$ retriever and beat strong SOTA retrievers (such as E5 and Contriever) by +2.1%.
  • Task-Specific Gains:
  • PubHealth: Showed the largest single-document jump, rising from 63.5% to 69.5% (+6.0%), outperforming instruction-tuned LLM baselines.
  • Natural Questions: Top-1 context accuracy increased from 34.4% to 39.8% (+5.4%).
  • TriviaQA: Rose from 62.0% to 65.8% (+3.8%).
  • ARC-Challenge: Modest gain from 56.9% to 58.1% (+1.2%), constrained by ARC's small training set.

Limitations and Future Work

  • Task Generalization & Transferability: The learned relevance for closed-set tasks does not transfer reliably across different LLMs, meaning the retriever must be retrained whenever the generator backbone changes.
  • Scope of Likelihood Approximation: Approximating labels via single-pass token likelihood works well for short answer strings and classification, but breaks down for open-ended, long-form text generation.
  • Data Scarcity: Datasets with small training splits (e.g., ARC-Challenge with only a few hundred samples) yield diminished returns.

Summary updated

BibTeX
@inproceedings{zhou2025openrag,
  author = {Jiawei Zhou and Lei Chen},
  title = {{OpenRAG: Optimizing RAG End-to-End via In-Context Retrieval Learning}},
  booktitle = {Data Problems @ ICLR},
  year = {2025},
  url = {https://openreview.net/forum?id=myhssp1INs},
}
Figure