Paper commentary
xRAG: Extreme Context Compression for Retrieval-augmented Generation with One Token
xRAG shrinks retrieved documents to one token for faster retrieval-augmented generation
- Problem Retrieval augmentation pastes full documents into the prompt, which makes it costly and can exceed LLM context limits. Earlier compression methods either need large memory or only reach modest compression rates.
- Method xRAG replaces each document with one token by projecting the retriever's document embedding into the LLM's representation space. Only a two-layer projector is trained, while the retriever and LLM stay frozen.
- Results On Mixtral-8x7b, xRAG averaged 46.91 across six tasks, compared to 46.22 for uncompressed RAG. GFLOPs fall by a factor of 3.53 on average.

Figure 2 : Overview of xRAG (a) and RAG (b). For a given query, RAG typically concatenates the retrieved document with the query, significantly extending the context length. In contrast, xRAG addresses this issue through modality fusion by directly projecting the document embedding into the LLM’s representation space. This allows for efficient retrieval-augmentation with the addition of only one token.
Original paper · CC BY 4.0 · Xin Cheng, Xun Wang, Xingxing Zhang, Tao Ge, Si-Qing Chen, Furu Wei, Huishuai Zhang, Dongyan Zhao · xRAG: Extreme Context Compression for Retrieval-augmented Generation with One Token · Original paper figure · Extracted the figure area from page 3 of the original PDF.Why whole documents make RAG expensive
Retrieval augmentation pastes the retrieved document in front of the question, and that is what makes it costly. In the Motel 6 example, the relevant document turns a wrong answer into a correct one, but it stretches the query by more than tenfold. Prompts that carry the whole document can also grow past the context limit of LLMs. So the question becomes how to shorten the context without losing what retrieval adds.
![Figure 1: xRAG enables efficient retrieval augmentation by adding one document token [X]](/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-123d5c367530bfa66ec9b2c0fd6fbd48.png?thumb=512)
Figure 1 : xRAG enables efficient retrieval augmentation by adding one document token [X].
Original paper · CC BY 4.0Existing compression methods fall into two families, soft-prompt and hard-prompt methods. Soft-prompt methods such as Gist, AutoCompressor and ICAE pack the context into dense memory slots. They need large memory for LLM activations, 1.05 MB per token for Gist, or they reach only relatively low compression rates. Hard-prompt methods such as LLMLingua and RECOMP instead edit the surface text of the context.
The authors point to a property of dense retrieval that these methods overlook. Contrastive training on question-document pairs already distills a document into one high-dimensional embedding. This idea sets up the move to treat the retrieval embedding as a second modality.
Treating the retrieval embedding as a second modality
xRAG treats the retriever's document embedding as a feature from another modality, not as text to shorten. Vision-language models follow a similar path, where a pretrained encoder such as CLIP extracts features and a bridge feeds them into the language model. The retriever already distills each document into a single high-dimensional embedding during contrastive training on question-document pairs.
Because these embeddings exist from offline indexing, xRAG can reuse them at run time without re-encoding documents.
A standard RAG prompt feeds the embeddings of the document and the query, giving a length of |D| + |q|. xRAG replaces the document with W(E), one vector that the projector W produces from the retrieval embedding E. Emb is the LLM's own embedding layer, so the new input is W(E) ⊕ Emb(q), with length 1 + |q|. The two forms differ only in the prefix, one token instead of the whole document.
The projector W is a two-layer MLP, chosen for simplicity over more sophisticated modules such as Q-Former. The projector is the only trainable component, at 0.46% of Mistral-7b parameters and 0.07% of Mixtral-8x7b parameters. The retriever and the LLM stay frozen, so the existing retrieval index can be reused as it is. Training the projector alone avoids the full-parameter tuning that earlier compression studies required.
The projector must learn to map retrieval features into the LLM's representation space before any downstream training. The authors train it in two stages, starting with Paraphrase Pretraining on unlabeled documents. The next section covers both training stages in detail.
Two training stages for a frozen LLM
A projector alone isn't enough, because the frozen LLM has never been trained to read the projected vector. xRAG therefore trains in two stages: Paraphrase Pretraining, then Context-aware Instruction Tuning. The projected token W(E) replaces the document's embeddings, so the input shrinks to 1 + |q| positions. The challenge is modality fusion: a text-only language model has to understand features from the retrieval modality.
In Paraphrase Pretraining, the model sees each retrieval pair (E, D) from the corpus. An instruction such as "[X] The above text could be paraphrased as: [D]" places W(E) and the document D in the prompt. The model learns to recover D from W(E), and the loss is a negative log likelihood over the document tokens. The authors sample instructions from an instruction pool to keep the prompts diverse.
Pretraining alone doesn't teach the model to use these features on downstream tasks. Context-aware Instruction Tuning fills that gap with about 1 million entries from open-source datasets. The data covers reading comprehension, summarization, and open-domain question answering. For each triplet (Xcontext, Xquestion, Xanswer), xRAG computes the sentence embedding of Xcontext and feeds it through the projector.
The language modeling term conditions the answer on the projected context, with the question and answer prefix as text. The self-distillation term treats the RAG model as the teacher and xRAG as the student. The authors use self-distillation mainly to make the student resilient to noisy or irrelevant context. The KL divergence pulls the xRAG answer distribution toward the RAG output distribution over the full text.
The final loss is Lnll + αLkl, where α is a hyperparameter.
Downstream accuracy against RAG and other compression
On Mistral-7b, retrieval raises the six-task average from 36.54 without retrieval to 43.63 with uncompressed RAG. On the same backbone, xRAG averages 42.46, a 16.2% gain over the no-retrieval average. The text quotes this gain as 16.6%, while Table 1 prints 16.2%, so this article uses the table value. The main test runs six knowledge-intensive tasks with the top-1 SFR document as the retrieved input for both backbones.
Because the retriever is frozen, xRAG's comparison against RAG uses the same retrieved documents for every compression method.

Table 1 : Experimental results on six downstream tasks. The best results are in bold and the second best are with underscore. Percentage in the brackets denotes the relative improvement over non- retrieval setting. LLMs are frozen during the experiments and retrieved documents are set the same for different compression methods. ‡ and † denotes different compression ratio.
Original paper · CC BY 4.0On Mixtral-8x7b, xRAG averages 46.91, compared to 46.22 for uncompressed RAG and 42.76 without retrieval. That is a 9.7% gain, compared to 8.0% for RAG, so the one-token input does slightly better on this backbone. The authors suggest that uncompressed RAG is vulnerable to misleading documents, which may explain the reversal. The paper's compression baselines must work without dataset-specific tuning or changes to LLM parameters, which is why LLMLingua and TF-IDF qualified.
Compared with the other compression methods, xRAG's margin is wide. On Mistral-7b, TF-IDF averages 37.49 and LLMLingua at the ‡ ratio averages 37.48, both below xRAG's 42.46. xRAG keeps the input to a single token, where RAG averages 175.1 tokens. Its input length is one token, while the uncompressed RAG input length is 175.1.
The advantage doesn't hold on every task. On Mistral-7b, HotpotQA scores 34.05 for xRAG, compared to 38.79 for RAG. FactKG scores 63.08 for xRAG, compared to 67.76 for RAG. The paper ties this gap to tasks that demand reasoning over the document, such as HotpotQA and FactKG.
Cost savings and resilience to noisy retrieval
The one-token input changes cost first, because the LLM reads the projected document embedding plus the query instead of the full document. Torch Profiler measured CUDA Time and GFLOPs for RAG and xRAG on Mistral-7b in bfloat16 mode, using an Nvidia A100. Averaged over FactKG, NQ, TriviaQA and WebQA, xRAG improves CUDA Time by x1.64 relative to RAG.
GFLOPs fall by a factor of 3.53 on average, which matches the reduction the abstract reports. On FactKG, CUDA Time drops from 431.5 ms to 215.6 ms, a x2.01 gain.
Retrieval can also hurt, so the authors add two per-instance metrics. Resilience rate is the share of answers that stay correct before and after retrieval augmentation. Boost rate is the share of initially wrong answers that a retrieved document fixes. An ideal RAG system needs both a high resilience rate and a high boost rate.
On the Mixtral-8x7b baseline, RAG's average resilience rate is 75.2%. The authors read this as retrieval adversely affecting about one-quarter of earlier correct answers. xRAG shows considerable robustness across all evaluated datasets. The authors credit this to xRAG keeping an unbiased stance toward the LLM's internal knowledge, especially with noisy retrieval.
xRAG still trails RAG on boost rate, particularly in multi-hop reasoning tasks.
A high resilience rate doesn't mean the LLM ignores the provided information. That behavior can reduce the boost rate. Figure 5 shows a misleading-document case where RAG answers from the document while xRAG relies on the LLM's own knowledge. Compared with LLMLingua, the authors find xRAG more robust and more effective.
Which training stage carries the gain
The authors remove one training component at a time and read the drop in average score as that component's contribution. On Mistral-7b, removing finetuning (w/o finetune) drops the average from 44.58 to 37.87. Removing pretraining gives 38.95, while removing self-distillation gives 41.49 on the same model. The ablation set covers pretraining, instruction tuning, and two objectives, language modeling (nll) and self-distillation (self-kd).
The authors also train a Mistral-7b with LoRA on the instruction tuning dataset, so they can check whether extra tuning data explains the gain. That LoRA variant averages 39.80, well below the full xRAG model.

Table 3 : Ablation on different training strategy for xRAG.
Original paper · CC BY 4.0On Mixtral-8x7b, removing pretraining lowers the average from 51.45 to 48.09. That drop is smaller than the one on Mistral-7b, so pretraining matters less for the larger model. The authors suggest that the larger model can absorb multi-modality information more easily.
Dropping the nll loss gives 43.02 on Mistral-7b, which is above the 41.49 seen without self-distillation. So self-distillation matters more than language modeling during finetuning, according to the authors. The authors say self-distillation mainly bolsters the resilience rate of the xRAG system. Optimization with nll loss, they argue, causes an overreliance on context information.
Training on reading comprehension data alone gives 44.24 on average for Mistral-7b. That is close to the 44.58 of the full 955k-example mix, which uses 955k training examples. Summarization data alone gives 43.42, and QA data alone gives 43.74. The authors note that summarization-only tuning still performs strongly on QA datasets it was never exposed to.
They conclude that the benefit of instruction tuning comes from using projected context, not from task-specific knowledge.
Limits of the evidence
The main numbers rest on two frozen backbones, Mistral-7b and Mixtral-8x7b, which the authors chose to show versatility across scale and architecture. The retrieval corpus is the Wikipedia dump from December 2021, split into about 37 million passages averaging 180 tokens. The default retriever is SFR, and only the top-1 ranked document feeds both the instruction-tuning data and the downstream evaluation.
The cost figures come from one hardware setup, an Nvidia A100 with an AMD EPYC 7V12 64-Core Processor, measured on four datasets. Those cost measurements use Mistral-7b in bfloat16 inference mode, so the efficiency claim isn't tested on Mixtral-8x7b.
The baselines were chosen under a plug-and-play rule, so compression methods had to work without dataset-specific tuning or changes to LLM parameters. Those criteria excluded methods that store LLM activations for each compressed token, such as Gist, AutoCompressor and ICAE. The comparison therefore covers LLMLingua and a TF-IDF discrete baseline, and the authors don't report those excluded methods.
xRAG trails RAG on HotpotQA and FactKG, where reasoning over the document is needed. On Mistral-7b, xRAG reaches 34.05 on HotpotQA against 38.79 for RAG, and its boost rate lags in multi-hop tasks. The resilience and boost analysis covers only the Mixtral-8x7b baseline, so the robustness claim isn't tested on Mistral-7b. Resilience and boost rates are the two metrics the authors introduced, and a high resilience rate doesn't by itself show that the LLM uses the retrieved information.
Paper info
- Authors
- Xin Cheng, Xun Wang, Xingxing Zhang, Tao Ge, Si-Qing Chen, Furu Wei, Huishuai Zhang, Dongyan Zhao
- Venue
- arXiv · Preprint
- First published
- 2024-5-22
- Added
- 2026-11-5
- Updated
- 2024-12-9
- Version
- v2
- arXiv
- 2405.13792
- Category
- cs.CL · cs.AI · cs.IR
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
This paper introduces xRAG, an innovative context compression method tailored for retrieval-augmented generation. xRAG reinterprets document embeddings in dense retrieval--traditionally used solely for retrieval--as features from the retrieval modality. By employing a modality fusion methodology, xRAG seamlessly integrates these embeddings into the language model representation space, effectively eliminating the need for their textual counterparts and achieving an extreme compression rate. In xRAG, the only trainable component is the modality bridge, while both the retriever and the language model remain frozen. This design choice allows for the reuse of offline-constructed document embeddings and preserves the plug-and-play nature of retrieval augmentation. Experimental results demonstrate that xRAG achieves an average improvement of over 10% across six knowledge-intensive tasks, adaptable to various language model backbones, ranging from a dense 7B model to an 8x7B Mixture of Experts configuration. xRAG not only significantly outperforms previous context compression methods but also matches the performance of uncompressed models on several datasets, while reducing overall FLOPs by a factor of 3.53. Our work pioneers new directions in retrieval-augmented generation from the perspective of multimodality fusion, and we hope it lays the foundation for future efficient and scalable retrieval-augmented systems
Quote from the paper
Xin Cheng, Xun Wang, Xingxing Zhang, Tao Ge, Si-Qing Chen, Furu Wei, Huishuai Zhang, Dongyan Zhao (2024). xRAG: Extreme Context Compression for Retrieval-augmented Generation with One Token. arXiv:2405.13792v2. https://arxiv.org/abs/2405.13792v2
BibTeX
@misc{cheng2024xrag,
title = {{xRAG: Extreme Context Compression for Retrieval-augmented Generation with One Token}},
author = {Xin Cheng and Xun Wang and Xingxing Zhang and Tao Ge and Si-Qing Chen and Furu Wei and Huishuai Zhang and Dongyan Zhao},
year = {2024},
eprint = {2405.13792},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2405.13792v2}
}