xRAG: Extreme Context Compression for Retrieval-augmented Generation with One Token

Xin Cheng, Xun Wang, Xingxing Zhang, Tao Ge, Si-Qing Chen, Furu Wei, Huishuai Zhang, Dongyan Zhao

Abstract

Retrieval-Augmented Generation (RAG) significantly enhances Large Language Models (LLMs) by providing external factual context. However, the inclusion of full documents in prompts leads to high inference costs and consumes limited context windows. We present xRAG, a framework that compresses retrieved documents into a single token. By treating document embeddings as a distinct input modality and using a lightweight "modality bridge," xRAG achieves a 175x compression rate and a 3.5x reduction in compute costs. Our results demonstrate that xRAG maintains performance comparable to full-text RAG while offering increased resilience to noisy retrievals.

Introduction

Retrieval-Augmented Generation has become the standard for grounding LLMs in up-to-date, factual information. Despite its success, RAG suffers from a significant "context tax": feeding entire documents into a prompt consumes massive amounts of the context window and spikes inference costs. Existing solutions like prompt compression often face a trade-off between compression ratio and accuracy.

xRAG addresses this by asking: since dense retrievers already distill a whole document into a single vector for retrieval, why can't the LLM "read" that vector directly? By treating the document embedding as a visual-like feature, xRAG compresses an entire document into a single "soft" token.

Extracted figure from page 2 of xRAG: Extreme Context Compression for Retrieval-augmented Generation with One Token

Methodology: Modality Fusion

The core innovation of xRAG is Modality Fusion. Instead of processing documents as text, xRAG treats document embeddings (from retrievers like SFR or BGE) as a distinct input modality, similar to how multi-modal models handle images.

The Modality Bridge

A simple two-layer Multi-Layer Perceptron (MLP) acts as a projector. It takes the document embedding and maps it into the LLM’s input space as a single "document token" [X]. Crucially, both the LLM and the Retriever remain frozen; only the tiny MLP bridge (representing <0.1% of total parameters) is trained.

Architectural comparison between (a) xRAG and (b) standard RAG. xRAG uses a projector to map sentence embeddings into the language model's input space as a single token.

Two-Stage Training

  1. Paraphrase Pretraining: The model is first trained to reconstruct the original document text given only the single token [X]. This aligns the retriever's embedding space with the LLM's representation space.
  2. Context-aware Instruction Tuning: The model learns to answer questions using the information encoded in [X]. This stage utilizes Self-Distillation, where the xRAG model (student) matches the output distribution of a standard RAG model (teacher) that has access to the full text.

Experimental Results

The authors evaluated xRAG across six knowledge-intensive benchmarks, including HotpotQA, TruthfulQA, and FactKG, using a Mistral-7B backbone.

  • Extreme Compression: xRAG achieved a compression ratio of 175:1, reducing approximately 180 tokens to just one.
  • Efficiency Gains: The method reduced total FLOPs by 3.53x and improved CUDA time efficiency by 1.64x.
  • Competitive Performance: xRAG achieved an average score of 42.46%, nearly matching the 43.63% of uncompressed RAG and significantly outperforming other compression methods like LLMLingua (38.01%).
  • Robustness: A key finding was xRAG's resilience. When retrievers fetch irrelevant documents, standard RAG models often hallucinate or get distracted. xRAG tends to rely more on the LLM's internal knowledge in these cases, leading to fewer "distraction" errors.

Conclusion and Future Work

xRAG demonstrates that modern dense embeddings capture nearly as much functional information as raw text for many downstream tasks. While it excels at fact retrieval, a "reasoning gap" remains for complex multi-hop tasks like HotpotQA. Future work will explore multi-vector retrieval—using a few tokens per document—to bridge this gap while maintaining high efficiency. Additionally, scaling xRAG to Top-K retrieval scenarios promises even greater efficiency gains over traditional RAG architectures.

Summary updated

BibTeX
@inproceedings{cheng2024xrag,
  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},
  title = {{xRAG: Extreme Context Compression for Retrieval-augmented Generation with One Token}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=6pTlXqrO0p},
}
Figure