[2506.06266] Cartridges: Lightweight and general-purpose long context representations via self-study
Abstract:Large language models are often used to answer queries grounded in large text corpora (e.g. codebases, legal documents, or chat histories) by placing the entire corpus in the context window and leveraging in-context learning (ICL). Although current models support contexts of 100K-1M tokens, this setup is costly to serve because the memory consumption of the KV cache scales with input length. We explore an alternative: training a smaller KV cache offline on each corpus. At inference time, we load this trained KV cache, which we call a Cartridge, and decode a response. Critically, the cost of training a Cartridge can be amortized across all the queries referencing the same corpus. However, we find that the naive approach of training the Cartridge with next-token prediction on the corpus is not competitive with ICL. Instead, we propose self-study, a training recipe in which we generate synthetic conversations about the corpus and train the Cartridge with a context-distillation objective. We find that Cartridges trained with self-study replicate the functionality of ICL, while being significantly cheaper to serve. On challenging long-context benchmarks, Cartridges trained with self-study match ICL performance while using 38.6x less memory and enabling 26.4x higher throughput. Self-study also extends the model's effective context length (e.g. from 128k to 484k tokens on MTOB) and surprisingly, leads to Cartridges that can be composed at inference time without retraining.
# link_21vapqdy5ff.pdf ## Metadata - PDFFormatVersion=1.5 - IsLinearized=false - IsAcroFormPresent=false - IsXFAPresent=false - IsCollectionPresent=false - IsSignaturesPresent=false - Author=Sabri Eyuboglu; Ryan Ehrlich; Simran Arora; Neel Guha; Dylan Zinsley; Emily Liu; Will Tennien; Atri Rudra; James Zou; Azalia Mirhoseini; Christopher Re - Creator=arXiv GenPDF (tex2pdf:) - Custom.DOI=https://doi.org/10.48550/arXiv.2506.06266 - Custom.License=http://creativecommons.org/licenses/by/4.0/ - Custom.PTEX.Fullbanner=This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) kpathsea version 6
Explore this link on the map →saved by
related reading
- [2605.15156] MeMo: Memory as a Modelarxiv.org
- Self-Adapting Language Modelsarxiv.org
- Recursive Language Models | Alex L. Zhangalexzhang13.github.io
- Why We Need Continual Learning | Andreessen Horowitza16z.com
- Reimagining LLM Memory: Using Context as Training Data Unlocks Models That Learn at Test-Time | NVIDIA Technical Blogdeveloper.nvidia.com
- Subquadratic — How SSA Makes Long Context Practicalsubq.ai
- Extending Context is Hard | kaiokendevkaiokendev.github.io
- LLMs can invent their own compression - Rajan Agarwalrajan.sh
- The Continual Learning Problemjessylin.com
- How does in-context learning work? A framework for understanding the differences from traditional supervised learning | SAIL Blogai.stanford.edu
- [2412.02252] Compressing KV Cache for Long-Context LLM Inference with Inter-Layer Attention Similarityarxiv.org
- Getting Caught Up to Modern LLM Research | Samarth Goeldev.samarthgoel.com