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

Sabri Eyuboglu, Ryan Ehrlich, Simran Arora, Neel Guha, Dylan Zinsley +6 more
6/6/2025
cs.CLcs.AIcs.LG

No official code found. Best implementation: whymauri/GenConvo (0 stars, last commit 2025-08-14).

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.

View on arXivView PDF

Code Implementations(1)

whymauri/GenConvoCommunity56%

Replication of GenConvo dataset from Cartridges https://arxiv.org/pdf/2506.06266

00Python, Jupyter NotebookAug 7, 20251 years ago

Similar Papers

Cite this paper

@article{eyuboglu2025cartridges,
  title  = {Cartridges: Lightweight and general-purpose long context representations via self-study},
  author = {Sabri Eyuboglu and Ryan Ehrlich and Simran Arora and Neel Guha and Dylan Zinsley and Emily Liu and Will Tennien and Atri Rudra and James Zou and Azalia Mirhoseini and Christopher Re},
  year   = {2025},
  eprint = {2506.06266},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2506.06266v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2506.06266.svg)](https://codeofpaper.com/paper/2506.06266)

Discussion