TL;DR
Core Context Aware (CCA) Attention is a plug-and-play module designed to scale Large Language Models (LLMs) to long contexts (up to 128K tokens) efficiently. By dynamically compressing redundant global information into compact "core tokens" while preserving fine-grained local context, CCA-Attention achieves up to a 7.9× inference speedup and slashes KV cache memory usage from 64GB to 4.5GB with minimal fine-tuning.
What Problem Does This Paper Address?
As LLMs are tasked with processing increasingly long documents, standard Transformer self-attention hits a wall. Its computational complexity scales quadratically ($O(L^2)$) with sequence length, and the Key-Value (KV) cache rapidly consumes available GPU memory.
Furthermore, massive contexts inherently contain a lot of noise and redundancy. In long sequences, attention maps become highly sparse—only a fraction of the tokens actually contribute to predicting the next word. Existing methods try to solve this by using fixed sparse attention patterns (e.g., only looking at the first few and last few tokens). However, because crucial information can be scattered anywhere in a document, these rigid patterns often drop vital context, leading to incomplete comprehension.
Methods
The authors introduce Core Context Aware (CCA) Attention, a standalone operator implemented in Triton that replaces standard self-attention. It consists of two main components:
- Globality-Aware Pooling Module: The input sequence is divided into small token groups of size $g$. Instead of keeping every token in the KV cache, a group-wise weighted pooling strategy uses the last token of each group as a proxy query to evaluate token importance. The group is then compressed into a single, highly informative core token. This reduces global attention complexity to a linear relationship with sequence length.
- Locality-Preserving Module: To ensure the model doesn't lose fine-grained details, a sliding window of size $s$ allows each query token to attend to its immediate neighbors normally.
Finally, the key and value matrices from both modules are differentiably fused via concatenation before computing the final attention output.
Datasets
- Training: Continuous pre-training/fine-tuning was performed using SlimPajama (a 627B token cleaned version of RedPajama).
- Evaluation:
- LongBench & LongBench-E: For bilingual, multi-task long-context understanding.
- Lost in the Middle dataset: Used to calculate Exact Match (EM) scores for multi-document question answering.
- MMLU: To ensure short-context common-sense reasoning capabilities were preserved.
- Proof-pile: For evaluating language modeling perplexity (PPL).
Key Insights and Ideas
- The Last Token is a Great Proxy: The authors discovered that within a local chunk of text, the final token's attention weights serve as an excellent indicator of which preceding tokens carry the core semantic weight of that group.
- Inference Elasticity: Because the group size ($g$) and local window size ($s$) are adjustable parameters, CCA-Attention introduces architectural flexibility at runtime. Engineering teams can dynamically adjust these parameters to trade a tiny bit of accuracy for massive throughput gains during peak user traffic periods without retraining the model.
Key Results
- Massive Speedups: When processing 128K token contexts on NVIDIA A800 GPUs, CCA-Attention achieved a 7.9× inference speedup in the pre-filling stage compared to vanilla self-attention.
- KV Cache Drastically Reduced: For LLaMA2-7B-80K at a 128K context length, the KV cache footprint plummeted from 64GB to just 4.5GB, making long-context deployment significantly cheaper.
- State-of-the-Art Accuracy: On LongBench-E, CCA-LLM outperformed other efficient attention frameworks like StreamingLLM, LM-Infinite, and MInference, showing that its dynamic compression retains more task-relevant information than static token-dropping methods.
Limitations and Future Work
- Fine-Tuning Required: While it is a "plug-and-play" module with a low training footprint (requiring only 2.1B tokens for 32K context adaptation), it still requires some continuous pre-training to perform optimally compared to purely training-free methods.
- Hyperparameter Tuning: The optimal balance of group size $g$ and window size $s$ currently depends on empirical testing. Future work could explore methods to make these parameters automatically adaptive based on the complexity of the input text.
Summary updated