Context Embeddings for Efficient Answer Generation in RAG
Retrieval-Augmented Generation (RAG) allows overcoming the limited knowledge of LLMs by extending the input with external information. As a consequence, the contextual inputs to the model become much longer which slows down decoding time directly translating to the time a user has to wait for an answer. We address this challenge by presenting COCOM, an effective context compression method, reducing long contexts to only a handful of Context Embeddings speeding up the generation time by a large margin. Our method allows for different compression rates trading off decoding time for answer quality. Compared to earlier methods, COCOM allows for handling multiple contexts more effectively, significantly reducing decoding time for long inputs. Our method demonstrates an inference speed-up of up to 5.69× while achieving higher performance compared to existing efficient context compression methods. Model checkpoints: https://huggingface.co/naver/cocom-v1-128- mistral-7b.
Introduction. Large Language Models (LLMs) are pre-trained on massive amounts of textual data; for instance, Llama 2 [32] has been trained on 3 trillion tokens during pre-training. Through billions of learnable parameters, LLMs not only excel at modeling language but at the same time, build up a knowledge base that could be later used for question answering. On the other hand, the model is limited to the knowledge contained in the pre-training data. In knowledgeintensive scenarios, relying solely on the parametric memory of the model is often insufficient. To alleviate this, context can be provided explicitly from an external source through a preceding retrieval step (Retrieval-Augmented Generation–RAG). Although LLMs show notable improvements when given additional relevant context in knowledge-intensive tasks, this approach has limitations. A key drawback is that adding more context to the input considerably slows down generation during inference. This occurs because the self-attention mechanism in transformers grows exponentially in space and memory requirements with increasing input length.
Discussion / Conclusion. In this paper, we presented our novel approach COCOM approach for context compression. Our main finding is that COCOM accelerates answer generation, by reducing the model’s input, by compressing multiple contexts into context embeddings that, once pre-computed serve to augment the answer generation. Our approach maximizes the potential of the LLM by tuning all components outperforming existing methods for context compression in RAG. By offering a trade-off between efficiency and effectiveness, our method allows for the selection of varying numbers of context compression tokens. This flexibility enables us to balance higher answer quality against faster generation times as needed. Unlike previous methods, our approach allows for the input of multiple contexts, which enhances generation quality and optimally makes use of the reduced decoding time. This is because only for very long inputs, the distinction between the context in token form and a reduced set of embeddings becomes most apparent.
Lines of inquiry this paper opens 24
Research framings built by reading the notes related to this paper — the questions it feeds into.
Do accumulated memories help or hurt continual learning in models?- When does training a memory model beat RAG or fine-tuning?
- Why do accumulated memory systems sometimes hurt continual learning?
- Can a memory module be swapped between different base models?
- Why do external memory consolidation systems fail worse than naive in-context learning on continual tasks?
- Can native memory procedures acquired through training handle stale or incorrect cached information?
- Does composing multiple continual learning mechanisms reduce forgetting more than single approaches?
- Does moving memory outside model weights avoid the limitations of in-weight retention?
- Can in-weight memorization scale beyond model parameter count limits?
- Why does higher agent recall make forgetting problems harder?
- What shapes of memory help frozen agents improve without retraining?
- When does persistent harmful memory create performance error floors?
- Do memory architectures genuinely close the gap between knowing and acting on preferences?
- Does recoverable content elision in context management match externalized memory benefits?
- Does memory granularity need to match the task domain or the model size?
- How does textual memory structure affect frozen model improvement?