Abstract
Retrieval-Augmented Generation (RAG) systems rely on complex pipelines where hyper-parameters like the number of retrieved documents ($k$), embedding models ($\mathcal{E}$), and prompt compression ratios ($C$) significantly impact performance and cost. AutoRAG-HP introduces a hierarchical multi-armed bandit (Hier-MAB) framework to automate this tuning process online. By structuring the search space into high-level categories and low-level values, AutoRAG-HP achieves optimal configurations using only 20% of the LLM API calls required by traditional exhaustive search methods.
Introduction
Building a production-ready RAG system involves more than just connecting a vector database to a Large Language Model (LLM). Modern pipelines incorporate query rewriting, document reranking, and prompt compression, each introducing hyper-parameters that create a vast search space. Traditionally, these are tuned via expensive grid searches or manual trial-and-error. AutoRAG-HP addresses this by framing hyper-parameter selection as an online optimization problem, allowing systems to self-tune based on real-time feedback.
The Challenge of RAG Optimization
The performance of a RAG system is highly sensitive to its configuration. For instance, increasing the number of retrieved documents ($k$) might improve accuracy but also increases latency and API costs. Similarly, different embedding models or compression ratios offer varying trade-offs between precision and resource consumption.
Static tuning often fails because the optimal configuration can shift as user queries evolve or as the underlying data changes. Developers need a method that is both cost-efficient and adaptive to dynamic environments.
Methodology: Hierarchical Multi-Armed Bandits
AutoRAG-HP treats hyper-parameter selection as an Online Multi-Armed Bandit (MAB) problem. In this framework, each configuration is considered an "arm" of a slot machine; the system selects an arm, observes a reward (a weighted combination of accuracy and token efficiency), and updates its strategy to maximize future rewards.
To avoid the "combinatorial explosion" of testing every possible parameter combination, the authors propose a Two-level Hierarchical MAB (Hier-MAB):
- High-Level MAB: Determines which hyper-parameter category to adjust (e.g., "Should I tune Top-k or the Compression Ratio right now?").
- Low-Level MAB: Selects the specific value within that category (e.g., "Set $k=5$").
The system utilizes the Upper Confidence Bound (UCB) algorithm to balance exploration (trying new settings) and exploitation (sticking with known high-performing settings).
Experimental Evaluation
The framework was evaluated across three distinct benchmarks: ALCE-ASQA (long-form QA), Natural Questions (NQ) (short-form QA), and Spider (Text-to-SQL). To ensure a rigorous evaluation of retrieval performance, the datasets were filtered to remove questions the LLM could answer using its internal knowledge alone.
Key Results and Insights
- Efficiency over Exhaustion: Hier-UCB reached a Recall@5 of ~0.8 while requiring roughly 80% fewer LLM calls than a full grid search.
- Superior Convergence: In multi-parameter scenarios (tuning $k$, $C$, and $\mathcal{E}$ simultaneously), the hierarchical approach showed significantly faster convergence and higher cumulative rewards compared to standard MAB or random search.
- The "Warm Start" Advantage: When upgrading models (e.g., moving from GPT-3.5 to GPT-4), the system can "continue" learning from its previous state, adapting much faster than a full reset.
- Balanced Rewards: By adjusting a weight parameter ($w$), developers can tune the system to be either "cost-central" or "accuracy-central" based on specific deployment needs.
Conclusion and Future Work
AutoRAG-HP demonstrates that online, hierarchical bandit algorithms can effectively manage the complexity of RAG hyper-parameter tuning with minimal overhead. While currently limited to discretized search spaces, future work will explore continuous optimization and the use of intermediate feedback—such as document relevance scores—to further accelerate the learning process.
Summary updated