StitchRAG:通过基于扩散的拼接为 RAG 构建紧凑且保留证据的上下文
摘要
StitchRAG提出了一种RAG上下文压缩框架,通过效用最大化动态分配各段落的压缩比,抽取锚定句后用文本扩散将其拼接为紧凑且保留证据的连贯上下文,在五个开放域QA基准上优于多步与压缩基线。
查看缓存全文
缓存时间: 2026/11/19 08:57
# StitchRAG: Constructing Compact and Evidence-Preserving Contexts for RAG with Diffusion-Based Stitching
Source: [https://arxiv.org/html/2611.22766](https://arxiv.org/html/2611.22766)
Junpyo LimAffiliation:Korea UniversityHeeje ChoAffiliation:Korea UniversitySeungjun Baek††thanks:Corresonding AuthorAffiliation:Korea University
###### Abstract
Retrieval\-augmented generation \(RAG\) improves factuality by grounding large language models \(LLMs\) in external evidence\. However, long retrieved contexts incur computational overhead and can even hurt performance due to noisy or irrelevant content\. We proposeStitchRAG, a framework for constructing compact context in RAG\.StitchRAGbuilds a faithful, information\-dense context while dynamically compressing the retrieved passages\. We adapt the size reduction ratio to each passage by formulating a utility maximization trading\-off the retained information and computation costs\. We then extract answer candidates and query\-related keywords from passages as anchors and collect passage sentences containing anchors under the derived size constraint\. Finally, we connect or stitch the collected sentences together using text diffusion to form a coherent and natural context\. Experiments on five open\-domain QA benchmarks show thatStitchRAGconsistently outperforms diverse multi\-step and compression baselines\. Extensive ablations show the effectiveness of dynamic size allocation, anchor preservation, and diffusion\-based stitching\.
## 1Introduction
Large language models \(LLMs\)[Achiam et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib21);[Huang et al\. \(2024\)](https://arxiv.org/html/2611.22766#bib.bib4)have rapidly advanced and enabled a wide range of real\-world applications\. However, they face fundamental limitations: updating their knowledge is costly, and LLMs often hallucinate responses that are plausible but incorrect[Welleck et al\. \(2019\)](https://arxiv.org/html/2611.22766#bib.bib32);[Kalai et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib35)\. Retrieval\-augmented generation \(RAG\) addresses these issues by grounding generation on external evidence retrieved at inference time[Chen et al\. \(2017\)](https://arxiv.org/html/2611.22766#bib.bib20);[Lewis et al\. \(2020\)](https://arxiv.org/html/2611.22766#bib.bib16)\. By conditioning on retrieved passages, RAG improves factuality and enables easy updates with up\-to\-date information\.
Figure 1:Constructing Compact Context\.From retrieved passages, StitchRAG extracts and preserves sentences containing key terms\. Then it connects them via diffusion\-based stitching to construct a compact context\.A growing body of work improves RAG via advanced retrieval and generation loops, including multi\-step reasoning[Trivedi et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib6);[Kim et al\. \(2024b\)](https://arxiv.org/html/2611.22766#bib.bib36), self\-reflection[Jiang et al\. \(2023b\)](https://arxiv.org/html/2611.22766#bib.bib7);[Asai et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib5), and multi\-agent debate or verification[Du et al\. \(2024\)](https://arxiv.org/html/2611.22766#bib.bib27);[Hu et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib9), in order to reduce hallucinations and strengthen reasoning\. However, these methods primarily focus on iterative retrieval or post hoc verification, while largely leaving the context constructed from retrieved passages unconstrained\. As a result, the context often accumulates redundant or conflicting evidence\. Such longer or repeatedly processed contexts also increase inference latency and computational cost\. More importantly, even with strong retrievers, simply providing more evidence does not reliably improve answers: LLMs can be confused by noisy passages and long inputs[Liu et al\. \(2024\)](https://arxiv.org/html/2611.22766#bib.bib1);[Hong et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib3);[Du et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib2)\.
This has motivated substantial interest in*context engineering*[Mei et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib33);[Hua et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib34)for RAG, which helps models better interpret the retrieved contexts\. Context compression methods, such as selection[Li et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib12)and compression prior to generation[Pan et al\. \(2024\)](https://arxiv.org/html/2611.22766#bib.bib30);[Xu et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib11), reduce the inference cost and latency by shortening the input length\. However, most existing approaches rely on fixed or heuristic compression ratios, largely independent of the query, passage quality, or reasoning complexity\. In practice, a good compression should be context\-dependent: some questions require preserving long, cross\-passage evidence chains, whereas others benefit from aggressively filtering irrelevant content\. Consequently, applying a single global compression ratio to all passages can create a mismatch between the context reduction and the information needs of each problem\. Moreover, because prior compression methods typically operate at the token level rather than preserving original sentences, they often degrade the readability of contexts and thus the overall performance of RAG\.
Contribution\.We proposeStitchRAG, a framework for constructing compact contexts for RAG\.StitchRAGdynamically retains evidence in retrieved passages for size reduction and reconstructs a coherent context from preserved evidence\. We formulate evidence retention as a constrained optimization problem: we maximize relevance utility combined with a computation\-aware penalty to derive a closed\-form retention ratio for each retrieved passage\. This enables a dynamic adjustment of the retention ratio to each passage, improving the efficiency and relevance of the constructed context\. To build a compact yet readable context, we introduce hybrid anchor selection and diffusion\-based stitching\. Anchors are defined as key terms for the query, and sentences containing anchors are preserved in the context as fixed evidence\. Next, we perform*context stitching*, which connects fragmented sentences using text diffusion in order to restore coherence of the generated context\. The proposed refinement enables faithful context reconstruction while reducing factual drift and hallucination\. In our experiments,StitchRAGconsistently improves the RAG performance over baseline methods\. Extensive ablations confirm the importance of dynamic context retention, anchor preservation, and diffusion\-based stitching\.
## 2Related Work
Advanced RAG and Multi\-step Retrieval/Generation\.Recent work has exploredmulti\-stepandadaptivestrategies that couple retrieval with intermediate reasoning steps\. IRCoT[Trivedi et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib6)interleaves reasoning traces with retrieval, enabling sequential evidence acquisition for multi\-hop questions\. FLARE[Jiang et al\. \(2023b\)](https://arxiv.org/html/2611.22766#bib.bib7)triggers retrieval based on token\-level uncertainty during generation, while Self\-RAG[Asai et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib5)incorporates self\-reflection to assess retrieved evidence and adapt the generation accordingly\. SuRe[Kim et al\. \(2024a\)](https://arxiv.org/html/2611.22766#bib.bib8)is a multi\-stage framework that generates answer candidates and summarizes retrieved passages conditioned on each candidate, then ranks candidates by verifying the resulting summaries\. More recently, DRAG[Hu et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib9)introduces a debate\-based verification framework to reduce hallucinations and improve answer reliability under retrieval constraints\. However, these methods primarily focus on when to retrieve and how to expand or revise evidence through multi\-step cycles\. In contrast, StitchRAG addresses how to compress retrieved context under a dynamic budget while preserving crucial information and connecting fragmented evidence\.
Context Compression\.Prior work has studied context compression as a means of reducing input length before generation\. Selective Context[Li et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib12)prunes tokens using information\-theoretic criteria \(e\.g\., self\-information\), aiming to remove redundant content\. LLMLingua and LongLLMLingua[Jiang et al\. \(2023a\)](https://arxiv.org/html/2611.22766#bib.bib18);[Jiang et al\. \(2024\)](https://arxiv.org/html/2611.22766#bib.bib10)propose coarse\-to\-fine compression using a small language model to budget and select query\-relevant spans\. RECOMP[Xu et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib11)trains compressive models to distill retrieved documents into compact representations or summaries\. Recent work also studies attention\-guided pruning for RAG contexts[Fang et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib31), which leverages attention signals to identify and remove redundant evidence\. Many prior methods frame context compression as a separate pre\-processing step, relying on static heuristics or auxiliary models\. In contrast, StitchRAG incorporates budget allocation and evidence retention in context construction for RAG\.
Diffusion Models for Text Generation\.Diffusion models provide a non\-autoregressive framework for text generation via iterative refinement\. Early works such as Diffusion\-LM[Li et al\. \(2022\)](https://arxiv.org/html/2611.22766#bib.bib17)and DiffuSeq[Gong et al\. \(2022\)](https://arxiv.org/html/2611.22766#bib.bib13)adapted denoising processes to discrete sequence modeling\. Recent scalable approaches[Nie et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib14);[Ye et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib15)operate on masked generative principles and achieve performance competitive with autoregressive LLMs at scale\. Their iterative refinement supports global editing with bidirectional context, which is particularly suitable for controlled text modification\. Building on these properties, StitchRAG adopts a retrieve\-and\-refine paradigm\.
Figure 2:Overview of StitchRAG\.Given a query and a set of retrieved passages, StitchRAG1\)computes a per\-passage dynamic retention ratior∗r^\{\*\},2\)extracts passage sentences containing key terms, called*anchors*, and aggregates them under the token budget constrained byr∗r^\{\*\}, and3\)generates bridging text between the aggregated sentences using a diffusion LLM\. Finally, the constructed context is fed into the LLM to generate the answer\.
## 3Method
StitchRAG is a framework to construct a compact context from retrieved passages for RAG\. It first computes how much to reduce each passage in its size and determines its context budget; next, it retains only sentences containing key terms under the budget; finally, it bridges retained sentences via text diffusion\. Fig\.[2](https://arxiv.org/html/2611.22766#S2.F2)\. presents an overview\.
### 3\.1Optimal Context Retention via Utility Maximization
Problem Formulation\.We consider a standard RAG setting where a queryqqretrievesKKpassages𝒫=\{x1,…,xK\}\\mathcal\{P\}=\\\{x\_\{1\},\\dots,x\_\{K\}\\\}\. Consider compressing passagex∈𝒫x\\in\\mathcal\{P\}where the compression rate depends onxx\. For passagexx, we define the*retention ratio*r\(x,q\)∈\[0,1\]r\(x,q\)\\in\[0,1\]\(for simplicity, hereafter we drop the dependence ofrronx,qx,q\)\. The compressed passage has lengthr⋅\|x\|r\\cdot\|x\|where\|x\|\|x\|denotes the length of passagexxin the number of tokens\. For example, ifr=0\.7r=0\.7, the compressed passage has 70% of the original length\. Our goal is to find the optimalr∗r^\{\*\}for given passagexx\. We formulate this problem as*cost\-aware utility maximization*\. Specifically, we maximize the objectiveℱ\(r\)\\mathcal\{F\}\(r\)forr∈\[0,1\]r\\in\[0,1\]:
ℱ\(r\)=𝒰\(r\)−𝒞\(r\)\\displaystyle\\mathcal\{F\}\(r\)=\\mathcal\{U\}\(r\)\-\\mathcal\{C\}\(r\)\(1\)where𝒰\\mathcal\{U\}denotes the achievable utility and𝒞\\mathcal\{C\}denotes the computation cost\.
Relevance utility\.The utility is defined to measure how the compressed passage is relevant to queryqq\. However, in the first place, the original passagexxshould be relevant toqqprior to compression\. Suppose we obtain utilityu\(r\)u\(r\)with retention ratiorrifxxis relevant, and utility 0 ifxxis irrelevant\. Let random variableZ∈\{0,1\}Z\\in\\\{0,1\\\}indicate relevance \(Z=1Z\{=\}1iffxxis relevant\)\. The achievable utility is given byZ⋅u\(r\)Z\\cdot u\(r\), and𝒰\(r\)\\mathcal\{U\}\(r\)is defined as its expectation:
𝒰\(r\)=𝔼\[Z\]⋅u\(r\)=P\(Z=1\)⋅u\(r\)\.\\mathcal\{U\}\(r\)=\\mathbb\{E\}\[Z\]\\cdot u\(r\)=P\(Z\{=\}1\)\\cdot u\(r\)\.\(2\)We estimateP\(Z=1\)P\(Z\{=\}1\)by probing the LLM with a binary prompt that asks whether passagexxis useful to answerqq\(see Appendix[A\.3](https://arxiv.org/html/2611.22766#A1.SS3)for the template\)\. We compute the log\-probabilities of the LLM of the answers \(“Yes” vs\. “No”\), denoted byℒYes\\mathcal\{L\}\_\{\\text\{Yes\}\}andℒNo\\mathcal\{L\}\_\{\\text\{No\}\}, and convert them into a relevance score:
P\(Z=1\)≈R\(x,q\):=exp\(ℒYes\)exp\(ℒYes\)\+exp\(ℒNo\)\.P\(Z\{=\}1\)\\approx R\(x,q\):=\\frac\{\\exp\(\\mathcal\{L\}\_\{\\text\{Yes\}\}\)\}\{\\exp\(\\mathcal\{L\}\_\{\\text\{Yes\}\}\)\+\\exp\(\\mathcal\{L\}\_\{\\text\{No\}\}\)\}\.
Next, we defineu\(r\)u\(r\)\. Sinceu\(r\)u\(r\)is obtained assumingxxis a relevant passage,u\(r\)u\(r\)should be increasing inrr; retaining more fromxxis more informative to answerqq\. However, we assume a*diminishing return*: new information does not increase proportionately with the context length\. Thus, we adopt a*logarithmic utility*inrr:
u\(r\)=log\(1\+r\)\\displaystyle u\(r\)=\\log\(1\+r\)\(3\)A diminishing return is consistent with Heaps’ law[Heaps \(1978\)](https://arxiv.org/html/2611.22766#bib.bib37), which states that the number of distinct words grows sub\-linearly in the document length\. Thus, redundancy grows faster than novel information as the context gets longer\. Later, we give more justification for log\-utilityu\(r\)u\(r\)\. In summary,𝒰\(r\)=R\(x,q\)log\(1\+r\)\\mathcal\{U\}\(r\)=R\(x,q\)\\log\(1\+r\)\.
Computation Cost\.The latency of self\-attention scales quadratically with the sequence length\. Thus, the computation cost of retainingr\|x\|r\|x\|tokens is proportional to\(r\|x\|\)2\(r\|x\|\)^\{2\}\. In RAG, documents are commonly segmented into passages of fixed word count[Karpukhin et al\. \(2020\)](https://arxiv.org/html/2611.22766#bib.bib29)or fixed token length[Bhat et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib38);[Zhong et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib39)for indexing\. Thus, we treat\|x\|\|x\|as a constant and define the cost objective:
𝒞\(r\)=βr2,\\mathcal\{C\}\(r\)=\\beta r^\{2\},\(4\)where the hyperparameterβ\>0\\beta\>0controls the latency penalty and absorbs the constant factor\|x\|2\|x\|^\{2\}\.
Deriving the optimalr∗r^\{\*\}\.We maximize expected utility minus cost:
maxr∈\[0,1\]ℱ\(r\)=R\(x,q\)⋅log\(1\+r\)−βr2\.\\max\_\{r\\in\[0,1\]\}\\ \\mathcal\{F\}\(r\)=R\(x,q\)\\cdot\\log\(1\+r\)\-\\beta r^\{2\}\.\(5\)ℱ\(r\)\\mathcal\{F\}\(r\)is a strictly concave function inrr, and \([5](https://arxiv.org/html/2611.22766#S3.E5)\) admits a unique solution[Boyd and Vandenberghe \(2004\)](https://arxiv.org/html/2611.22766#bib.bib44)as follows:
r∗=min\{12\(1\+2R\(x,q\)β−1\),1\}\.r^\{\*\}=\\min\\left\\\{\\frac\{1\}\{2\}\\left\(\\sqrt\{1\+\\frac\{2R\(x,q\)\}\{\\beta\}\}\-1\\right\),1\\right\\\}\.\(6\)We set hyperparameterβ=0\.25\\beta=0\.25\. In this setting, one can show thatr∗=1r^\{\*\}=1if and only ifR\(x,q\)=1R\(x,q\)=1, which is a reasonable choice\. In \([6](https://arxiv.org/html/2611.22766#S3.E6)\),r∗r^\{\*\}increases with relevance confidenceRR, i\.e\., highly relevant passages should retain more context\.
### 3\.2Hybrid Anchor Extraction
For passagexx, our token budget is set tor∗\|x\|r^\{\*\}\|x\|\. We select and retain important*sentences*fromxxunder this budget\. Retaining sentences, instead of individual tokens, helps to maintain the coherence of context after compression\. To that end, we select sentences which contain important spans, called*anchors*\. We first select the anchors by a hybrid strategy: a semantic\-lexical selection that combines reasoning\-centric generation with query\-centric lexical matching\.
Reasoning\-centric anchors \(AR\-based\)\.We generate multiple answer candidates using the LLM conditioned on\(q,x\)\(q,x\)\. The answer spans form the anchor set,AARA^\{\\text\{AR\}\}, to capture implicit semantic dependencies beyond simple keyword matching\.
Query\-centric anchors \(TF\-IDF\-based\)\.In parallel, we extract the query\-centric anchor set denoted byATFIDFA^\{\\text\{TFIDF\}\}using a TF\-IDF score to ensure the coverage of rare entities and lexical cues\. The final anchor set is the union of the anchor sets:
𝒜=AAR∪ATFIDF\.\\mathcal\{A\}=A^\{\\text\{AR\}\}\\cup A^\{\\text\{TFIDF\}\}\.\(7\)
### 3\.3Fact\-First Sentence Selection
Given the token budgetTbudget=r∗⋅\|x\|T\_\{\\text\{budget\}\}=r^\{\*\}\\cdot\|x\|, we select sentences fromxxthat contain anchors\. We initially mark all the sentences inxxas “unselected”\.1\. Anchor protection\.We identify sentences that contain anchors in𝒜\\mathcal\{A\}and mark them as “selected”\. Let𝒮𝒜\\mathcal\{S\}\_\{\\mathcal\{A\}\}denote this set of sentences, which forms the factual backbone of the compressed context\.2\. Budget\-aware selection\.If the total number of tokens in𝒮𝒜\\mathcal\{S\}\_\{\\mathcal\{A\}\}is less thanTbudgetT\_\{\\text\{budget\}\}, we select some non\-anchor sentences using a lightweight priority rule: \(i\) sentences containing query keywords, and \(ii\) earlier sentences in retrieved passages, which often summarize salient local context\. These high\-priority non\-anchor sentences are marked as “selected” until the token budget is reached\. Finally, all the sentences marked as “unselected” are removed fromxxto obtain the compressed passage\.
Passage Compression and Log\-utility\.We provide a heuristic argument relating log\-utilityu\(r\)u\(r\)to our passage compression\. Suppose we randomly choose a sentence from passagexx\. The probability of choosing an anchor sentence isp=\|𝒮𝒜\|\|𝒮\|p=\\frac\{\|\\mathcal\{S\}\_\{\\mathcal\{A\}\}\|\}\{\|\\mathcal\{S\}\|\}\. If we take the logarithm of1/p1/p, we have that
log1p=log\|𝒮\|\|𝒮𝒜\|\\displaystyle\\log\\frac\{1\}\{p\}=\\log\\frac\{\|\\mathcal\{S\}\|\}\{\|\\mathcal\{S\}\_\{\\mathcal\{A\}\}\|\}\(8\)\([8](https://arxiv.org/html/2611.22766#S3.E8)\) is analogous to the well\-known*Inverse Document Frequency \(IDF\)*; consider𝒮\\mathcal\{S\}as a collection of documents \(treating sentences as documents\), and𝒮𝒜\\mathcal\{S\}\_\{\\mathcal\{A\}\}as the document set containing a keyword, then \([8](https://arxiv.org/html/2611.22766#S3.E8)\) is the IDF\. The IDF serves as a relevance metric for retrieval[Robertson \(2004\)](https://arxiv.org/html/2611.22766#bib.bib40)\. Supposexxis compressed by our sentence selection method with retention ratiorr\. The compressed passage retains𝒮𝒜\\mathcal\{S\}\_\{\\mathcal\{A\}\}, but its size is reduced to approximatelyr\|𝒮\|r\|\\mathcal\{S\}\|\. Thus, \([8](https://arxiv.org/html/2611.22766#S3.E8)\) for the compressed passage is
logr\|𝒮\|\|𝒮𝒜\|=logr\+log\|𝒮\|\|𝒮𝒜\|\\displaystyle\\log\\frac\{r\|\\mathcal\{S\}\|\}\{\|\\mathcal\{S\}\_\{\\mathcal\{A\}\}\|\}=\\log r\+\\log\\frac\{\|\\mathcal\{S\}\|\}\{\|\\mathcal\{S\}\_\{\\mathcal\{A\}\}\|\}\(9\)\([9](https://arxiv.org/html/2611.22766#S3.E9)\) shows the logarithmic dependence of relevance metric onrr\(the second term is constant and does not affect optimization \([5](https://arxiv.org/html/2611.22766#S3.E5)\)\), where we usedu\(r\)=log\(1\+r\)u\(r\)=\\log\(1\+r\)for numerical stability\. Overall,u\(r\)u\(r\)can be approximately seen as a relevance metric associating the compressed passage with anchor terms\.
### 3\.4Diffusion\-based Context Stitching
All the retrieved passages are compressed and then concatenated to construct the final context denoted by𝒳\\mathcal\{X\}\. While𝒳\\mathcal\{X\}preserves crucial factual information, concatenated sentences may not form a coherent context as a whole, because \(i\) some sentences are removed within the passage during compression; \(ii\) possibly heterogeneous passages are directly concatenated\. We propose*context\-stitching*based on text diffusion\. The goal of stitching is to simply connect the sentences to maintain their natural semantic flows using a small amount of tokens\. The stitching consists of two steps:
1. 1\.Dynamically allocate*stitching tokens*, initialized as masked tokens, and insert them between adjacent sentences in𝒳\\mathcal\{X\}\.
2. 2\.Fill these stitching tokens in parallel via a diffusion\-based denoising process\.
Allocation based on Semantic overlap\.We allocateκi,j\\kappa\_\{i,j\}stitching tokens between sentencesiiandjjbased on their semantic overlap\. Let𝒥i,j\\mathcal\{J\}\_\{i,j\}denote the Jaccard similarity of sentencesiiandjj, then
κi,j=⌊κ¯⋅\(1−𝒥i,j\)⌋\\kappa\_\{i,j\}=\\left\\lfloor\\bar\{\\kappa\}\\cdot\\bigl\(1\-\\mathcal\{J\}\_\{i,j\}\\bigr\)\\right\\rfloor\(10\)whereκ¯\\bar\{\\kappa\}is the maximum budget for each stitching\.κ¯\\bar\{\\kappa\}may differ depending on the types ofi,ji,j: ifiiandjjbelong to different passages, i\.e\., they are at passage boundaries and are likely to have a large semantic distance,κ¯\\bar\{\\kappa\}is set relatively large\. In contrast, ifiiandjjbelong to the same passage,κ¯\\bar\{\\kappa\}is set relatively small; see Sec\.[4](https://arxiv.org/html/2611.22766#S4)for details\.
Diffusion with a verbatim constraint\.We perform*text diffusion*[Li et al\. \(2022\)](https://arxiv.org/html/2611.22766#bib.bib17);[Lou et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib43)only on stitching tokens in𝒳\\mathcal\{X\}, while keeping the original context tokens frozen\. We treat the frozen tokens as observed conditioning context and perform masked denoising only on the stitching positions \(i\.e\., text infilling[Zhu et al\. \(2019\)](https://arxiv.org/html/2611.22766#bib.bib42)\)\. LetX\(t\)X^\{\(t\)\}denote the partially denoised version ofX\(T\)≡𝒳X^\{\(T\)\}\\equiv\\mathcal\{X\}at reverse stept=T,…,0t=T,\\ldots,0\. Letpθ\(X\(t−1\)∣X\(t\)\)p\_\{\\theta\}\(X^\{\(t\-1\)\}\\mid X^\{\(t\)\}\)denote the reverse denoising distribution parameterized byθ\\theta\. Letℐ\\mathcal\{I\}denote the index set of stitching tokens in𝒳\\mathcal\{X\}\. We first sample an intermediate state
X~\(t−1\)∼pθ\(X\(t−1\)∣X\(t\)\),\\tilde\{X\}^\{\(t\-1\)\}\\sim p\_\{\\theta\}\(X^\{\(t\-1\)\}\\mid X^\{\(t\)\}\),\(11\)and update the context state at indexiiorXiX\_\{i\}:
Xi\(t−1\)=\{X~i\(t−1\),i∈ℐ,Xi\(T\),i∉ℐ,X^\{\(t\-1\)\}\_\{i\}=\\begin\{cases\}\\tilde\{X\}^\{\(t\-1\)\}\_\{i\},&i\\in\\mathcal\{I\},\\\\ X^\{\(T\)\}\_\{i\},&i\\not\\in\\mathcal\{I\},\\end\{cases\}\(12\)Our diffusion with the*verbatim constraint*, i\.e\., denoising only stitching tokens and keeping the original context fixed, prevents factual drift while allowing coherent transitions between fragmented passages\. We use pre\-trained denoising models, e\.g\.,[Nie et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib14);[Ye et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib15), aspθp\_\{\\theta\}\.
Why Diffusion?Text diffusion is advantageous for context stitching for the following reasons\. 1\) Auto\-regressive models generate tokens only from left context, i\.e\.,P\(xt∣x<t\)P\(x\_\{t\}\\mid x\_\{<t\}\), whereas stitching is an*interpolation*problem capturing both preceding and succeeding contexts\. We therefore adopt text diffusion, whose bidirectional attention works conditionally on both sides of the context\. 2\) Text diffusion enables*parallel decoding*over masked tokens, which can reduce latency when the diffusion step count is much smaller than the context length\.
Table 1:Comparison of retrieval\-augmented generation methods\. \(✓: Retrieval used, ✗: No retrieval\)\.Boldindicates the best performance\. andUnderlinedenotes the second\-best performance\.Ret\.MethodHotpotQANQTriviaQAPopQA2WikiEMF1EMF1EMF1EMF1EMF1Baselines✗Naive Gen16\.823\.817\.426\.256\.665\.519\.223\.38\.616\.5✗MAD23\.032\.721\.833\.156\.466\.321\.428\.218\.225\.1✓RAG30\.241\.137\.650\.462\.071\.037\.045\.619\.028\.2Compression Methods✓LongLLMLingua29\.439\.533\.445\.460\.269\.334\.041\.516\.827\.0✓RECOMP29\.239\.235\.246\.058\.365\.835\.843\.021\.433\.5✓Selective Context22\.136\.432\.542\.657\.665\.929\.536\.813\.619\.5Multi\-step Methods✓SuRe19\.032\.334\.851\.347\.664\.141\.848\.910\.218\.6✓FLARE16\.623\.719\.427\.653\.663\.021\.624\.39\.220\.1✓IRCoT25\.234\.428\.637\.347\.254\.527\.033\.022\.831\.1✓Self\-RAG14\.828\.844\.051\.246\.458\.322\.034\.313\.026\.6✓DRAG30\.841\.736\.850\.360\.869\.938\.646\.128\.834\.9Ours✓StitchRAG32\.643\.439\.453\.363\.472\.837\.246\.327\.835\.4
## 4Experiment
### 4\.1Experimental Settings
We evaluate performance on five open\-domain QA benchmarks\. Following prior work[Jiang et al\. \(2023b\)](https://arxiv.org/html/2611.22766#bib.bib7);[Hu et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib9), we randomly sample 500 examples from each dataset using the default setup provided by FlashRAG[Jin et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib28)\.
Dataset\.We evaluate retrieval\-augmented generation on HotpotQA[Yang et al\. \(2018\)](https://arxiv.org/html/2611.22766#bib.bib22), Natural Questions \(NQ\)[Kwiatkowski et al\. \(2019\)](https://arxiv.org/html/2611.22766#bib.bib23), TriviaQA[Joshi et al\. \(2017\)](https://arxiv.org/html/2611.22766#bib.bib24), 2WikiMultiHopQA \(2Wiki\)[Ho et al\. \(2020\)](https://arxiv.org/html/2611.22766#bib.bib25), and PopQA[Mallen et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib41)\. HotpotQA and 2Wiki require multi\-hop reasoning across multiple passages\. NQ consists of real user queries paired with Wikipedia answers\. TriviaQA focuses on factoid questions with evidence from web or Wikipedia sources\. PopQA is an entity\-centric open\-domain QA benchmark constructed from Wikidata and designed to probe long\-tail factual knowledge\. For each query, we retrieve a fixed number of passages and condition the generator on the retrieved context\.
Baselines\.We compareStitchRAGagainst \(i\)non\-retrievalbaselines, includingNaive GenandMAD[Du et al\. \(2024\)](https://arxiv.org/html/2611.22766#bib.bib27), \(ii\) Standard RAG[Lewis et al\. \(2020\)](https://arxiv.org/html/2611.22766#bib.bib16)\(iii\)iterative / multi\-stepRAG methods that involve multiple stages of retrieval and/or generation \(SuRe[Kim et al\. \(2024a\)](https://arxiv.org/html/2611.22766#bib.bib8),FLARE[Jiang et al\. \(2023b\)](https://arxiv.org/html/2611.22766#bib.bib7),IRCoT[Trivedi et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib6),Self\-RAG[Asai et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib5),DRAG[Hu et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib9)\), and \(iv\)context compressionmethods \(LongLLMLingua[Jiang et al\. \(2024\)](https://arxiv.org/html/2611.22766#bib.bib10),RECOMP[Xu et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib11),Selective Context[Li et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib12)\)\.
Implementation details\.The system is built on theFlashRAGtoolkit[Jin et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib28)\. Following this setup, we use E5\-base\-v2[Wang et al\. \(2022\)](https://arxiv.org/html/2611.22766#bib.bib26)as the retriever and the widely adopted December 2018 Wikipedia dump as the retrieval corpus[Karpukhin et al\. \(2020\)](https://arxiv.org/html/2611.22766#bib.bib29)\. For fair comparison, all methods use the same retriever, and we report Exact Match \(EM\) and token\-level F1 using standard evaluation protocols\. For*single\-shot*retrieval methods \(including ours and non\-iterative baselines\), we retrieve Top\-K=9K\{=\}9passages once and condition the generator on the retrieved context\. For baselines that*explicitly iterate retrieval*\(e\.g\.,FLARE,IRCoT,DRAG\), we follow their original settings and retrieve Top\-K=3K\{=\}3passages per iteration for up to three retrieval–generation iterations \(up to 9 passages total\)\. The generator isLLaMA3\-8B\-Instruct[Huang et al\. \(2024\)](https://arxiv.org/html/2611.22766#bib.bib4)\. We instantiate our approach withLLaDA[Nie et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib14)as the diffusion backbone, usingT=32T=32reverse diffusion steps\. We setκ¯\\bar\{\\kappa\}to 2 for intra\-passage sentences and to 7 for inter\-passage sentences\. For the diffusion backbone, we build on Fast\-dLLM[Wu et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib19)and optimize its dynamic remasking for*batched, GPU\-parallel*execution, which is crucial in context\-stitching where multiple retrieved passages are processed simultaneously\. Specifically, we remove Python\-level per\-sample loops via vectorized sorting, prefix\-product cutoff detection, and batched scatter\-based selection, preserving the same remasking policy and matching transfer decisions while achieving an average∼\\sim1\.3×\\timesspeedup for batch size≥4\\geq 4\(Appendix[A\.5](https://arxiv.org/html/2611.22766#A1.SS5)\)\. All experiments were conducted on A100 GPUs\.
Context budget for baselines\.StitchRAG reduces the retrieved context to 72\.29% on average of its original length across datasets\. To match the retention budget, we set the retention ratio of other compression\-based baselines and fixed\-retention budget methods to 75% in all experiments\. Table[9](https://arxiv.org/html/2611.22766#A1.T9)in Appendix[A\.4](https://arxiv.org/html/2611.22766#A1.SS4)provides detailed statistics\.
### 4\.2Main Results
Table[1](https://arxiv.org/html/2611.22766#S3.T1)summarizes end\-to\-end QA performance \(EM/F1\) on five open\-domain benchmarks\. Overall, StitchRAG achieves the strongest results, ranking first on 6 of 10 metrics and second on the remaining three, demonstrating robust performance across both single\-hop and multi\-hop QA\. On HotpotQA, it improves over RAG[Lewis et al\. \(2020\)](https://arxiv.org/html/2611.22766#bib.bib16)by \+2\.4 EM and \+2\.3 F1, and also outperforms DRAG[Hu et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib9)by \+1\.8 EM and \+1\.7 F1\. On NQ, although Self\-RAG[Asai et al\. \(2023\)](https://arxiv.org/html/2611.22766#bib.bib5)attains the highest EM, StitchRAG achieves the best F1, improving over RAG by \+2\.1 F1\. On TriviaQA, it sets the best EM and F1, surpassing RAG by \+1\.4 EM and \+1\.8 F1\. On PopQA, DRAG achieves the highest EM, while SuRE attains the best F1\. StitchRAG ranks second on both metrics\. On 2Wiki, StitchRAG achieves the best F1 while ranking second in EM\. Across datasets, both StitchRAG variants consistently outperform the retrieval baselines and most multi\-step and compression\-based methods\. This shows that our dynamic context construction and diffusion\-based stitching are an effective alternative to multi\-round retrieval and generic context compression\.
### 4\.3Analyses
Robustness to Retrieval Noise\.Fig\.[3](https://arxiv.org/html/2611.22766#S4.F3)evaluates robustness under increasing retrieval depth by sweeping Top\-KKfrom 10 to 30\. AsKKgrows, the retrieved context becomes longer and typically noisier, substantially hurting RAG pipelines: Standard RAG drops sharply at Top\-3030, falling to 45\.1 average F1 \(from 48\.1 at Top\-1010\), indicating a pronounced sensitivity to retrieval noise and context\-length effects\. In contrast, StitchRAG remains essentially invariant across the sweep, staying at 51\.2 average F1 for Top\-10/20/3010/20/30\. This stability suggests that our dynamic context construction effectively decouples generation quality from the raw amount of retrieved evidence by filtering redundant content and preserving an information\-dense context, thereby mitigating the degradation observed in naive scaling of retrieval depth\.
Figure 3:Robustness to increased retrieval passages\.Average F1 across four QA benchmarks \(Hotpot, NQ, TriviaQA, 2Wiki\) as the retrieval number of Top\-KKincreases \(Top\-10/20/30\)\. While standard RAG degrades sharply at largerKKdue to longer and noisier contexts, StitchRAG remains stable, mitigating retrieval noise and context\-length effects\.Table 2:Effect of adaptive vs\. fixed retention ratio \(75%\) on StitchRAG \(EM/F1\)\.CompressionHotpotQANQTriviaQA2WikiEMF1EMF1EMF1EMF1Fixed 75%30\.841\.937\.452\.461\.672\.226\.833\.3Dynamic \(Avg\. 72\.7%\)32\.643\.439\.453\.363\.472\.827\.835\.4
Effectiveness of Dynamic Retention Budgets\.Table[2](https://arxiv.org/html/2611.22766#S4.T2)compares a fixed retention ratio \(75%\) against our dynamic, utility\-guided budgeting \(average retention≈\\approx72\.7%\)\. Across all four benchmarks, dynamic budgeting consistently improves both EM and F1, indicating that a fixed retention rate is suboptimal under heterogeneous retrieval quality and question difficulty\. The gains are most pronounced on multi\-hop datasets: on HotpotQA, dynamic budgeting improves \+1\.8 EM and \+1\.5 F1, and on 2Wiki, \+1\.0 EM and \+2\.1 F1\. We also observe consistent improvements on single\-hop settings: on NQ, F1 increases by \+0\.9, and on TriviaQA, \+1\.8 EM and \+0\.6 F1\. These results suggest that allocating a slightly larger budget to high\-utility passages while aggressively filtering low\-utility ones yields a higher information density under a comparable overall compression level, outperforming fixed\-budget compression\.
Table 3:Ablation on hybrid anchor extraction \(EM/F1\)\.We ablate reasoning\-centric AR anchors and lexical TF\-IDF anchors\.AnchorsHotpotQANQTriviaQA2WikiEMF1EMF1EMF1EMF1AR✓\\color\[rgb\]\{0,0,1\}\\checkmarkTF\-IDF×\\color\[rgb\]\{1,0,0\}\\times29\.841\.439\.252\.161\.070\.725\.833\.4AR×\\color\[rgb\]\{1,0,0\}\\timesTF\-IDF✓\\color\[rgb\]\{0,0,1\}\\checkmark31\.842\.437\.250\.963\.272\.426\.033\.9AR✓\\color\[rgb\]\{0,0,1\}\\checkmarkTF\-IDF✓\\color\[rgb\]\{0,0,1\}\\checkmark32\.643\.439\.453\.363\.472\.827\.835\.4
Ablation Study of Anchor Protection\.Table[3](https://arxiv.org/html/2611.22766#S4.T3)studies the contribution of our hybrid anchor extraction by ablating reasoning\-centric AR anchors and query\-centric lexical TF\-IDF anchors\. Using either anchor set alone is consistently worse than combining both, indicating strong complementarity\. WithAR\-only\(TF\-IDF removed\), performance drops markedly on multi\-hop datasets \(HotpotQA: 29\.8/41\.4; 2Wiki: 25\.8/33\.4\), suggesting that AR candidates alone may miss rare entities or exact lexical cues needed for precise evidence grounding\. WithTF\-IDF\-only\(AR removed\), results improve over AR\-only on HotpotQA and TriviaQA \(31\.8/42\.4 and 63\.2/72\.4, respectively\) but degrade on NQ \(37\.2/50\.9\), where paraphrased answers benefit from semantically guided anchors\. CombiningAR\+TF\-IDFyields the best performance across all datasets, demonstrating that semantic anchors from AR and lexical coverage from TF\-IDF have synergistic effects, yielding faithful and information\-rich sentences for subsequent stitching\.
Table 4:Ablation on stitching components \(EM/F1\)\.“No stitching” removes diffusion stitching and uses only extracted evidence spans; “AR\-stitching” replaces diffusion stitching with an autoregressive stitcher \(LLaMA\)\.VariantStitcherHotpotQANQTriviaQA2WikiEMF1EMF1EMF1EMF1No stitching–32\.242\.738\.050\.961\.471\.126\.033\.4AR\-stitchingLLaMA27\.438\.337\.650\.556\.065\.524\.033\.2StitchRAGDiffusion32\.643\.439\.453\.363\.472\.827\.835\.4
Impact of Stitching Strategies\.Table[4](https://arxiv.org/html/2611.22766#S4.T4)shows the effect of context stitching\. We compare the modifications of StitchRAG: \(i\)no stitchingperforms only dynamic context construction without stitching; \(ii\)AR stitchingperforms stitching with autoregressive models instead of diffusion\. Table[4](https://arxiv.org/html/2611.22766#S4.T4)shows that full StitchRAG performs the best on all benchmarks \(e\.g\., HotpotQA \+0\.4 EM / \+0\.7 F1; NQ \+1\.4 EM / \+2\.4 F1; 2Wiki \+1\.8 EM / \+2\.0 F1\) overno stitching, showing that stitching contributes non\-trivial gains by producing coherent transitions and reducing discontinuities between retained spans\. In contrast, AR\-stitching underperforms drastically, suggesting that left\-to\-right generation is brittle for constrained context editing: it tends to drift from frozen evidence and accumulates errors when forced to connect disjoint fragments\. Our results show that diffusion\-based stitching is better suited for faithful context construction\.
Table 5:Sensitivity to the number of Anchors\.Left: AR candidate sweep with TF\-IDF fixed to 10\. Right: TF\-IDF anchor sweep with AR fixed to 1\. Values are Avg F1 on HotpotQA\.SettingHyperparameterAvg F1143\.4AR candidates sweep243\.3542\.4542\.4TF\-IDF anchors sweep1043\.42043\.5
Effects of the number of Answer Candidates\.From Table[5](https://arxiv.org/html/2611.22766#S4.T5), we observe that the number of AR candidates has limited benefit beyond a single candidate\. Using one AR candidate achieves a strong performance \(43\.4\), and expanding the candidate set to 2 brings little improvement, while further increasing it to 5 substantially hurts performance\. This trend suggests that additional AR candidates may introduce noisy or weakly relevant anchor signals\. By contrast, performance consistently improves as the number of TF\-IDF anchors increases from 5 to 10, and then saturates at 20\. The small gain from 10 to 20 implies that a moderate number of TF\-IDF anchors is sufficient to capture useful lexical evidence\. Based on this trade\-off, we use 1 AR candidate and 10 TF\-IDF anchors\.
Table 6:Latency comparison\.We randomly sample 100 examples from HotpotQA\. All experiments are conducted with FlashRAG[Jin et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib28)on A100 GPUs, and results are reported as mean±\\pmstandard deviation\.RAGSelf\-RAGIRCoTDRAGStitchRAGLatency\(seconds\)7\.247\.24±2\.84\\pm 2\.848\.088\.08±0\.56\\pm 0\.5624\.6624\.66±9\.81\\pm 9\.8127\.3927\.39±7\.97\\pm 7\.9710\.6210\.62±4\.30\\pm 4\.30
Latency Analysis\.Table[6](https://arxiv.org/html/2611.22766#S4.T6)shows that StitchRAG strikes a practical balance between efficiency and performance\. Although it is slower than Base RAG and Self\-RAG, it remains substantially more efficient than IRCoT and DRAG, both of which require iterative multi\-step reasoning\. When we replaced diffusion\-based stitching in StitchRAG with autoregressive stitching, latency increased by about 10\.3 s\. Thus, diffusion has advantages not only in performance but also in efficiency compared to AR due to its parallel decoding\. Overall, our result positions StitchRAG as a middle\-ground design point that improves over simple one\-pass baselines without incurring the full cost of iterative methods\.
Additional Results\.We provide additional experiments on the use of another diffusion backbone,DREAM[Ye et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib15), and an analysis of stitching tokens in Appendix[A\.1](https://arxiv.org/html/2611.22766#A1.SS1)\. A qualitative analysis is provided in Appendix[A\.2](https://arxiv.org/html/2611.22766#A1.SS2)\.
## 5Conclusion
In this work, we introducedStitchRAG, which addresses a central challenge in RAG: how to build a compact context without discarding the evidence most critical for answering\. By combining passage\-adaptive context\-length allocation, hybrid anchor selection, and diffusion\-based stitching,StitchRAGconstructs compact yet information\-dense contexts without incurring a substantial efficiency cost\. Across five open\-domain QA benchmarks,StitchRAGconsistently outperforms prior multi\-step and compression baselines while also offering a clear efficiency advantage\. We hope this work motivates further research on adaptive and faithful context construction for long and complex retrieval settings\.
## 6Limitations
StitchRAG improves answer quality, reduces context length, and provides a theoretically grounded framework to determine the retention ratio\. However, our approach still requires multiple model inferences similar to other advanced RAG methods\. This incurs overhead as compared to the default baseline: single\-pass RAG\.
To mitigate this overhead, we design the pipeline to be batch\-friendly\. The extra calls can be amortized via auto\-regressive batch inference for anchor scoring/selection across many queries\. We also use parallelization strategies for stitching, such as diffusion parallel decoding \(multi\-sample denoising executed in parallel, enhanced by our modification[A\.5](https://arxiv.org/html/2611.22766#A1.SS5)\)\. In practice, these batching and parallel decoding techniques substantially reduce per\-request overhead\.
Finally, while our framework prevents factual drift by freezing verbatim anchors during diffusion, we restricted the diffusion method to lightweight stitching\. This is mainly due to the limited capability of state\-of\-the\-art discrete diffusion LLMs as of this writing\. As diffusion\-based generators mature, we envision an exciting direction beyond stitching: towards more aggressive yet faithful context refinement, elegantly rewriting and reorganizing non\-anchor regions while keeping anchors intact, without increasing inference latency\.
## References
- Achiamet al\.\(2023\)J\. Achiam, S\. Adler, S\. Agarwal, L\. Ahmad, I\. Akkaya, F\. L\. Aleman, D\. Almeida, J\. Altenschmidt, S\. Altman, S\. Anadkat,et al\.Gpt\-4 technical report\.arXiv preprint arXiv:2303\.08774\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p1.1)\.
- Asaiet al\.\(2023\)A\. Asai, Z\. Wu, Y\. Wang, A\. Sil, and H\. HajishirziSelf\-rag: learning to retrieve, generate, and critique through self\-reflection\.InThe Twelfth International Conference on Learning Representations,Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1),[§2](https://arxiv.org/html/2611.22766#S2.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1),[§4\.2](https://arxiv.org/html/2611.22766#S4.SS2.p1.1)\.
- Bhatet al\.\(2025\)S\. R\. Bhat, M\. Rudat, J\. Spiekermann, and N\. Flores\-HerrRethinking chunk size for long\-document retrieval: a multi\-dataset analysis\.arXiv preprint arXiv:2505\.21700\.Cited by:[§3\.1](https://arxiv.org/html/2611.22766#S3.SS1.p4.1)\.
- Boyd and Vandenberghe \(2004\)S\. Boyd and L\. VandenbergheConvex optimization\.Cambridge university press\.Cited by:[§3\.1](https://arxiv.org/html/2611.22766#S3.SS1.p5.2)\.
- Chenet al\.\(2017\)D\. Chen, A\. Fisch, J\. Weston, and A\. BordesReading wikipedia to answer open\-domain questions\.InProceedings of the 55th Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),pp\. 1870–1879\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p1.1)\.
- Duet al\.\(2024\)Y\. Du, S\. Li, A\. Torralba, J\. B\. Tenenbaum, and I\. MordatchImproving factuality and reasoning in language models through multiagent debate\.InForty\-first international conference on machine learning,Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1)\.
- Duet al\.\(2025\)Y\. Du, M\. Tian, S\. Ronanki, S\. Rongali, S\. Bodapati, A\. Galstyan, A\. Wells, R\. Schwartz, E\. A\. Huerta, and H\. PengContext length alone hurts llm performance despite perfect retrieval\.arXiv preprint arXiv:2510\.05381\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1)\.
- Fanget al\.\(2025\)Y\. Fang, T\. Sun, Y\. Shi, and X\. GuAttentionrag: attention\-guided context pruning in retrieval\-augmented generation\.arXiv preprint arXiv:2503\.10720\.Cited by:[§2](https://arxiv.org/html/2611.22766#S2.p2.1)\.
- Gonget al\.\(2022\)S\. Gong, M\. Li, J\. Feng, Z\. Wu, and L\. KongDiffuseq: sequence to sequence text generation with diffusion models\.arXiv preprint arXiv:2210\.08933\.Cited by:[§2](https://arxiv.org/html/2611.22766#S2.p3.1)\.
- Heaps \(1978\)H\. S\. HeapsInformation retrieval: computational and theoretical aspects\.Academic Press, Inc\.\.Cited by:[§3\.1](https://arxiv.org/html/2611.22766#S3.SS1.p3.2)\.
- Hoet al\.\(2020\)X\. Ho, A\. D\. Nguyen, S\. Sugawara, and A\. AizawaConstructing a multi\-hop qa dataset for comprehensive evaluation of reasoning steps\.InProceedings of the 28th International Conference on Computational Linguistics,pp\. 6609–6625\.Cited by:[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p2.1)\.
- Honget al\.\(2025\)K\. Hong, A\. Troynikov, and J\. HuberContext rot: how increasing input tokens impacts llm performance\.Technical reportChroma\.External Links:[Link](https://research.trychroma.com/context-rot)Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1)\.
- Huet al\.\(2025\)W\. Hu, W\. Zhang, Y\. Jiang, C\. J\. Zhang, X\. Wei, and L\. QingRemoval of hallucination on hallucination: debate\-augmented rag\.InProceedings of the 63rd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),pp\. 15839–15853\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1),[§2](https://arxiv.org/html/2611.22766#S2.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1),[§4\.2](https://arxiv.org/html/2611.22766#S4.SS2.p1.1)\.
- Huaet al\.\(2025\)Q\. Hua, L\. Ye, D\. Fu, Y\. Xiao, X\. Cai, Y\. Wu, J\. Lin, J\. Wang, and P\. LiuContext engineering 2\.0: the context of context engineering\.arXiv preprint arXiv:2510\.26493\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p3.1)\.
- Huanget al\.\(2024\)K\. C\. Huang, K\. Lakhotia, K\. Huang, L\. Chen, L\. Garg, A\. Lavender, L\. Silva, L\. Bell, L\. Zhang, L\. Guo,et al\.The llama 3 herd of models\.preprint\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p4.1)\.
- Jianget al\.\(2023a\)H\. Jiang, Q\. Wu, C\. Lin, Y\. Yang, and L\. QiuLlmlingua: compressing prompts for accelerated inference of large language models\.InProceedings of the 2023 conference on empirical methods in natural language processing,pp\. 13358–13376\.Cited by:[§2](https://arxiv.org/html/2611.22766#S2.p2.1)\.
- Jianget al\.\(2024\)H\. Jiang, Q\. Wu, X\. Luo, D\. Li, C\. Lin, Y\. Yang, and L\. QiuLongllmlingua: accelerating and enhancing llms in long context scenarios via prompt compression\.InProceedings of the 62nd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),pp\. 1658–1677\.Cited by:[§2](https://arxiv.org/html/2611.22766#S2.p2.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1)\.
- Jianget al\.\(2023b\)Z\. Jiang, F\. F\. Xu, L\. Gao, Z\. Sun, Q\. Liu, J\. Dwivedi\-Yu, Y\. Yang, J\. Callan, and G\. NeubigActive retrieval augmented generation\.InProceedings of the 2023 conference on empirical methods in natural language processing,pp\. 7969–7992\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1),[§2](https://arxiv.org/html/2611.22766#S2.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1)\.
- Jinet al\.\(2025\)J\. Jin, Y\. Zhu, Z\. Dou, G\. Dong, X\. Yang, C\. Zhang, T\. Zhao, Z\. Yang, and J\. WenFlashrag: a modular toolkit for efficient retrieval\-augmented generation research\.InCompanion Proceedings of the ACM on Web Conference 2025,pp\. 737–740\.Cited by:[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p4.1),[Table 6](https://arxiv.org/html/2611.22766#S4.T6)\.
- Joshiet al\.\(2017\)M\. Joshi, E\. Choi, D\. S\. Weld, and L\. ZettlemoyerTriviaqa: a large scale distantly supervised challenge dataset for reading comprehension\.InProceedings of the 55th Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),pp\. 1601–1611\.Cited by:[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p2.1)\.
- Kalaiet al\.\(2025\)A\. T\. Kalai, O\. Nachum, S\. S\. Vempala, and E\. ZhangWhy language models hallucinate\.arXiv preprint arXiv:2509\.04664\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p1.1)\.
- Karpukhinet al\.\(2020\)V\. Karpukhin, B\. Oguz, S\. Min, P\. Lewis, L\. Wu, S\. Edunov, D\. Chen, and W\. YihDense passage retrieval for open\-domain question answering\.InProceedings of the 2020 conference on empirical methods in natural language processing \(EMNLP\),pp\. 6769–6781\.Cited by:[§3\.1](https://arxiv.org/html/2611.22766#S3.SS1.p4.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p4.1)\.
- Kimet al\.\(2024a\)J\. Kim, J\. Nam, S\. Mo, J\. Park, S\. W\. Lee, M\. Seo, J\. W\. Ha, and J\. ShinSURE: summarizing retrievals using answer candidates for open\-domain qa of llms\.In12th International Conference on Learning Representations, ICLR 2024,Cited by:[§2](https://arxiv.org/html/2611.22766#S2.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1)\.
- Kimet al\.\(2024b\)M\. Kim, C\. Park, and S\. J\. BaekQpaug: question and passage augmentation for open\-domain question answering of llms\.InFindings of the Association for Computational Linguistics: EMNLP 2024,pp\. 9024–9042\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1)\.
- Kwiatkowskiet al\.\(2019\)T\. Kwiatkowski, J\. Palomaki, O\. Redfield, M\. Collins, A\. Parikh, C\. Alberti, D\. Epstein, I\. Polosukhin, J\. Devlin, K\. Lee,et al\.Natural questions: a benchmark for question answering research\.Transactions of the Association for Computational Linguistics7,pp\. 453–466\.Cited by:[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p2.1)\.
- Lewiset al\.\(2020\)P\. Lewis, E\. Perez, A\. Piktus, F\. Petroni, V\. Karpukhin, N\. Goyal, H\. Küttler, M\. Lewis, W\. Yih, T\. Rocktäschel,et al\.Retrieval\-augmented generation for knowledge\-intensive nlp tasks\.Advances in neural information processing systems33,pp\. 9459–9474\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1),[§4\.2](https://arxiv.org/html/2611.22766#S4.SS2.p1.1)\.
- Liet al\.\(2022\)X\. Li, J\. Thickstun, I\. Gulrajani, P\. S\. Liang, and T\. B\. HashimotoDiffusion\-lm improves controllable text generation\.Advances in neural information processing systems35,pp\. 4328–4343\.Cited by:[§2](https://arxiv.org/html/2611.22766#S2.p3.1),[§3\.4](https://arxiv.org/html/2611.22766#S3.SS4.p4.1)\.
- Liet al\.\(2023\)Y\. Li, B\. Dong, F\. Guerin, and C\. LinCompressing context to enhance inference efficiency of large language models\.InProceedings of the 2023 conference on empirical methods in natural language processing,pp\. 6342–6353\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p3.1),[§2](https://arxiv.org/html/2611.22766#S2.p2.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1)\.
- Liuet al\.\(2024\)N\. F\. Liu, K\. Lin, J\. Hewitt, A\. Paranjape, M\. Bevilacqua, F\. Petroni, and P\. LiangLost in the middle: how language models use long contexts\.Transactions of the Association for Computational Linguistics12,pp\. 157–173\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1)\.
- Louet al\.\(2023\)A\. Lou, C\. Meng, and S\. ErmonDiscrete diffusion modeling by estimating the ratios of the data distribution\.arXiv preprint arXiv:2310\.16834\.Cited by:[§3\.4](https://arxiv.org/html/2611.22766#S3.SS4.p4.1)\.
- Mallenet al\.\(2023\)A\. Mallen, A\. Asai, V\. Zhong, R\. Das, D\. Khashabi, and H\. HajishirziWhen not to trust language models: investigating effectiveness of parametric and non\-parametric memories\.InProceedings of the 61st annual meeting of the association for computational linguistics \(volume 1: Long papers\),pp\. 9802–9822\.Cited by:[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p2.1)\.
- Meiet al\.\(2025\)L\. Mei, J\. Yao, Y\. Ge, Y\. Wang, B\. Bi, Y\. Cai, J\. Liu, M\. Li, Z\. Li, D\. Zhang,et al\.A survey of context engineering for large language models\.arXiv preprint arXiv:2507\.13334\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p3.1)\.
- Nieet al\.\(2025\)S\. Nie, F\. Zhu, Z\. You, X\. Zhang, J\. Ou, J\. Hu, J\. Zhou, Y\. Lin, J\. Wen, and C\. LiLarge language diffusion models\.arXiv preprint arXiv:2502\.09992\.Cited by:[§A\.1](https://arxiv.org/html/2611.22766#A1.SS1.SSS0.Px2.p1.1),[§2](https://arxiv.org/html/2611.22766#S2.p3.1),[§3\.4](https://arxiv.org/html/2611.22766#S3.SS4.p4.3),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p4.1)\.
- Panet al\.\(2024\)Z\. Pan, Q\. Wu, H\. Jiang, M\. Xia, X\. Luo, J\. Zhang, Q\. Lin, V\. Rühle, Y\. Yang, C\. Lin,et al\.Llmlingua\-2: data distillation for efficient and faithful task\-agnostic prompt compression\.InFindings of the Association for Computational Linguistics: ACL 2024,pp\. 963–981\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p3.1)\.
- Robertson \(2004\)S\. RobertsonUnderstanding inverse document frequency: on theoretical arguments for idf\.Journal of documentation60\(5\),pp\. 503–520\.Cited by:[§3\.3](https://arxiv.org/html/2611.22766#S3.SS3.p2.2)\.
- Trivediet al\.\(2023\)H\. Trivedi, N\. Balasubramanian, T\. Khot, and A\. SabharwalInterleaving retrieval with chain\-of\-thought reasoning for knowledge\-intensive multi\-step questions\.InProceedings of the 61st annual meeting of the association for computational linguistics \(volume 1: long papers\),pp\. 10014–10037\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p2.1),[§2](https://arxiv.org/html/2611.22766#S2.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1)\.
- Wanget al\.\(2022\)L\. Wang, N\. Yang, X\. Huang, B\. Jiao, L\. Yang, D\. Jiang, R\. Majumder, and F\. WeiText embeddings by weakly\-supervised contrastive pre\-training\.arXiv preprint arXiv:2212\.03533\.Cited by:[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p4.1)\.
- Wellecket al\.\(2019\)S\. Welleck, I\. Kulikov, S\. Roller, E\. Dinan, K\. Cho, and J\. WestonNeural text generation with unlikelihood training\.arXiv preprint arXiv:1908\.04319\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p1.1)\.
- Wuet al\.\(2025\)C\. Wu, H\. Zhang, S\. Xue, Z\. Liu, S\. Diao, L\. Zhu, P\. Luo, S\. Han, and E\. XieFast\-dllm: training\-free acceleration of diffusion llm by enabling kv cache and parallel decoding\.arXiv preprint arXiv:2505\.22618\.Cited by:[§A\.5](https://arxiv.org/html/2611.22766#A1.SS5.p1.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p4.1)\.
- Xuet al\.\(2023\)F\. Xu, W\. Shi, and E\. ChoiRecomp: improving retrieval\-augmented lms with compression and selective augmentation\.arXiv preprint arXiv:2310\.04408\.Cited by:[§1](https://arxiv.org/html/2611.22766#S1.p3.1),[§2](https://arxiv.org/html/2611.22766#S2.p2.1),[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p3.1)\.
- Yanget al\.\(2018\)Z\. Yang, P\. Qi, S\. Zhang, Y\. Bengio, W\. Cohen, R\. Salakhutdinov, and C\. D\. ManningHotpotQA: a dataset for diverse, explainable multi\-hop question answering\.InProceedings of the 2018 conference on empirical methods in natural language processing,pp\. 2369–2380\.Cited by:[§4\.1](https://arxiv.org/html/2611.22766#S4.SS1.p2.1)\.
- Yeet al\.\(2025\)J\. Ye, Z\. Xie, L\. Zheng, J\. Gao, Z\. Wu, X\. Jiang, Z\. Li, and L\. KongDream 7b: diffusion large language models\.arXiv preprint arXiv:2508\.15487\.Cited by:[§A\.1](https://arxiv.org/html/2611.22766#A1.SS1.SSS0.Px2.p1.1),[§2](https://arxiv.org/html/2611.22766#S2.p3.1),[§3\.4](https://arxiv.org/html/2611.22766#S3.SS4.p4.3),[§4\.3](https://arxiv.org/html/2611.22766#S4.SS3.p7.1)\.
- Zhonget al\.\(2025\)Z\. Zhong, H\. Liu, X\. Cui, X\. Zhang, and Z\. QinMix\-of\-granularity: optimize the chunking granularity for retrieval\-augmented generation\.InProceedings of the 31st International Conference on Computational Linguistics,pp\. 5756–5774\.Cited by:[§3\.1](https://arxiv.org/html/2611.22766#S3.SS1.p4.1)\.
- Zhuet al\.\(2019\)W\. Zhu, Z\. Hu, and E\. XingText infilling\.arXiv preprint arXiv:1901\.00158\.Cited by:[§3\.4](https://arxiv.org/html/2611.22766#S3.SS4.p4.1)\.
## Appendix AAppendix
### A\.1Additional Experiments
SettingHotpotQANQTriviaQA2WikiEMF1EMF1EMF1EMF1Intra\-only32\.042\.738\.651\.561\.070\.726\.033\.7Inter\-only32\.443\.139\.253\.161\.270\.626\.634\.5Both32\.643\.439\.453\.363\.472\.827\.835\.4
Table 7:Ablation on stitching scope \(EM/F1\)\.“Intra\-only” uses stitching tokens only within the same passage; “Inter\-only” stitches only across passages; “Both” enables both intra\- and inter\-passage stitching\.
Figure 4:Effect of stitching\-token budget on intra\- vs\. inter\-passage stitching\.#### Analysis of Stitching token budgets\.
Figure[4](https://arxiv.org/html/2611.22766#A1.F4)sweeps the stitching\-token budgetκ¯\\bar\{\\kappa\}on HotpotQA \(EM\) while isolating intra\-passage vs\. inter\-passage stitching\. We find that the optimal budget differs substantially by scope:Intra\-onlypeaks at a small budget \(κ¯=2\\bar\{\\kappa\}\{=\}2, 32\.4 EM\), suggesting that within\-passage gaps primarily require short local smoothing\. In contrast,Inter\-onlybenefits from a larger budget and peaks later \(κ¯=7\\bar\{\\kappa\}\{=\}7, 31\.8 EM\), consistent with the higher difficulty of bridging cross\-passage evidence\. Performance degrades whenκ¯\\bar\{\\kappa\}is overly large \(e\.g\., inter\-only atκ¯=9\\bar\{\\kappa\}\{=\}9\), indicating that excessive stitching capacity can introduce drift or dilute the evidence\-to\-stitching ratio\. Overall, this motivates using distinct budgets for intra\- and inter\-passage stitching rather than a single global setting\.
Table[7](https://arxiv.org/html/2611.22766#A1.T7)analyzes where stitching tokens matter by restricting stitching to intra\-passage gaps only or inter\-passage gaps only\. Using either scope alone is insufficient:Intra\-onlyyields strong HotpotQA performance but lags on NQ and 2Wiki, whileInter\-onlyimproves cross\-passage reasoning metrics but is slightly worse on HotpotQA and does not help TriviaQA\. EnablingBothconsistently delivers the best results across all datasets\. This indicates that effective context construction requires*both*local smoothing within retrieved passages and global bridging across passages: intra\-passage stitching resolves fragment boundaries and improves readability, while inter\-passage stitching is essential for multi\-hop evidence composition and cross\-passage coherence\.
Table 8:Results of StitchRAG with different diffusion LLMs\.BoldandUnderlinerespectively denote the best performance and the second\-best performance in the Table[1](https://arxiv.org/html/2611.22766#S3.T1)\(main results\)\.Ret\.MethodHotpotQANQTriviaQA2WikiEMF1EMF1EMF1EMF1✓StitchRAG \(Dream\)32\.042\.238\.652\.662\.771\.927\.234\.7✓StitchRAG \(LLaDA\)32\.643\.439\.453\.363\.472\.827\.835\.4
#### Results of StitchRAG with different Diffusion Backbone \(Dream\)\.
Table[8](https://arxiv.org/html/2611.22766#A1.T8)shows the performance of StitchRAG comparing different diffusion backbones for stitching: LLaDA[Nie et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib14)and Dream[Ye et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib15)\. The Dream\-based variant achieves competitive performance across all benchmarks, ranking second on HotpotQA \(EM/F1\), NQ F1, and TriviaQA \(EM/F1\) compared to the baseline methods shown in the main results in Table[1](https://arxiv.org/html/2611.22766#S3.T1)\. These results indicate that the proposed framework generalizes across diffusion backbones\.
### A\.2Qualitative Analyses
We present three qualitative case studies, each organized around a different baseline: NaiveRAG, AR\-RAG, and No Stitching\. Each case highlights howStitchRAGimproves context construction and downstream answer generation under a distinct retrieval failure pattern\.
Case Study: Evidence Stitching for Multi\-hop Reasoning \(HotpotQA\)QuestionWhen was the novel published in 2010 which is part of the series of The Maze Runner?Correct AnswerSeptember 18, 2010Reasoning RequirementThe Maze Runner series→\\rightarrownovel released in 2010⇓\\DownarrowThe Scorch Trials⇓\\Downarrowpublication date→\\rightarrowSeptember 18, 2010Evidence in the Original Retrieved ContextThe retrieved passages already contain the necessary evidence, but the relevant facts arefragmented across different sentences\. In the original context, the two pieces of evidence are separated by multiple sentences:…The Scorch Trialsis a 2010 young adult post\-apocalyptic …in the“The Maze Runner” series\.The novel was published onSeptember 18, 2010by Delacorte Press\.…Failure of Naive Context ConcatenationThe naive RAG concatenates retrieved passages into a long context \(1607 tokens\) without explicitly connecting related evidence\. As a result, the relationship between theMaze Runnerseries, the 2010 novel, and its publication date remains implicit\. The model therefore stops at the intermediate entity:NaiveRAG→\\rightarrowThe Scorch Trials\(incorrect\)Evidence Stitching by DiffusionStitchRAG preserves the original evidence spans asanchorsand generates a short connective sentence that stitches them into a coherent reasoning chain:…The Scorch Trialsis the second book releasedin the series, onSeptember 18, 2010\.…Importantly, the stitched sentence does not introduce new factual evidence\. Instead, it connects the preserved evidence spans into a form that is easier for the language model to interpret\.OutcomeNaiveRAG→\\rightarrowThe Scorch Trials \(incorrect\)StitchRAG→\\rightarrowSeptember 18, 2010\(correct\)Context Reduction1607 tokens→\\rightarrow1219 tokens \(24% compression\)AnalysisThis example highlights the role of diffusion\-based stitching\. Although the retrieved context already contains the necessary evidence, the relevant information appears in fragmented sentences\. StitchRAG preserves the original evidence spans and generates a short bridging sentence that connects them into a coherent reasoning path\. This stitched context makes the relationship between evidence explicit and shortens the multi\-hop reasoning process, enabling the model to produce the correct answer\.
Case Study: Evidence Stitching for Multi\-hop Reasoning \(WikiMultiHopQA\)QuestionWho is James Roosevelt Roosevelt’s sibling\-in\-law?Correct AnswerEleanor RooseveltReasoning RequirementJames Roosevelt Roosevelt⇓\\Downarrow\(half\-brother\)Franklin Delano Roosevelt⇓\\Downarrow\(married\)Eleanor RooseveltEvidence in the Original Retrieved ContextThe retrieved passages contain the necessary facts, but they appear inseparate documents\. The relationship chain required for multi\-hop reasoning is therefore fragmented across the context\.…“James Roosevelt “Rosy” Roosevelt \(April 27, 1854 – May 7, 1927\) was an American diplomat, heir, and theolder half\-brother of 32nd President of the United States Franklin Delano Roosevelt\.”…“In 1905, hemarried his fifth cousin once removed, Eleanor Roosevelt\.”…These two pieces of evidence provide the required relations:James Roosevelt Roosevelt→\\rightarrowFranklin Delano RooseveltFranklin Delano Roosevelt→\\rightarrowEleanor RooseveltHowever, in the original retrieved context these facts are separated by large amounts of unrelated biography text, making the reasoning path implicit\.Failure of Naive Context ConcatenationNaive RAG concatenates the retrieved passages without aligning the relations across documents\. As a result, the model often stops at the intermediate entity:NaiveRAG→\\rightarrowFranklin Delano Roosevelt \(incorrect\)The final relational step linking Franklin Roosevelt to Eleanor Roosevelt is not explicitly connected to the earlier evidence\.Evidence Stitching by DiffusionStitchRAG preserves the original evidence spans and places them within a single coherent reasoning segment:…James Roosevelt “Rosy” Roosevelt was theolder half\-brother of Franklin Delano Roosevelt\.Franklin Delano Rooseveltmarried Eleanor Roosevelt\.…This stitched context makes the relational chain explicit:James Roosevelt Roosevelt→\\rightarrowFranklin Delano Roosevelt→\\rightarrowEleanor RooseveltOutcomeNaiveRAG→\\rightarrowFranklin Delano Roosevelt \(incorrect\)StitchRAG→\\rightarrowEleanor Roosevelt\(correct\)AnalysisThe required relations already exist in the retrieved passages but appear in separate documents and are embedded in irrelevant text\. By preserving the evidence spans and placing them in a coherent context, StitchRAG enables the model to connect the relations and correctly infer that the sibling\-in\-law of James Roosevelt Roosevelt is Eleanor Roosevelt\.
Case Study: Diffusion\-based Knowledge Completion \(HotpotQA\)QuestionThe rapper whose debut album was titled “Thug Misses” has sold over how many records worldwide?Correct Answer2 millionReasoning RequirementThis HotpotQA example requires bridge\-type multi\-hop reasoning:Thug Misses→\\rightarrowrapperKhia⇓\\DownarrowKhia’s worldwide record sales→\\rightarrow2 millionMissing Evidence in the Retrieved ContextThe retrieved passages correctly identify the artist associated with the album, but they do not contain the worldwide record sales required to answer the question\.…“Thug Missesis the debut album by American rapperKhia\.”“The album spawned the single “My Neck, My Back \(Lick It\)”\.”“As of June 2007 the album had sold611,000 copies in the US\.”…Thus, the retrieved evidence provides information about the album and its U\.S\. sales, but the key fact about Khia’s worldwide record sales is missing from the retrieved context\.Model OutputsBecause the retrieved passages prominently contain the number611,000, several RAG systems incorrectly treat this number as the answer\.NaiveRAG→\\rightarrow611,000 \(incorrect\)No Stitching→\\rightarrow611,000 \(incorrect\)AR\-RAG→\\rightarrowNot specifiedStitchRAG→\\rightarrow2 million\(correct\)Diffusion\-based CompletionAfter diffusion\-based context reconstruction, the refined context contains the following passage:…“The album was moderately successful and achieved moderate crossover chart success\.”“Khia released her album later that year, which also gained gold status\.”“Khia sold over 2 million records worldwide\.”…Notably, the statement about Khia’s worldwide sales does not appear in the retrieved passages\.AnalysisThis example illustrates that diffusion\-based stitching can go beyond simply connecting retrieved evidence spans\. While the retrieved context contains only partial information \(the album and its U\.S\. sales\), the diffusion process introduces a missing factual link using parametric knowledge learned during pretraining\. By combining the retrieved evidence with this generated fact, StitchRAG is able to complete the multi\-hop reasoning chain and produce the correct answer\.
Case Study: Structural Evidence Stitching \(HotpotQA\)QuestionWhich author wrote a play in 2006 and a book on homosexual sex in 1977?Correct AnswerEdmund Valentine White IIIReasoning RequirementThis question requires identifying an author who satisfies two conditions:book about homosexual sex \(1977\)→\\rightarrowauthor→\\rightarrowplaywright \(2006\)Evidence in the Original ContextThe retrieved passages mainly discuss unrelated topics such as:•religious views on homosexuality•legal cases and legislation•unrelated books and films•historical eventsAlthough the wordhomosexual sexappears multiple times, the passages do not contain any information linking a specific book to its author, nor do they provide any connection to theatrical works\.Structural Evidence Stitching in the Stitched ContextThe stitched context organizes evidence into structured topical segments\. For example:Documentary filmGay Sex in the 70sand the literary reference:Faggots \(novel\)“The novel’s portrayal of promiscuous sex and recreational drug use provoked controversy\.”In addition, the stitched context contains structural markers such as:\#\#\# ReferencesThese elements group related cultural and literary references, creating a structured context around LGBTQ\-related works\.How Stitching Enables ReasoningThe stitched context introduces a crucial evidence anchor:Faggots \(novel\)This work is associated with the authorEdmund Whiteand is known for its depiction of homosexual culture in the late 1970s\. This anchor satisfies the first condition in the question:book about homosexual sex \(1977\)Through structural evidence stitching, related passages about LGBTQ literature and cultural works are placed within the same semantic region\. This stitched context allows the model to identifyEdmund Whiteas the author and recognize that he is also a playwright who produced theatrical works in 2006\.Rather than inserting the answer directly,StitchRAGstitches topically related evidence into a coherent reasoning structure, enabling the model to recover the reasoning chain and correctly infer the answer\.
Error CaseQuestionWho is Thessalonike of Macedon’s father\-in\-law?Correct AnswerAntipaterModel PredictionCassanderReasoning RequirementAnswering this question requires a two\-step kinship inference:Thessalonike of Macedon→\\rightarrowwife of CassanderCassander→\\rightarrowson of Antipater⇓\\Downarrowfather\-in\-law of Thessalonike→\\rightarrowAntipaterEvidence in the Retrieved ContextThe retrieved context clearly supports that Thessalonike married Cassander, but it does not explicitly preserve the second link needed for the full inference:*Cassander→\\rightarrowson of Antipater*\. Thus, the context strongly supports identifying the husband, but not the father\-in\-law\.\[…\]“Thessalonikewas a Macedonian princess … andwife of Cassander\.”\[…\]“Cassandermarried her\. Thessalonike became queen of Macedon …”\[…\]Example of Structural StitchingIn the refined context, the main preserved evidence anchor is:Thessalonike of Macedon→\\rightarrowwife of CassanderThis anchor provides onlypartial structural Stitching\. It links Thessalonike to her husband, but not Cassander to his father:Cassander→\\rightarrowAntipater’s sonAs a result, the context encourages arelation collapsefrom*father\-in\-law*to*husband*\.Reasoning Failure Induced by Incomplete Structural StitchingWith only the first kinship link preserved, the model defaults to the nearest available male relative:Thessalonike→\\rightarrowCassanderPrediction→\\rightarrowCassanderBut the correct reasoning requires an additional genealogical step:Thessalonike→\\rightarrowhusband: CassanderCassander→\\rightarrowfather: Antipater⇓\\Downarrowfather\-in\-law→\\rightarrowAntipaterAnalysisThis is a failure case of structural stitching\. The refinement preserves an anchor sufficient to recover Thessalonike’s husband, but not the extra bridge needed to resolve the father\-in\-law relation\. The model therefore predictsCassander, a locally supported but semantically incorrect answer\. The gold answer,Antipater, requires a second genealogical link that is absent from the refined context\.
Error CaseQuestionWhere does the director of film Présentation ou Charlotte et son steak work at?Correct AnswerCahiers du cinémaModel PredictionSwitzerlandReasoning RequirementAnswering this question requires identifying the film’s director and then linking that director to his workplace:Présentation ou Charlotte et son steak→\\rightarrowdirected by Éric RohmerÉric Rohmer→\\rightarrowworked at Cahiers du cinéma⇓\\Downarrowdirector’s workplace→\\rightarrowCahiers du cinémaEvidence in the Retrieved ContextThe retrieved context preserves the first step but not the second, and instead highlights an irrelevant location cue tied to the film’s setting\.\[…\]“Présentation ou Charlotte et son steakis a French short drama film written and directed byÉric Rohmer… In aSwiss villagein winter, Walter is walking with Charlotte when they meet Clara\.”\[…\]The missing second\-hop fact is:Éric Rohmer→\\rightarrowworked atCahiers du cinémaExample of Structural StitchingIn the refined context, the system preserves the director anchor but also highlights a competing location anchor:Présentation ou Charlotte et son steak→\\rightarrowÉric RohmerPrésentation ou Charlotte et son steak→\\rightarrowSwiss villageThese anchors createmisleading structural stitching, since the workplace link is missing while an irrelevant geographical cue remains salient\.Reasoning Failure Induced by Misleading Structural StitchingThe model may therefore substitute the film’s setting for the director’s workplace:Présentation ou Charlotte et son steak→\\rightarrowSwiss villageSwiss village→\\rightarrowSwitzerlandPrediction→\\rightarrowSwitzerlandThe correct reasoning is:Présentation ou Charlotte et son steak→\\rightarrowdirector: Éric RohmerÉric Rohmer→\\rightarrowworkplace: Cahiers du cinéma⇓\\Downarrowanswer→\\rightarrowCahiers du cinémaAnalysisThis example illustrates a relation\-substitution error\. Although the refined context correctly links the film toÉric Rohmer, it does not preserve the evidence connecting Rohmer toCahiers du cinéma\. Instead, it highlights the film’s Swiss setting, which encourages the model to substitute a salient location for the director’s workplace\.
### A\.3Prompt Templates
Relevance probing prompt\.We estimateR\(x,q\)=P\(Z=1\)R\(x,q\)=P\(Z\{=\}1\)using a fixed binary prompt that asks whether a retrieved passage is useful for answering the query\. We decode neither a rationale nor a free\-form answer; instead, we only score the canonical responsesYesandNo\.
> Question:⟨q⟩\\langle q\\rangle Passage:⟨x⟩\\langle x\\rangle Is this passage relevant to the question? Answer \(Yes/No\):
Scoring\.LetℒYes\\mathcal\{L\}\_\{\\text\{Yes\}\}andℒNo\\mathcal\{L\}\_\{\\text\{No\}\}denote the \(sequence\) log\-probabilities of the targetsYesandNounder the model given the prompt\. If a target is tokenized into multiple tokens, we sum log\-probabilities across its token sequence\. We then compute
R\(x,q\)=exp\(ℒYes\)exp\(ℒYes\)\+exp\(ℒNo\)\.R\(x,q\)=\\frac\{\\exp\(\\mathcal\{L\}\_\{\\text\{Yes\}\}\)\}\{\\exp\(\\mathcal\{L\}\_\{\\text\{Yes\}\}\)\+\\exp\(\\mathcal\{L\}\_\{\\text\{No\}\}\)\}\.\(13\)
Answer generation prompt \(RAG\)\.For all methods, the final answer is generated by an autoregressive generator conditioned on the \(possibly compressed/stitched\) context\. We use the following instruction\-style RAG prompt\.
> \[System\]Answer the question based on the given passages\. Provide a direct and accurate answer\. \[User\] Passage: ⟨context⟩\\langle\\text\{context\}\\rangle Question: ⟨q⟩\\langle q\\ranglePlease provide the answer in the format: ‘The answer is: \[your answer\]’\.
### A\.4Average Retention ratior∗r^\{\*\}of StitchRAG
Table 9:Averager∗r^\{\*\}of retrieved tokens achieved byStitchRAGon each dataset\.HotpotQANQTriviaQA2WikiPopQAAvg\.Avg\. retention ratio \(%\)74\.2572\.8376\.2667\.4470\.6672\.29
### A\.5Vectorized Implementation of Dynamic Remasking
Table 10:Comparison of implementation strategies\.ComponentOriginalOursBatch iterationPythonforloopVectorizedThreshold computationList comprehensiontorch\.arangeSortingPer\-sample \(masked\-only\)Batch\-parallel \(full, with sentinel\)Cutoff detectionNested loopPrefix\-product \(cumprod\)SelectionPer\-sampletopkBatchedscatterEdge casesManualiftorch\.whereTable 11:Inference time comparison ofget\_transfer\_index\_dynamic\(seq\_len=2048, vocab=32k, warmup=10, repeat=50\)\. We conducted our experiments on a single NVIDIA A100 GPU\.Batch SizeOriginalOursSpeedup12\.41 ms2\.31 ms1\.04×\\times49\.25 ms8\.49 ms1\.09×\\times826\.49 ms20\.00 ms1\.32×\\times1644\.92 ms36\.00 ms1\.25×\\times3284\.56 ms65\.14 ms1\.30×\\timesThis appendix compares the original Fast\-dLLM dynamic remasking implementation[Wu et al\. \(2025\)](https://arxiv.org/html/2611.22766#bib.bib19)with our vectorized PyTorch version\. The vectorized implementation follows the same dynamic remasking policy as the original version and produced matching transfer decisions in all of our tests, while removing Python\-level per\-sample loops to improve batched inference efficiency\.
#### Background \(Dynamic Remasking Policy\)\.
Let masked tokens be ranked by confidence in descending order\. Conceptually, the algorithm selects the longest confidence\-sorted prefix whose elements satisfy a rank\-dependent threshold,
τr=1−αr\+1,\\tau\_\{r\}=1\-\\frac\{\\alpha\}\{r\+1\},\(14\)whereα\\alphais a factor parameter \(typicallyα=1\\alpha=1\), while ensuring that at least one token is transferred whenever masked positions exist\.
#### Original Implementation \(Fast\-dLLM\)
The original implementation iterates over batch elements in Python: it computes per\-sample thresholds, sorts masked\-token confidences, scans ranks to find the cutoffkk, and then applies per\-sampletopkselection\.
Table 12:Original Fast\-dLLM implementation \(sequential per\-sample loop\)\.mask\_index,x,num\_transfer\_tokens,factor=1\):
\#Sampleproposalsandcomputeconfidence
logits\_with\_noise=add\_gumbel\_noise\(logits,temperature\)
x0=torch\.argmax\(logits\_with\_noise,dim=\-1\)
p=F\.softmax\(logits\.to\(torch\.float64\),dim=\-1\)
x0\_p=torch\.squeeze\(
torch\.gather\(p,dim=\-1,index=torch\.unsqueeze\(x0,\-1\)\),\-1\)
x0=torch\.where\(mask\_index,x0,x\)
confidence=torch\.where\(mask\_index,x0\_p,\-np\.inf\)
transfer\_index=torch\.zeros\_like\(x0,dtype=torch\.bool\)
num\_transfer\_tokens=mask\_index\.sum\(dim=1,keepdim=True\)
\#Per\-sampleloop\(sequentialprocessing\)
forjinrange\(confidence\.shape\[0\]\):
num\_tokens=int\(num\_transfer\_tokens\[j\]\.item\(\)\)
ifnum\_tokens==0:
continue
\#Computethresholds\(Pythonlistcomprehension\)
ns=list\(range\(1,num\_tokens\+1\)\)
es=\[factor/\(n\+1\)forninns\]
threshs=\[1\-eforeines\]
threshs\[0\]=\-1\#Ensureatleastonetransfer
\#Sortmaskedtokensonly
sorted\_confidence=torch\.sort\(
confidence\[j\]\[mask\_index\[j\]\],descending=True\)\[0\]
\#Findcutoffrank
fortop\_iinrange\(len\(threshs\)\):
ifsorted\_confidence\[top\_i\]<threshs\[top\_i\]:
break
\#Edgecasehandling
iftop\_i==0ortop\_i==len\(threshs\)\-1:
top\_i\+=1
\#Selecttop\-k
\_,select\_index=torch\.topk\(confidence\[j\],k=top\_i\)
transfer\_index\[j,select\_index\]=True
returnx0,transfer\_index
#### Our Vectorized Implementation
We implement the same logic using tensor\-native operations only\. Instead of sorting only masked positions, we sort the full sequence after assigning unmasked positions a sentinel “−∞\-\\infty\-like” value, ensuring they are placed at the tail and do not affect the top\-kkmasked ranks\. Cutoff detection and index materialization are fully vectorized across the batch\.
Table 13:Our vectorized implementation \(batch\-parallel on GPU\)\.mask\_index,x,num\_transfer\_tokens=None,
factor=1\.0,threshold=None\):
\#Sampleproposalsandcomputeconfidence
logits\_with\_noise=add\_gumbel\_noise\(logits,temperature\)
x0=torch\.argmax\(logits\_with\_noise,dim=\-1\)
p=F\.softmax\(logits\.to\(torch\.float64\),dim=\-1\)
x0\_p=torch\.gather\(p,dim=\-1,index=x0\.unsqueeze\(\-1\)\)\.squeeze\(\-1\)
x0=torch\.where\(mask\_index,x0,x\)
neg\_inf=torch\.tensor\(torch\.finfo\(x0\_p\.dtype\)\.min,
device=x0\_p\.device,dtype=x0\_p\.dtype\)
confidence=torch\.where\(mask\_index,x0\_p,neg\_inf\)
B,L=confidence\.shape
mask\_counts=mask\_index\.sum\(dim=1\)\.to\(dtype=torch\.long\)
\#Earlyexitforemptymasks
if\(mask\_counts==0\)\.all\(\):
returnx0,torch\.zeros\_like\(mask\_index,dtype=torch\.bool\)
\#Vectorizedthresholdcomputation
ranks=torch\.arange\(L,device=confidence\.device,dtype=torch\.float64\)
thr=1\.0\-\(float\(factor\)/\(ranks\+2\.0\)\)
thr\[0\]=torch\.finfo\(torch\.float64\)\.min\#Atleastonetransfer
\#Batchsorting\(parallelacrossbatchdimension\)
values,idx=torch\.sort\(confidence,dim=1,descending=True\)
\#Vectorizedthresholdcomparison
pass\_mask=values\>=thr\.unsqueeze\(0\)\#\(B,L\)
\#Prefixproducttofindconsecutivepassingranks
prefix\_ok=torch\.cumprod\(pass\_mask\.to\(torch\.int64\),dim=1\)
k=prefix\_ok\.sum\(dim=1\)\.to\(dtype=torch\.long\)\#Per\-samplek
\#Vectorizededgecasehandling\(matchoriginalboundaryhandling\)
k=torch\.minimum\(k,mask\_counts\)
k=torch\.where\(mask\_counts\>0,torch\.clamp\(k,min=1\),k\)
k=torch\.where\(\(mask\_counts\>0\)&\(k==mask\_counts\-1\),
mask\_counts,k\)
\#Vectorizedtop\-kselectionviascatter
cols=torch\.arange\(L,device=confidence\.device\)\.unsqueeze\(0\)\.expand\(B,L\)
select\_sorted=cols<k\.unsqueeze\(1\)
transfer\_int=torch\.zeros\(B,L,device=confidence\.device,dtype=torch\.int8\)
transfer\_int=transfer\_int\.scatter\(1,idx,select\_sorted\.to\(torch\.int8\)\)
transfer\_index=transfer\_int\.bool\(\)&mask\_index
returnx0,transfer\_index
#### Key Optimization
To avoid explicit scanning loops, we implement threshold\-based prefix selection with a vectorized prefix\-product operation over the sorted pass mask\. This yields the valid prefix length efficiently and is well\-suited for batch\-parallel GPU execution\.
#### Performance
Both versions are dominated by sorting at long sequence lengths; the practical speedup comes from eliminating Python overhead and enabling batch\-parallel execution on GPU, which improves utilization forB≥4B\\geq 4in our setup\.
#### Equivalence Validation
The vectorized implementation follows exactly the same threshold rule and prefix selection criterion as the original version\. We verified output equivalence through randomized unit tests over 1,000 cases with varying batch sizes, sequence lengths, and mask densities, and observed no accuracy difference in end\-to\-end evaluation on HotpotQA and NQ\.相似文章
RAG-Stress:探究检索增强生成中证据依赖的边界
RAG-Stress 提出一个受控诊断协议,通过编辑检索证据中的单一断言来诱导错误答案,量化模型在检索增强生成中被误导证据覆盖正确答案的比率(misleading rate),并发现严格遵循文档的指令会系统性提高误导率。
CANOPY:面向多模态 RAG 的自适应粒度证据压缩
CANOPY 提出一种自适应粒度的多模态 RAG 检索后证据压缩框架,通过层级表征与父节点相对精炼来选择多粒度证据区域,并在压缩不足时触发定向再检索,在 5 个 QA 基准上取得更高平均准确率,同时将读取器输入 token 减少 14.2–27.7%。
检索增强生成的组合性
论文提出开源 RAG 受控评测框架 LASAGNA,在八个基准和 5K-200K 文档语料上测试 450 种配置,发现单独有效的 RAG 技术组合后收益大幅缩水(预期 +47% 仅得 +17%),检索质量与答案忠实度的设计取舍互相冲突,且最优组合随语料规模变化。
CoinRAG: Contextualized Information Nugget KV Cache Reuse for Long-Context RAG
CoinRAG is a new method for long-context RAG that reuses fine-grained contextualized information nugget KV caches instead of full chunks, improving efficiency and answering quality. It achieves a new Pareto frontier with 5.3% relative F1 improvement on LongBench multi-hop QA tasks.
什么能保存到上下文中:预算受限多跳RAG的诊断方法与子模证据打包的改进时机
本文引入了answer-in-context,一种用于预算受限多跳RAG的诊断指标,用于衡量黄金答案是否存在于打包后的读者上下文中,并提出了一种子模证据打包方法,在特定条件下优于启发式方法。