To address the difficulty of efficiently optimizing the quality-performance trade-offs arising from the many configuration choices in RAG deployment, this paper proposes the RAG-Stack framework, which can find the quality-performance Pareto frontier of RAG systems across the full algorithm and system design space without deploying all candidate configurations.
Retrieval-augmented generation (RAG), which supplements the generation process of large language models by retrieving information from a database, has become the mainstream implementation approach for knowledge-intensive applications. However, modern RAG systems involve a large number of configuration choices spanning multiple dimensions, including retrieval indexes, model selection, and how models invoke retrieval. Different configurations form entirely different trade-offs between answer quality and service performance, which poses a significant challenge to selecting the optimal configuration for a specific application deployment scenario.
Manually achieving joint quality and performance optimization in RAG scenarios is clearly difficult, and extensive measured results show that the trade-off relationships often defy developer intuition: an agentic ReAct pipeline can achieve faster response times than a sequential pipeline at only a small quality cost, and query expansion sacrifices throughput for quality gains—but such quality gains hold only under some configurations, and even switching to a larger generation model does not always improve answer quality.
In fact, all parameters related to answer quality Q change the logical computation path of the RAG service, and therefore necessarily affect service performance P, satisfying the containment relation ; there are no purely quality-related parameters that are entirely independent of performance effects.
In the traditional full-deployment measurement approach, the full configuration space that must be traversed is the Cartesian product of the algorithm configuration space and the system configuration space that only affects performance, where contains all parameters that affect both Q and P, and contains all parameters that affect only P.
The proposed RAG-Stack is an efficient co-optimization framework for RAG service deployment. Without deploying every candidate configuration one by one to measure actual performance, it covers the complete algorithm and system design space and solves for the quality-performance Pareto frontier of the RAG system. The framework directly addresses the core limitation of existing approaches, which cannot jointly optimize answer quality and service performance over the full design space.
RAG-PE builds on traditional multi-objective Bayesian optimization (MOBO) by extending it with stage-aware diagnostics, heterogeneous candidate generation, and global arbitration, making the configuration exploration process more targeted while retaining end-to-end Pareto optimization. The necessity of this design stems from the inseparability of stage effects in RAG pipelines: the benefit of adjusting a single stage depends heavily on the configuration choices of other stages, so a greedy stage-by-stage optimization strategy will miss configurations that perform well only as a complete pipeline, while traditional composite-function Bayesian optimization assumes the final objective is a known function of intermediate outputs and cannot adapt to the characteristics of RAG scenarios.
RAG-IR serves as an intermediate representation layer, bridging the quality assessment module and the RAG-CM cost model. Its design has two core properties: first, system independence—it fully decouples the logical workload from the specific deployment plan, allowing RAG-CM to search deployment options independently and recompute the cost of the same workload on new hardware without actually running the workload; second, RAG-workflow independence—a unified encoding paradigm supports both sequential and agentic RAG pipelines, so RAG-PE can freely explore different workflow structures while RAG-CM does not need to write dedicated modeling logic for each workflow.
RAG-CM predicts configuration performance through a four-layer structure, obtaining performance metrics over the full configuration space without actual deployment: the first layer, the algorithm layer, generates hardware-independent operator work profiles for each RAG stage; the second layer, the performance layer, maps each operator work profile to actual runtime on the corresponding host; the third layer, the communication layer, computes the cost of data transfers between operators; and the fourth layer, the assembly layer, traverses the system design space and combines the outputs of the first three layers to obtain throughput and latency metrics for each algorithm-system configuration.
In the end-to-end co-optimization task, RAG-Stack was compared against GP+LogNEHVI, the strongest baseline on both datasets. On the RAGEval dataset, its average hypervolume is 0.514 versus 0.364 for the baseline; on the MS MARCO dataset, its average hypervolume is 0.635 versus 0.259 for the baseline, corresponding to per-seed relative improvements averaging 52.5% and 153.2% respectively. Across all six seed-dataset pairs, RAG-Stack's per-seed hypervolume exceeds that of the strongest baseline. Readers can refer to the figure below to observe the distributions of log-scale QPS versus answer relevance quality on the two datasets.
For a performance model that guides the search of the system space, preserving the relative ranking priority between configurations is more valuable than minimizing absolute prediction error. On two different systems, the calibrated RAG-CM achieves Spearman correlation coefficients of 0.968 to 0.978 for latency and QPS, with overall mean absolute percentage errors kept between 11.2% and 15.3%. Even for the random-access-intensive IVF-PQ-FS and HNSW index structures, where the mean absolute percentage error rises to 20.1%, the Spearman correlation coefficient remains no lower than 0.977, indicating that the remaining prediction errors essentially do not disturb the relative ranking of configurations and can provide reliable ranking signals to support RAG-PE's optimization process.
In the cross-system transfer scenario, with the same evaluation budget of 20, the uncalibrated transfer approach improves normalized hypervolume by 108.4% over optimization from scratch, and the calibrated transfer approach improves normalized hypervolume by 182.2% over optimization from scratch.
Currently, RAG-Stack's support for agentic RAG uses a trace-driven mode: RAG-IR must fully execute the pipeline and observe the runtime control flow before RAG-CM can complete the performance prediction for the corresponding configuration.
This mechanism brings clear capability boundaries: on one hand, RAG-PE cannot densely sample the performance objective before the quality assessment stage, and cannot leverage multi-task Gaussian processes to use a large number of performance-only observations to improve sampling efficiency; on the other hand, the framework cannot filter out configurations that violate the service level agreement before they enter the candidate screening pool.
The research team has already implemented a static RAG-IR and RAG-CM path that requires no execution traces for sequential RAG scenarios where the control flow can be directly determined by the configuration, while extending this pre-execution-free performance prediction capability to agentic RAG scenarios remains explicitly stated future work in the paper.