Submitted:
24 November 2026
Posted:
25 November 2026
You are already at the latest version
Abstract
Retrieval-augmented generation (RAG) combines stochastic document retrieval with conditional answer generation. We investigate the global complexity of exactly fitting a finite stochastic document-mixture model to a rational query--answer probability table. Unrestricted exact fitting is complete for the existential theory of the reals, by an explicit normalization-preserving equivalence with exact nonnegative matrix factorization. Under corpus-constrained retrieval, fitting remains NP-complete when each query mixes at most two documents; this holds with only three answer classes and strictly positive probabilities. In contrast, one-document retrieval, two freely learned document components, and two-document retrieval with fixed component distributions admit polynomial-time solutions. We derive closed-form optimal mixing weights, an exact binary linear formulation for corpus selection, and monotone conditional optimization updates. The hardness classifications also persist for a restricted query-conditioned generator with a frozen language-model distribution and a fixed, query-dependent evidence decoder. We relate these abstractions to normalized top-K document marginalization, score-based retrieval, and finite-answer probability models, while explicitly distinguishing them from unrestricted transformer generation. The results identify global fitting barriers in a mathematically specified RAG family without claiming hardness of ordinary inference or arbitrary generative architectures.
Keywords:
retrieval-augmented generation
; stochastic document mixtures
; computational complexity
; existential theory of the reals
; sparse retrieval
; probabilistic generation
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.