TL;DR
Researchers have developed a unified "ECG" (Embed, Compress, Generate) model that performs retrieval, context compression, and answer generation using a single set of vector representations. By sharing these representations, the model halves disk storage requirements and matches the performance of traditional Retrieval-Augmented Generation (RAG) systems while using only one-tenth of the context size, making high-quality, private AI on mobile devices a reality.
What Problem Does This Paper Address?
Retrieval-Augmented Generation (RAG) is the backbone of modern AI, allowing models to look up facts in a massive library of documents before answering a query. Usually, this happens on powerful cloud servers. Moving RAG to a local device (like your phone) is highly desirable for privacy—you don't want your medical records or bank statements sent to a server—and for offline reliability.
However, on-device RAG faces two major bottlenecks:
- Disk Space: Storing "embeddings" (mathematical representations of documents) for a large corpus takes up significant storage.
- Memory (RAM): Generative models have a "context window" limit. Long retrieved documents balloon the Key-Value (KV) cache, leading to slow responses or out-of-memory crashes on mobile hardware.
Existing solutions often use separate models for retrieval and compression, which doubles the storage and compute overhead. This paper asks: Can we use the same vectors to both find a document and summarize its meaning for the generator?
Methods
The authors introduce the ECG (Embed, Compress, Generate) framework. Instead of treating retrieval and generation as separate silos, they unify them into a single transformer-based model (testing with SmolLM-v2 135M and Gemma 3 1B).
The Architecture
The model uses a standard pretrained decoder but adds two small "projection blocks":
- $\theta_{ret}$: Produces multi-vector representations optimized for retrieval using a variant of the MaxSim similarity metric (popularized by ColBERT).
- $\theta_{comp}$: Transforms those same retrieval vectors into "compressed context" tokens that the generative model can understand as input.
The Training Recipe
Unifying these tasks is difficult because the objectives often compete. The authors use a two-stage approach:
- Self-supervised Pretraining: The model learns to reconstruct text and predict neighboring passages. Crucially, it uses a contrastive loss to ensure the representations are useful for retrieval from the start.
- RAG-Specific Fine-tuning: The model is trained via knowledge distillation. A large "teacher" model provides the "gold standard" answers and document relevance scores, which the smaller ECG model learns to mimic using its compressed representations.
Datasets
The models were trained and evaluated on standard RAG benchmarks to allow for direct comparison with server-scale systems:
- Wikipedia: Used as the primary information corpus (approx. 2.1M passages).
- Natural Questions (NQ): A dataset of real Google search queries.
- TriviaQA: A large-scale reading comprehension dataset.
- FlashRAG: Used for augmenting training data with high-quality answers.
Key Insights and Ideas
- The Power of Multi-Task Regularization: Surprisingly, training the model to do both retrieval and compression makes it better at both. The authors hypothesize that the retrieval loss acts as a regularizer, creating richer, more robust representations than compression training alone.
- Dynamic Loss Scaling is Essential: The "aha moment" in the training process was discovering that retrieval and generation objectives can easily overwhelm each other. The authors implemented a learned scaling parameter to balance these losses, preventing the model from "forgetting" how to retrieve while learning to generate.
- Variable-Length Efficiency: Unlike prior work that required fixed-length summaries, this model uses variable-length multi-vector embeddings. This allows the system to scale storage and compute costs based on the device's specific constraints.
Key Results
The ECG model demonstrates massive efficiency gains over "Standard RAG" (which uses raw text) and "Context Compression" (which uses separate vectors):
- Context Reduction: On the NQ dataset, the ECG model matched the performance of a standard RAG reader while using 16x less context.
- Storage Efficiency: By sharing representations, ECG requires half the storage of systems that maintain separate retrieval and compression indices.
- Performance: With a tiny budget of just 16–32 vectors per document, ECG achieved an Exact Match (EM) score of 0.343 on NQ, while a standard ColBERT RAG system at the same budget struggled at 0.106.
Limitations and Future Work
While promising, the authors note several areas for improvement:
- Domain Gap: The model was tested on Wikipedia, but the ultimate goal is personal data (emails, messages). Future work needs to validate performance on these more sensitive, idiosyncratic domains.
- Single-Document Focus: The current evaluation primarily focuses on RAG using the top-ranked document. Handling multi-document reasoning with compressed vectors remains a challenge.
- Quantization: The study did not explore 4-bit or 8-bit quantization of the vectors, which could further reduce the disk footprint by another 2-4x.
For more details, you can find the full paper "A Unified Model and Document Representation for On-Device Retrieval-Augmented Generation" published at COLM 2026.
Summary updated