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

xRAG: 토큰 하나로 하는 검색 증강 생성을 위한 극단적 문맥 압축

Xin Cheng, Xun Wang, Xingxing Zhang, Tao Ge, Si-Qing Chen, Furu Wei 외 2명 · arXiv · 2024년 5월 22일

- **연구 문제** 검색된 긴 문서를 텍스트로 넣으면 RAG의 추론 비용과 문맥 길이 한계가 커지므로, 검색 임베딩을 재사용해 문맥을 한 토큰으로 압축할 수 있는지가 문제입니다.
- **연구 방법** xRAG는 밀집 검색 임베딩을 모달리티 프로젝터로 LLM 표현 공간에 투영하여 문서를 한 토큰으로 바꾸며, 프로젝터만 학습하고 검색기와 LLM은 고정합니다.
- **주요 결과** Mistral-7b와 Mixtral-8x7b 설정에서 xRAG는 검색 증강 없는 설정 대비 평균 16.2%와 9.7% 향상을 보였고, RAG 대비 CUDA Time 1.64배, GFLOPs 3.53배 개선을 보고했습니다. 다만 다중 홉 추론 과제에서는 RAG에 뒤처집니다.

## 문서 전체를 넣는 RAG의 비용 문제

검색 증강 생성(RAG)은 검색한 문서 전체를 질문과 함께 프롬프트에 이어 붙이므로, 문서가 질의를 열 배 이상 확장하여 추론 비용과 문맥 길이 한계가 커집니다. 기존 문맥 압축 연구는 소프트 프롬프트 방식(Gist, AutoCompressor, ICAE)과 하드 프롬프트 방식(LLMLingua, RECOMP)으로 나뉘는데, 전자는 압축 토큰마다 LLM 활성값을 저장해야 하여 수많은 문서를 다루는 RAG 환경에서 메모리 부담이 크고, 후자는 압축률이 상대적으로 낮습니다.

![Figure 1: xRAG enables efficient retrieval augmentation by adding one document token \[X\]](https://refivu.com/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\].

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 2쪽에서 그림 영역을 추출했습니다.

![Table 5: Comparison between different compression methods from their setting to design principle](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-6add7351b4cbe58a2baae6979f5a898a.png?thumb=512)

**Table 5** : Comparison between different compression methods from their setting to design principle.

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 16쪽에서 그림 영역을 추출했습니다.

이 논문은 여기서 한 가지 관찰을 출발점으로 삼습니다. 대조 학습으로 훈련된 밀집 검색기는 이미 문서 내용을 하나의 고차원 임베딩에 담고 있으며, 이 임베딩은 텍스트만큼 많은 정보를 담고 있다고 보고됩니다. 따라서 xRAG는 이미 오프라인에서 만들어 둔 검색 임베딩을 텍스트 대신 재사용하는 방향을 택합니다.

## 모달리티 브리지로 검색 임베딩을 한 토큰으로 투영

xRAG는 검색 임베딩 E를 텍스트가 아니라 검색 모달리티의 특징으로 보고, 이를 LLM 표현 공간으로 옮기는 모달리티 프로젝터 W를 둡니다. 표준 RAG의 입력은 길이 \|D\|+\|q\|의 임베딩 Emb(D⊕q)인 반면, xRAG의 입력은 W(E)⊕Emb(q)로 길이가 1+\|q\|가 됩니다. 검색기와 LLM은 고정되고, 프로젝터 W만 학습됩니다. 프로젝터는 두 층 MLP로 구현되며, 원문에 따르면 Mistral-7b에서 전체 파라미터의 0.46%, Mixtral-8x7b에서 0.07%를 차지합니다.

![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 co…](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-d579441ae7c966570c56b39a23cb14b0.png?thumb=512)

**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.

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 3쪽에서 그림 영역을 추출했습니다.

학습은 두 단계입니다. 첫 단계인 Paraphrase Pretraining에서는 각 (E, D) 쌍에 대해 W(E)를 조건으로 문서 D를 복원하도록 다음 토큰 손실을 최소화합니다. 둘째 단계인 Context-aware Instruction Tuning에서는 독해, 요약, 개방형 질의응답 데이터를 사용하여 문맥 임베딩 E\_context를 조건으로 정답을 생성하는 언어 모델링 손실과, RAG 모델을 교사로 xRAG를 학생으로 두는 자기 증류 손실을 함께 사용합니다. 자기 증류 항은 Kullback-Leibler 발산 L\_kl로 두 출력 분포의 차이를 줄이며, 최종 손실은 L\_nll + αL\_kl입니다.

![Figure 3: Two-stage training strategy of xRAG including (a) Paraphrase Pre-training on unlabeled corpus and (b) Context-aware Instruction Tuning optimized with…](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-a9c636f7aebbe6a22ae6e5c913f88019.png?thumb=512)

**Figure 3** : Two-stage training strategy of xRAG including (a) Paraphrase Pre-training on unlabeled corpus and (b) Context-aware Instruction Tuning optimized with labeled data and self-distillation.

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.

## 실험 설정과 비교 기준

평가는 Natural Questions, TriviaQA, WebQuestions의 개방형 질의응답, HotpotQA의 다중 홉 질의응답, TruthfulQA의 장문 질의응답, FactKG의 사실 검증으로 구성됩니다. 개방형 질의응답과 HotpotQA는 Exact Match, FactKG는 정확도, TruthfulQA는 F1과 Rouge-L로 측정합니다. 기본 검색 모델은 SFR이며, 백본은 Mistral-7b와 Mixtral-8x7b입니다. 기준선은 검색 증강이 없는 설정, 검색 문서를 전부 넣는 RAG, LLMLingua, TF-IDF 기반 이산 압축입니다.

검색 문서는 2021년 12월 Wikipedia 덤프에서 만든 약 3,700만 개의 패시지에서 top-1 문서를 사용합니다. 이 설정은 주요 실험에서 검색 문서를 한 개만 사용하는 조건이며, 여러 문서를 다루는 설정은 한계 절에서 별도로 언급됩니다.

## 평균 성능과 효율의 비교

Mistral-7b 설정에서 검색 증강 없는 모델의 평균은 36.54이고 RAG는 43.63입니다. xRAG는 평균 42.46으로 검색 증강 없는 설정 대비 16.2% 향상되며, 같은 설정에서 LLMLingua(약 38.01 및 37.48)와 TF-IDF(37.49)보다 높습니다. Mixtral-8x7b 설정에서는 검색 증강 없는 모델이 42.76, RAG가 46.22이고, xRAG는 46.91로 검색 증강 없는 설정 대비 9.7% 향상됩니다. 원문은 이 평균 향상률이 Mixtral-8x7b에서 RAG의 8.0%보다 큰 결과라고 보고합니다.

![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…](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-5b14ba37d3fb335a07528fbf355d06d8.png?thumb=512)

**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.

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.

계산 효율 평가는 FactKG, NQ, TriviaQA, WebQA에서 Mistral-7b를 bfloat16으로 실행하여 측정했습니다. xRAG는 RAG 대비 평균 CUDA Time이 x1.64 빠르고 GFLOPs가 x3.53 감소했습니다. 다만 이 효율 측정은 Mistral-7b 백본의 측정이며, 기본 구성에서 얻은 값입니다.

![Table 2: Comparison of RAG and xRAG performance in CUDA Time and GFLOPS](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-0ddce4c570e6a227e94f10fc83d415ff.png?thumb=512)

**Table 2** : Comparison of RAG and xRAG performance in CUDA Time and GFLOPS.

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 7쪽에서 그림 영역을 추출했습니다.

## 강건성 지표와 학습 요소의 기여

검색 문서가 항상 도움이 되지는 않으므로, 논문은 Resilience Rate와 Boost Rate를 도입합니다. Resilience Rate는 검색 증강 전후에 모두 정답인 사례의 비율이고, Boost Rate는 검색 증강 전 오답이었다가 검색 문서 도입 후 정답이 된 사례의 비율입니다. RAG의 Resilience Rate는 평균 75.2%로 보고되며, xRAG는 평가한 모든 데이터셋에서 강건성이 두드러진다고 제시됩니다. 다만 xRAG의 Boost Rate는 RAG보다 낮으며, 특히 다중 홉 추론 과제에서 뒤처집니다.

![Figure 5: Given the misleading document, RAG model tend to generate a wrong answer based on the document, while xRAG demonstrate its robustness by leveraging t…](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-acaafa32b62570efb7d8505358168df3.png?thumb=512)

**Figure 5** : Given the misleading document, RAG model tend to generate a wrong answer based on the document, while xRAG demonstrate its robustness by leveraging the internal knowledge of LLM.

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.

절제 실험에서는 Mistral-7b 설정에서 xRAG의 평균이 44.58, self-kd 제거 시 41.49, pre-training 제거 시 38.95, finetune 제거 시 37.87로 나타납니다. 저자들은 self-distillation이 Resilience Rate를 높이는 데 중요하다고 해석합니다. 이 해석은 해당 절제 결과에 한정된 저자의 해석입니다.

![Table 3: Ablation on different training strategy for xRAG](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-0a69b9b662ac50cbd292cc988dd87a3a.png?thumb=512)

**Table 3** : Ablation on different training strategy for xRAG.

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 8쪽에서 그림 영역을 추출했습니다.

## 적용 범위와 한계

논문이 밝히는 주요 한계는 다음과 같습니다. 첫째, 단일 밀집 벡터 검색만 고려하며 BM25 같은 희소 검색이나 ColBERT 같은 다중 벡터 검색은 포함하지 않습니다. 둘째, xRAG는 관련 문서가 검색되었을 때 좋은 성능을 보이지만, 다중 홉 추론(HotpotQA)과 사실 검증(FactKG)처럼 추론이 필요한 과제에서 RAG에 뒤처집니다. 저자들은 학습 단계에 추론 관련 데이터가 포함되지 않았다는 점을 한 가지 이유로 제시합니다. 셋째, 주요 실험은 Top-1 검색 설정이며, 여러 문서를 사용하는 경우의 효과는 본 연구에서 확인되지 않았습니다.

![Figure 7: Failure case of xRAG when reasoning is required to derive the final answer](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544/figures/figure-108061f3a9225bf288eb86e8b54fea6d.png?thumb=512)

**Figure 7** : Failure case of xRAG when reasoning is required to derive the final answer.

[원문](https://arxiv.org/abs/2405.13792v2) · [CC BY 4.0](https://creativecommons.org/licenses/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 · 원문 그림 인용 · 원본 PDF 22쪽에서 그림 영역을 추출했습니다.

또한 xRAG의 효율 개선은 Mistral-7b에서 측정한 CUDA Time과 GFLOPs에 근거하며, 다른 백본이나 하드웨어에서 같은 크기의 효율을 보장하지는 않습니다.

## 논문 정보

- **저자**: Xin Cheng, Xun Wang, Xingxing Zhang, Tao Ge, Si-Qing Chen, Furu Wei, Huishuai Zhang, Dongyan Zhao
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2024년 5월 22일
- **등록일**: 2026년 11월 5일
- **수정일**: 2024년 12월 9일
- **버전**: v2
- **arXiv**: 2405.13792
- **분류**: cs.CL · cs.AI · cs.IR
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2405.13792v2) · [원문 PDF ↗](https://arxiv.org/pdf/2405.13792v2)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

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

## 원문 인용

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}
}
```

## 이 논문의 용어

- [검색 증강 생성](https://refivu.com/terms/745578495b18-retrieval-augmented-generation)
- [TF-IDF](https://refivu.com/terms/b8fd079027e3-tf-idf)
- [Exact Match](https://refivu.com/terms/f6e0295e5c92-exact-match)
- [TruthfulQA](https://refivu.com/terms/31ff8523e160-truthfulqa)
- [HotpotQA](https://refivu.com/terms/16cb986b71c1-hotpotqa)
- [자기 증류](https://refivu.com/terms/f20426f19189-self-distillation)
- [GFLOPs](https://refivu.com/terms/6ad611ed6283-gflops)
- [LLMLingua](https://refivu.com/terms/0013b8356953-llmlingua)

## 다른 논문 해설

- [Scaling Laws For Data-Constrained Dense Retrieval](https://refivu.com/papers/9afdcf21-003a-43d4-967e-2743eca7bae1-scaling-laws-for-data-constrained-dense-retrieval.md)
- [Reliability Stress Testing of RAG Retrieval under Query-Relevant Corpus Poisoning](https://refivu.com/papers/96fa6a69-4ee1-4530-bc84-1b0ef73aef1f-reliability-stress-testing-of-rag-retrieval-under-query.md)
- [MIRAGE: A Metric-Intensive Benchmark for Retrieval-Augmented Generation Evaluation](https://refivu.com/papers/c55abcd2-d481-42f1-8d27-29ed92271f5c-mirage-a-metric-intensive-benchmark-for-retrieval-augmented.md)
- [Retrieving from Your Own Mistakes: On-Policy Training of Embedding Models for Multi-Hop Retrieval-Augmented Generation](https://refivu.com/papers/393abb8e-63e2-43d5-998b-12de9f9addaa-retrieving-from-your-own-mistakes-on-policy-training.md)
- [Forget the Data, Keep the Capability: Switchable Unlearning for Retrieval](https://refivu.com/papers/9888943b-1ac0-4684-9f27-2cb66c2bf5f6-forget-the-data-keep-the-capability-switchable-unlearning.md)
- [Reading Beyond OCR Noise: Robust Cross-Lingual RAG for Legislative Archives](https://refivu.com/papers/bd08253c-c28e-45b9-9d49-ae743f98622a-reading-beyond-ocr-noise-robust-cross-lingual-rag.md)
- [A Fresh Take on Stale Embeddings: Improving Dense Retriever Training with Corrector Networks](https://refivu.com/papers/942cd43a-5447-4e75-acd2-3fc678453159-a-fresh-take-on-stale-embeddings-improving-dense.md)
- [MixHop: Higher-Order Graph Convolutional Architectures via Sparsified Neighborhood Mixing](https://refivu.com/papers/1250a8b5-0d20-48a6-bf8a-8ec6a0c220d1-mixhop-higher-order-graph-convolutional-architectures-via.md)
- [Exact Combinatorial Optimization with Graph Convolutional Neural Networks](https://refivu.com/papers/8df34e94-f13d-47fe-92a7-0d3d6b6d4386-exact-combinatorial-optimization-with-graph-convolutional.md)
- [Fast Monte Carlo Rendering via Multi-Resolution Sampling](https://refivu.com/papers/8594df75-dd8a-44a7-8567-449efc1ce963-fast-monte-carlo-rendering-via-multi-resolution-sampling.md)
- [Neurosymbolic Models for Computer Graphics](https://refivu.com/papers/b6d15708-e5c5-43c3-87b7-62fba4afecb3-neurosymbolic-models-for-computer-graphics.md)
- [MagicAnimate: Temporally Consistent Human Image Animation using Diffusion Model](https://refivu.com/papers/d7e4c79d-ac46-4e0f-aef6-34e570d43e2f-magicanimate-temporally-consistent-human-image-animation.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/8c00b36b-02ff-4ebf-9551-f33a03272544-xrag-extreme-context-compression-for-retrieval-augmented)
