Skip to content

Commit 03118b9

Browse files
Merge pull request #29 from ScalingIntelligence/cartridges-paper
Add cartridges paper
2 parents 9fb1589 + 71375da commit 03118b9

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

_pubs/cartridges.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: 'Cartridges: Lightweight and general-purpose long context representations via self-study'
3+
authors:
4+
- name: Sabri Eyuboglu
5+
equal: true
6+
affiliation: Stanford
7+
- key: ryanehrlich
8+
equal: true
9+
affiliation: Stanford
10+
- name: Simran Arora
11+
equal: true
12+
affiliation: Stanford, Caltech
13+
- name: Neel Guha
14+
affiliation: Stanford
15+
- name: Dylan Zinsley
16+
affiliation: University of Buffalo
17+
- name: Emily Liu
18+
affiliation: Stanford
19+
- name: Will Tennien
20+
affiliation: Stanford
21+
- name: Atri Rudra
22+
affiliation: University of Buffalo
23+
- name: James Zou
24+
affiliation: Stanford
25+
- key: azaliamirhoseini
26+
affiliation: Stanford
27+
- name: Christopher Ré
28+
affiliation: Stanford
29+
venue: preprint
30+
year: 2025
31+
date: 2025-06-06
32+
has_pdf: true
33+
doi: 10.48550/arXiv.2506.06266
34+
tags:
35+
- machine learning
36+
- generative ai
37+
teaser: With Cartridges, scaling test time compute can >25x decode throughput
38+
materials:
39+
- name: Paper
40+
url: https://arxiv.org/abs/2506.06266
41+
type: file-pdf
42+
- name: Codebase
43+
url: https://github.com/HazyResearch/cartridges
44+
type: code
45+
- name: Blog post
46+
url: https://hazyresearch.stanford.edu/blog/2025-06-08-cartridges
47+
type: link
48+
---
49+
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).
50+
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.
51+
We explore an alternative: training a smaller KV cache offline on each corpus.
52+
At inference time, we load this trained KV cache, which we call a Cartridge, and decode a response.
53+
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.

imgs/teasers/cartridges.png

368 KB
Loading

imgs/thumbs/cartridges.png

1.09 MB
Loading

0 commit comments

Comments
 (0)