Introduction
Retrieval-Augmented Generation (RAG) has become a cornerstone of modern Large Language Model (LLM) applications, providing models with external knowledge to ground their outputs. However, traditional RAG systems typically rely on "top-k" retrieval, where documents are selected independently based on their individual similarity to a query. While effective for simple fact-seeking, this approach often fails in compositional tasks—such as semantic parsing or complex logical reasoning—where an LLM requires a diverse set of structural patterns to assemble a correct solution.
When documents are retrieved independently, the resulting context often contains redundant information, where multiple examples demonstrate the same logic while leaving other necessary components unaddressed. This paper introduces Reinforcing Compositional Retrieval (RCR), a method that reframes retrieval as a sequential "game" or Markov Decision Process (MDP). In RCR, each piece of evidence is chosen specifically to complement the information already gathered, ensuring a high-utility, non-redundant context for the downstream LLM.
The Methodology: Reinforcing Compositional Retrieval
RCR moves away from static similarity-based retrieval in favor of a two-stage framework designed to optimize the collective utility of the retrieved set.
1. Tri-encoder Architecture
To facilitate sequential decision-making, the authors developed a specialized tri-encoder architecture. Unlike standard bi-encoders that only compare a query and a candidate, the tri-encoder utilizes three distinct components:
- Query Encoder: Captures the original intent of the user.
- Context Encoder: Maintains a "memory" of the examples already selected in previous steps.
- Candidate Encoder: Evaluates potential new additions from the document pool.
This architecture allows the model to actively seek out candidates that fill "gaps" in the current context. Furthermore, the design is computationally efficient; the query embedding is computed once, and each subsequent step only requires encoding the newly selected item, resulting in linear $O(n)$ scaling relative to the number of retrieval steps.
2. Stage 1: Supervised Fine-Tuning (SFT)
The model is first initialized using a greedy "coverage" strategy. During this stage, the retriever is trained to select examples that maximize "local structure coverage"—essentially identifying sub-trees of the logical programs required for the ground-truth answer. This provides the retriever with a strong baseline policy for identifying relevant structural building blocks without the need for expensive LLM inference during early training.
3. Stage 2: Reinforcement Learning (GRPO)
To further refine the retriever, the authors employ Group Relative Policy Optimization (GRPO). This stage aligns the retriever with the specific preferences and behaviors of the target LLM. The retriever (the actor) proposes groups of examples, and a reward is assigned based on the downstream LLM’s actual performance. By grounding rewards in the structural similarity between the LLM’s output and the ground truth, RCR learns to compose contexts that are not just theoretically diverse, but practically useful for the model's inference process.
Experimental Evaluation
The researchers evaluated RCR on two primary benchmarks focused on compositional generalization:
- GeoQuery: A dataset of 880 U.S. geography questions. The evaluation focused on "Template," "TMCD," and "Length" splits, which are specifically designed to test how models handle logical structures not seen during training.
- COVR-10: A synthetic dataset using a variable-free functional language to test complex compositional grammar across 10 distinct splits.
Key Results
- State-of-the-Art Performance: RCR consistently outperformed traditional top-k retrievers (such as BM25 and BERT) and existing sequential retrievers (like $se^2$). On the GeoQuery "Template 1" split, RCR achieved an accuracy of 59.64%, a significant leap over BM25 (40.36%) and $se^2$ (30.42%).
- The Power of Quality over Quantity: One of the most striking findings was that RCR with only 4 carefully chosen examples (78.21% accuracy) outperformed "many-shot" approaches using 100 or 150 examples (approximately 63%). This demonstrates that the strategic composition of context is far more valuable than simply increasing the volume of data provided to the LLM.
- Optimal Context Size: Performance was found to peak at approximately 4 retrieval steps. Beyond this point, additional examples often introduced noise or redundancy, which actually degraded the LLM's performance.
Discussion and Insights
The success of RCR highlights the importance of Collective Utility. In compositional tasks, the value of a retrieved set is greater than the sum of its parts. A set of examples that are individually less similar to the query but collectively cover all necessary logical components is significantly more effective than a set of highly similar but redundant examples.
However, the method does face certain limitations. As a dense retrieval method, RCR relies on static indexing; incorporating new entries into the search pool may require re-training or fine-tuning the encoders. Additionally, like many sequential processes, RCR can suffer from "compounding errors," where a poor choice early in the sequence makes it difficult for the model to recover in later steps.
Conclusion
Reinforcing Compositional Retrieval represents a significant shift in how we approach context construction for RAG. By treating retrieval as a coordinated, step-by-step process and using reinforcement learning to align the retriever with the LLM, RCR achieves superior performance with significantly smaller context windows. Future work may explore more scalable mechanisms to maintain stability over even longer sequences of evidence gathering and dynamic index updates.
Summary updated