Cartridges: Lightweight and general-purpose long context representations via self-study

📅 2025-06-06
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
To address the high memory overhead and low throughput caused by full-context in-context learning (ICL) in long-context question answering, this paper proposes Cartridge: a lightweight, offline-trained KV cache representation method that replaces real-time ICL inference. Its core innovation is the self-study training paradigm—jointly optimizing Cartridge via corpus-driven synthetic dialogue generation and context distillation—enabling plug-and-play composition of multiple Cartridges without retraining. Technically, Cartridge integrates KV cache compression, offline representation learning, and compositional model inference. Experiments demonstrate that Cartridge matches ICL performance on long-context benchmarks while reducing memory consumption by 38.6× and increasing throughput by 26.4×. Moreover, it extends the effective context length from 128K to 484K tokens.

Technology Category

Application Category

📝 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.
Problem

Research questions and friction points this paper is trying to address.

Reduce memory consumption of KV cache in large language models
Improve efficiency of long-context processing without ICL
Enable cost-effective querying on large text corpora
Innovation

Methods, ideas, or system contributions that make the work stand out.

Offline-trained KV cache for cost efficiency
Self-study with synthetic corpus conversations
Context-distillation for ICL replication
🔎 Similar Papers
No similar papers found.