An Analysis of Hyper-Parameter Optimization Methods for Retrieval Augmented Generation

Matan Orbach, Ohad Eytan, Benjamin Sznajder, Ariel Gera, Odellia Boni, Yoav Kantor, Gal Bloch, Omri Levy, Hadas Abraham, Nitzan Barzilay, Eyal Shnarch, Michael Factor, Shila Ofek-Koifman, Paula Ta-Shma, Assaf Toledo · OpenReview

Abstract: Finding the optimal Retrieval-Augmented Generation (RAG) configuration for a given use case can be complex and expensive. Motivated by this challenge, frameworks for RAG hyper-parameter optimization (HPO) have recently emerged, yet their effectiveness has not been rigorously benchmarked. To address this gap, we present a comprehensive study involving 5 HPO algorithms over 5 datasets from diverse domains, including a new one collected for this work on real-world product documentation. Our study explores the largest HPO search space considered to date, with three evaluation metrics as optimization targets. Analysis of the results shows that RAG HPO can be done efficiently, either greedily or with random search, and that it significantly boosts RAG performance for all datasets. For greedy HPO approaches, we show that optimizing model selection first is preferable to the prevalent practice of optimizing according to RAG pipeline order.

The RAG Optimization Challenge

Retrieval-Augmented Generation (RAG) systems are inherently modular, composed of several interdependent stages: document chunking, embedding generation, vector retrieval, and final response generation by a Large Language Model (LLM). Each stage introduces critical hyper-parameters—such as chunk size, overlap, embedding model choice, and the number of retrieved documents (Top-K)—that significantly influence the system's final accuracy.

The RAG pipeline and its associated hyper-parameters.

Traditionally, finding the "best" configuration has been a manual, expensive process of trial and error. Because these parameters interact in complex ways, a change in the embedding model might necessitate a different Top-K value or chunking strategy. This study aims to move beyond manual tuning by rigorously benchmarking automated Hyper-Parameter Optimization (HPO) frameworks.

Experimental Framework

To establish a robust baseline, the researchers conducted an exhaustive grid search across 162 unique RAG configurations. They then evaluated five distinct HPO strategies to see how quickly they could converge on near-optimal performance:

  1. Random Search: A baseline approach of sampling configurations randomly.
  2. TPE (Tree-structured Parzen Estimator): A Bayesian optimization method that learns from previous trials.
  3. Greedy-R (Retrieval-first): Optimizes parameters sequentially following the data flow (Embedding → Chunking → Generation).
  4. Greedy-M (Model-first): Prioritizes the selection of the Generative LLM and Embedding model, assuming these high-impact components should be locked in first.
  5. Greedy-R-CC: A variant of retrieval-first that uses a low-cost "context correctness" metric to pre-optimize the retrieval stage.

These methods were tested across five diverse datasets: AIArxiv (technical QA), BioASQ (biomedical), MiniWiki (factoid), ClapNQ (long-form), and WatsonxQA—a new, open-sourced dataset introduced in this paper based on enterprise product documentation.

Key Results: Efficiency and Performance Gains

The study reveals that RAG HPO is remarkably effective. Across all datasets, automated optimization yielded performance improvements of up to 20% compared to unoptimized baselines. Crucially, this optimization does not require exhaustive search.

Performance of various HPO algorithms across different datasets and metrics over 10 iterations.

As shown in the performance curves above, most HPO algorithms—particularly Greedy-M and even Random Search—were able to match the performance of a full grid search within just 10 iterations. This represents a massive reduction in computational cost, especially when combined with the finding that optimizing on just 10% of the development data generalizes well to the full test set.

Strategic Insights

The "Model-First" Advantage

One of the most significant findings is that the order of optimization matters. While it is intuitive to follow the pipeline's data flow (Retrieval first), the Greedy-M (Model-first) approach proved more efficient. By selecting the most capable generative LLM early, the HPO process stabilizes faster, as the LLM has the most substantial impact on the final answer correctness.

Metric Sensitivity and Generalization

The choice of evaluation metric—whether LLM-as-a-Judge (e.g., RAGAS) or lexical overlap—can lead to different "optimal" configurations. For instance, Llama-3.1-8B often excelled under LLM-based evaluation, while models like Granite or Mistral performed better on lexical metrics. This highlights the need for practitioners to align their HPO objective with their specific end-user requirements and business goals.

Conclusion

This research demonstrates that RAG performance can be significantly and efficiently boosted through automated HPO. By employing a "model-first" greedy strategy or even simple random sampling, developers can find near-optimal configurations in a fraction of the time and cost required for grid searches. Future work will look to extend these findings to more complex agentic workflows and multi-modal RAG architectures.

Summary updated

BibTeX
@misc{orbach2025analysis,
  author = {Matan Orbach and Ohad Eytan and Benjamin Sznajder and Ariel Gera and Odellia Boni and Yoav Kantor and Gal Bloch and Omri Levy and Hadas Abraham and Nitzan Barzilay and Eyal Shnarch and Michael Factor and Shila Ofek-Koifman and Paula Ta-Shma and Assaf Toledo},
  title = {{An Analysis of Hyper-Parameter Optimization Methods for Retrieval Augmented Generation}},
  year = {2025},
  eprint = {2505.03452},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.03452},
}
Figure