A Hybrid Quantum Fidelity-Based Semantic Retrieval Framework for Retrieval-Augmented Generation
J. Senthilkumar, D.R. Karthika
Abstract
Retrieval-Augmented Generation (RAG) improves LLM factual accuracy via external retrieval, but existing frameworks rely on cosine similarity, leaving quantum overlap-based measures such as fidelity largely unexplored. QF-RAG is a hybrid quantum-classical retrieval architecture that estimates Quantum Fidelity Similarity (QFS) between amplitude-encoded embeddings via a Swap Test. Because fidelity equals squared cosine similarity for real unit vectors, QFS is fundamentally a score transformation, and we evaluate it entirely on real, handauthored text rather than synthetic vectors: 63 factual passages across 16 real-world topics (paraphrases, hard negatives, and noise documents) and 42 queries (standard, ambiguous, multihop), embedded with real TF-IDF vectors that are mean-centered so cosine similarity can take negative values, as dense embeddings do in practice. On this real corpus, 69.9% of query-document cosine similarities are negative, yet cosine and exact QFS agree on the Top-1 result for every query and produce identical Precision@5, Recall@5, MRR, and nDCG@5 to three decimal places, confirming that QFS preserves cosine's ranking quality on real text. With sufficient Swap Test shots, QFS recovers this same ceiling: MRR reaches 0.951 by$\mathrm{S}=1024$and 1.000 at the exact-fidelity limit, tracking the expected$\mathrm{O}(1 / \sqrt{ } \mathrm{S})$estimator convergence. A retrieval-to-generation test on the same real passages shows retrieval quality causally propagating to answer accuracy (93.8% at k=1). We further complement asymptotic complexity analysis with numbers computed and measured endto- end in code: an unoptimized amplitude-encoding synthesis needs O(d2) CNOT gates (349,525 at$\mathrm{d}=768)$, and we verify a tighter O(d) optimized bound (1,022), with exact memory accounting and a measured, extrapolated simulator runtime of 19.6 s per pair for state preparation at$\mathrm{d}=768$, dropping to 0.057 s with the optimized construction. QF-RAG is positioned as a rigorously specified, empirically evaluated hybrid architecture and evaluation framework for bringing quantum overlap measures into RAG retrieval, with a clear, quantified resource profile for near-term hardware.