Highlights

Contents

Part III
03

Keeping a smaller past

Old history can be summarized instead of retained exactly. That reduces distinctions as well as storage. Keep recent entries explicit and test what distant information survives the chosen compression.

THE ARCHITECTURE INVESTIGATIONCost + future tokens01Sparse connections02Compressed history03Latent memory04Compare KV designs05Speculative decoding06Controlled experiment07Interpret + decide08

#Section 9Compressed attention

The next word depends on a variable declared near the top of a long file, and a short local window has already dropped it. Keeping a smaller representation of old material sits between remembering every token and forgetting it.

Exact recent context and compressed old context

Compressed attention lets queries read a reduced representation of part of their history. Our teaching design keeps exact recent K/V entries and pools old K/V blocks. Part IV instead compresses the feature dimensions of every token.

The recent region keeps the original attention states. The historical region stores fewer entries, each standing for several old positions, and queries attend over both. The decoder must be trained with this memory, or it will expect information that is no longer there.

KEEP RECENT POSITIONS; SUMMARIZE OLDER BLOCKS768 historical positions256 recent positionshistorical blocks (schematic)96 summary entries256 exact entries352 entries represent a 1,024-position past
Figure 6.9Illustrative memory at length 1,024 keeps 256 recent entries and compresses 768 old entries in blocks of 8. The 96 compressed blocks are drawn schematically, not as 96 boxes.

Block-based compression and pooling old K/V states

Pooling combines several vectors into one summary, here their componentwise mean. For block size bb:

kˉj=1b∑i∈Bjki,vˉj=1b∑i∈Bjvi.\bar k_j=\frac{1}{b}\sum_{i\in \mathcal B_j}k_i, \qquad \bar v_j=\frac{1}{b}\sum_{i\in \mathcal B_j}v_i.

Each compressed key and value averages a block of historical entries.

MEAN POOLING COLLAPSES TWO DISTINCT LOOKUP CHOICESkeys1032componentwise mean21values4286componentwise mean64the average cannot tell you which value belonged to which key
Figure 6.10All entries in this illustrative mean-pooling example are computed. Two positions become one key and one value, so their separate identities are lost.

Pooling before softmax removes the choice between individual contents. Attention over one average cannot reproduce independently scoring and selecting the original entries.

Rae and colleagues' Compressive Transformer (2019) learned compressed memory with auxiliary objectives; our mean pooling isolates one mechanism and does not reproduce it. Compressive Transformer paper.

#Section 10Compressed KV memory

The cache fits at length 1,024 but not at the deployment's larger batch. How much could block compression save, and what must the runtime maintain?

Recent KV and historical compressed KV

Compressed KV memory stores fewer attention states for historical context. The runtime keeps an exact recent buffer and a historical buffer. When a full block leaves the recent region, it is summarized, appended to history, and its exact entries are released.

For T≥wT\ge w, recent width ww, and block size bb, with T−wT-w divisible by bb:

M=w+T−wb.M=w+\frac{T-w}{b}.

Keep recent entries individually and summarize older blocks. When the sequence fits entirely in the recent window, nothing needs compression.

Memory reduction and information loss

SAME FEATURE WIDTH, FEWER TOKEN ENTRIESfull4,194,304 bytes = 4 MiBcompressed1,441,792 bytes = 1.375 MiBorange: 256 exact entries; slate: 96 summaries
Figure 6.11Computed Finch payloads separate exact recent memory from compressed history. Compression reduces token entries; the width of each stored key and value is unchanged.

At fixed block size, history still grows linearly with length: smaller, not bounded. Recursive compression or dropping old summaries bounds it further but changes the contract again. Block size 1 compresses nothing, and a window covering the whole sequence leaves nothing to compress.

Partial blocks need a rule. Keep their exact states until the block completes, and store boundaries or counts if later logic uses them. A summary may become visible only once all its positions are in the query’s past; exposing a precomputed block to a query inside it leaks the future during training.

#Section 11Evaluating long-context compression

A compressed model writes a fluent paragraph about a document but misses one account number buried in it. Fluency alone does not show that memory kept the details the task needed.

Copy tasks and needle-in-a-haystack tests

A copy task asks the model to reproduce an earlier sequence exactly, stressing token identity. A needle-in-a-haystack test hides a known fact among unrelated text and asks for it later. Vary length and insertion depth, especially across the recent-to-compressed boundary.

MOVE THE FACT; KEEP THE QUESTION AND ANSWER FIXEDold blockqueryboundaryqueryrecent spanquery"What was the reservation key?"
Figure 6.12A schematic retrieval test moves the same fact between old compressed history and the recent region. The answer stays fixed, so a change in score reflects memory access, not a different question.

Break retrieval scores down by insertion depth. An overall average can hide failures in the middle or oldest compressed region.

Long-range retrieval and compression quality

Compression quality is how well the reduced memory keeps the information declared tasks need at a declared budget. Test exact facts, multiple facts, ordering, distractors, dependencies between distant passages, and held-out loss. A summary that keeps the topic may still fail exact copying.

RULER (2024) varies the work the context must support, not just its length. RULER paper. Liu and colleagues showed that results depend on where the relevant information sits. Lost in the Middle paper.

Compare variants on identical queries and generation settings. Measure accuracy, retained memory, compression overhead, prefill, and decode; entry count alone does not pick a winner.