Overview
REFRAG is an efficient decoding framework for Retrieval-Augmented Generation (RAG), developed in collaboration between Meta Superintelligence Labs, the National University of Singapore (NUS), and Rice University. Lead authors include NUS PhD student Lin Xiaoqiang.
The Long-Context Challenge in RAG
- Time cost: attention complexity grows quadratically with sequence length, causing very high time-to-first-token (TTFT).
- Space cost: the KV cache grows linearly with sequence length, limiting batch size and throughput.
- Information sparsity: among dozens of retrieved documents, only a few snippets are truly relevant to the query; the remaining tokens contribute little yet still participate in all attention computations.
- Retrieved passages tend to have low semantic correlation with each other, producing a block-diagonal sparsity pattern in attention when the model generates tokens.
- Tokens within a passage are strongly related; tokens across passages are weakly related.
- Feeding all raw tokens into the LLM is therefore unnecessary and inefficient.
- Accuracy on 16 RAG tasks matches or exceeds the full-context LLaMA model.
- Perplexity (PPL) on Book and Arxiv datasets is on average 9.3% lower than the CEPE baseline.
- Enterprise knowledge-base Q&A — large-scale document retrieval with fast responses.
- Multi-turn dialogue — no need to truncate history while preserving context.
- Long-document summarization — books, reports, and other very long texts.
- Agent applications — complex reasoning and tool use.
Block-Diagonal Attention Sparsity
Three-Stage Design: Compress, Sense, Expand
1. Compress — a lightweight encoder (e.g., RoBERTa) compresses text chunks into single embedding vectors, greatly reducing sequence length. 2. Sense — a projection layer (MLP) maps encoder embeddings into the main LLM's token embedding space, aligning the two models. 3. Expand — a reinforcement-learning policy intelligently selects which chunks to decompress, preserving key details (exact numbers, dates) that compression would otherwise lose.
Measured Results
| Metric | Value | |---|---| | First-token speedup (k=32) | 30.85x | | Context length extension | 16x | | Throughput improvement | 6.78x | | KV cache memory reduction | ~k-fold |
Applications
Reference
Paper: https://arxiv.org/abs/2509.01092