Multi-Constraint Quantum Document Selection for Retrieval-Augmented Generation: An Empirical Study of Classical, Annealing, and Gate-Based Quantum Solvers
Retrieval-Augmented Generation (RAG) systems typically select context documents using greedy nearest-neighbor search, which optimizes each documentindependently and ignores combinatorial interactions between retrieved items. Wepresent TaxQRAG, the first open-source quantum-hybrid RAG system evaluatedon real quantum hardware for multi-strategy document selection under explicitpairwise interaction constraints. Unlike prior work, our QUBO (Quadratic Unconstrained Binary Optimization) formulation incorporates three novel quadratic terms:domain-specific pairwise synergy rewards, conflict penalties, and audit risk compounding — enabling selection of document subsets that are jointly optimal ratherthan individually relevant. Applied to a tax strategy corpus (87 documents; IRS publications, Internal Revenue Code sections, and structured strategy documents), wecompare four solvers: classical greedy, simulated annealing (SA), QAOA on a localsimulator (Aer), and QAOA on IBM Quantum’s Heron R2 processor (ibm_fez,156 qubits). SA achieves a 173% improvement in combination quality score overclassical greedy with zero conflict selections. QAOA without parameter optimization produces a 66.7% conflict rate, which a λ ablation study confirms is caused byunoptimized variational parameters rather than QUBO encoding deficiency — anegative result that motivates VQE-optimized QAOA as future work. We furtherconduct the first QAOA parameter sensitivity analysis for RAG document selection,finding that combination quality coefficient of variation reaches 88.2% acrossrandom seeds, and that Ising energy and downstream combination score divergesignificantly at shallow circuit depth. Code, benchmark data, and IBM Quantumjob identifiers are released at https://github.com/joerein-iu/taxqrag.
Retrieval-Augmented Generation (RAG) systems typically select context documents using greedy nearest-neighbor search, which optimizes each documentindependently and ignores combinatorial interactions between retrieved items. Wepresent TaxQRAG, the first open-source quantum-hybrid RAG system evaluatedon real quantum hardware for multi-strategy document selection under explicitpairwise interaction constraints. Unlike prior work, our QUBO (Quadratic Unconstrained Binary Optimization) formulation incorporates three novel quadratic terms:domain-specific pairwise synergy rewards, conflict penalties, and audit risk compounding — enabling selection of document subsets that are jointly optimal ratherthan individually relevant. Applied to a tax strategy corpus (87 documents; IRS publications, Internal Revenue Code sections, and structured strategy documents), wecompare four solvers: classical greedy, simulated annealing (SA), QAOA on a localsimulator (Aer), and QAOA on IBM Quantum’s Heron R2 processor (ibm_fez,156 qubits). SA achieves a 173% improvement in combination quality score overclassical greedy with zero conflict selections. QAOA without parameter optimization produces a 66.7% conflict rate, which a λ ablation study confirms is caused byunoptimized variational parameters rather than QUBO encoding deficiency — anegative result that motivates VQE-optimized QAOA as future work. We furtherconduct the first QAOA parameter sensitivity analysis for RAG document selection,finding that combination quality coefficient of variation reaches 88.2% acrossrandom seeds, and that Ising energy and downstream combination score divergesignificantly at shallow circuit depth. Code, benchmark data, and IBM Quantumjob identifiers are released at https://github.com/joerein-iu/taxqrag.
Generating correct and executable quantum circuit code remains a significant barrier for both newcomers and experienced practitioners in quantum computing. While Large Language Models (LLMs) have shown promise in classical code generation, their application to quantum programming is hampered by limited domain-specific training data and the rapidly evolving nature of quantum software frameworks. In this work, we present Quantum-RAG, an extended Retrieval-Augmented Generation framework that couples a domain-specialized language model with a curated, multi-source knowledge corpus to produce Qiskit-based quantum circuit code. Our three-stage pipeline ingests documentation, educational notebooks, and research literature into a dense retrieval index and augments the generation model with the most relevant context at inference time. Evaluated on the Qiskit HumanEval benchmark, QuantumRAG achieves a Pass@1 of 0.4132, a Pass@3 of 0.6291, and a Pass@5 of 0.7020, surpassing the domain-adapted GraniteQiskit baseline by 101%, 72%, and 47 % at each respective threshold. These results demonstrate that retrieval-augmented approaches can substantially improve quantum code generation without expensive model retraining.
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 byS=1024and 1.000 at the exact-fidelity limit, tracking the expectedO(1/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 atd=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 atd=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.
Although the performance of LLMs on a wide variety of natural language processing problems demonstrates remarkable ability, hallucinated responses are introduced as one of the key weaknesses of LLMs, especially in knowledge-intensive applications, where fidelity to facts is paramount. While effective in reducing hallucinations, the context retrieved during the RAG operations is still very often suboptimal with respect to the external documents used in the retrieval stage, and being based on cosine similarity and nearest-neighbour search, these models typically do not return optimal context to support factual generation. The authors propose a five-stage solution, called Quantum-Enhanced Retrieval-Augmented Generation (QERAG), which combines the use of a quantum-inspired probability amplitude document ranking, a Context Utility Score (CUS) optimisation engine, and a Hallucination Verification Agent (HVA) based on a formal Hallucination Reduction Index (HRI). The Quantum Relevance Score (QRS) uses interference based, Amplitude Encoding on candidate Document Sets to yield a normalised relevance distribution that emphasises the relatively higher value generated in the discriminative context as compared to other locally similar passages in a document set. QERAG outperforms Standard LLM and Traditional RAG models on all five Natural benchmark across response accuracy, with a score of 92.8% vs. 74.3%, and hallucination rate, 4.3% vs. 18.2%, respectively. They achieve a significant overall improvement by using quantum-inspired retrieval layer, which achieves a 3.5-percentage-point reduction in hallucination rate when compared to cosine-similarity RAG, with this single layer showing more reduction than the rest of the pipeline layers. The results of an ablation study show the individual contribution of every pipeline stage, and the quantum-inspired retrieval layer exhibits the greatest reduction of a 3.5 percentage points over cosine-similarity RAG.
Large-scale combinatorial optimization is a challenge for near-term quantum computing because dense Quadratic Unconstrained Binary Optimization (QUBO) formulations yield interaction graphs that exceed the limits of NISQ processors. This work introduces Hybrid Quantum Neighborhood Selection (HQNS), a hybrid framework mitigating this via stochastic frontier decomposition. Instead of encoding all N variables into a monolithic circuit, HQNS selects a compact frontier of F << N active variables per stage, freezing the rest into reduced QUBO coefficients. A multi-stage crawling procedure rotates these frontiers, letting local quantum subproblems refine a global solution. We evaluate HQNS on the Maximum Diversity Subset Selection Problem (MDSSP) across six scales, N up to 1000. Circuit burden is reduced from the dense QAOA requirement of O(N^2) two-qubit terms per layer to O(F^2) per stage, with total complexity governed by the number of stages and classical overhead. Benchmarks show that HQNS achieves competitive solution quality relative to parallel simulated annealing (SA) while maintaining bounded circuit width and stable QPU time. In the N=1000 benchmark over ten executions, HQNS preserves 99.9908% of the mean diversity score of an 11-restart parallel SA baseline, while reducing wall-clock time by 65.03%, peak CPU usage by 55.97%, and peak memory by 35.21%. Ablation shows performance depends on frontier size, warm-starts, CVaR filtering, and stochastic rotation. These results demonstrate that structured frontier decomposition makes variational optimization executable for dense QUBO instances unsuitable for direct QAOA on present hardware.
Full-pipeline benchmark of the Quantum Approximate Optimization Algorithm (QAOA) against classical combinatorial solvers on a weighted Max-Cut formulation of exam-scheduling conflict minimization. Compares random assignment, greedy heuristic, 2-opt local search, exact ILP (OR-Tools), and QAOA — first via noisy local simulation on an 18-qubit validation subset, then via live execution on IBM's ibm_marrakesh (Heron r2) processor at the full 42-qubit scale. Uses shot-weighted expected-value scoring throughout rather than best-observed-sample reporting. At 18 qubits QAOA reaches 95.4% of the proven optimum; at 42 qubits the hardware run's expected value falls below random guessing (49.05% vs 50.00%), with all 4,096 shots returning distinct bitstrings — the signature of decoherence overwhelming the circuit. Includes causal analysis of the failure mode and outlines planned comparison against quantum annealing hardware.
Constrained portfolio selection in drug repurposing (choosing subsets of approved compounds that jointly satisfy interaction avoidance, toxicity ceilings, and target-coverage requirements) remains intractable for classical integer programming beyond ∼10,000 candidates, precisely the regime where combinatorial drug repositioning operates. Existing quantum formulations address pairwise drug-combination scoring but do not account for portfolio-level constraints or the mismatch between problem graph structure and physical qubit connectivity. We introduce a three-stage pipeline: a relational graph convolutional network (RGCN) narrows the candidate pool to ∼5,000 triples, a QUBO encoding extends the Complementary-Exposure framework [6], [36] with budget, diversity, and multitarget coverage penalties, and a topology-aware QAOA compiler maps constraint blocks onto natively connected heavy-hex qubit clusters. The compiler reduces two-qubit SWAP-gate counts by 23-41% relative to Qiskit optimization-level-3 transpilation on sub-problems of 20-100 qubits (Table IV), directly lowering accumulated gate error on IBM Heron r2 hardware. Retrospective validation on ten FDA-approved repurposed drugs yields 82.5% Recall@100 on a noiseless simulator versus 79.3% for ILP/Gurobi; on real IBM Heron hardware, recall drops to 69.8% (approximation ratio 0.64), falling 9.5 percentage points behind ILP and quantifying the noise gap that future errorcorrected processors must close. The central finding is negative: at current NISQ fidelities, classical ILP produces strictly superior solutions in less wall-clock time. The contribution is therefore architectural, not algorithmic; the topology-aware compilation strategy transfers directly to improved processors without redesign, positioning the pipeline for the p ≤ 10 −4 gate-error regime projected for 2028-2030. Code and QUBO encodings will be released upon acceptance.