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.
#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.
Block-based compression and pooling old K/V states
Pooling combines several vectors into one summary, here their componentwise mean. For block size :
Each compressed key and value averages a block of historical entries.
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 , recent width , and block size , with divisible by :
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
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.
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.