[Paper Review] Dynamic Context Pruning for Efficient and Interpretable Autoregressive Transformers
The paper introduces Adaptively Sparse Attention that dynamically prunes past context in decoder-only Transformers, enabling up to 80% context removal with minimal perplexity loss and up to 2x inference throughput gains.
Autoregressive Transformers adopted in Large Language Models (LLMs) are hard to scale to long sequences. Despite several works trying to reduce their computational cost, most of LLMs still adopt attention layers between all pairs of tokens in the sequence, thus incurring a quadratic cost. In this study, we present a novel approach that dynamically prunes contextual information while preserving the model's expressiveness, resulting in reduced memory and computational requirements during inference. Our method employs a learnable mechanism that determines which uninformative tokens can be dropped from the context at any point across the generation process. By doing so, our approach not only addresses performance concerns but also enhances interpretability, providing valuable insight into the model's decision-making process. Our technique can be applied to existing pre-trained models through a straightforward fine-tuning process, and the pruning strength can be specified by a sparsity parameter. Notably, our empirical findings demonstrate that we can effectively prune up to 80\% of the context without significant performance degradation on downstream tasks, offering a valuable tool for mitigating inference costs. Our reference implementation achieves up to $2 imes$ increase in inference throughput and even greater memory savings.
Motivation & Objective
- Motivate reducing memory and compute bottlenecks for long-context autoregressive Transformers without sacrificing expressivity.
- Propose a learnable, layer-wise mechanism to prune uninformative past tokens during generation.
- Enable integration with pre-trained models via lightweight fine-tuning and a sparsity-controlled mechanism.
- Quantify trade-offs between sparsity, perplexity, and zero-shot performance across GPT-2 variants.
Proposed method
- Introduce adaptively sparse attention with interaction queries/keys per layer via W_Q_int and W_K_int.
- Compute token-wise interaction indicators I_{k,j}^l using a sparse sigmoid (alpha-sigmoid) to decide trimming, ensuring causality.
- Use a layer-wise pruning scheme where dropped tokens are permanently ignored in subsequent steps.
- Augment the language modeling objective with a sparsity regularizer L_sparsity to encourage dropping.
- Implement an efficient batched data structure to remove dropped tokens from the key-value cache, enabling memory and throughput gains.
- Fine-tune pretrained GPT-2 models with the proposed mechanism and a cosine schedule for alpha to control sparsity at inference.

Experimental results
Research questions
- RQ1Can dynamic, layer-wise pruning maintain model expressivity while reducing context length during autoregressive generation?
- RQ2What is the impact of adaptive sparsity on perplexity and zero-shot performance across GPT-2 variants?
- RQ3How do memory usage and throughput change as context size grows, under adaptive pruning?
- RQ4How interpretable are the token-drop decisions across layers and types of tokens (e.g., punctuation, stop words)?
Key findings
- Up to 80% of the context can be pruned with no performance loss in perplexity for certain context sizes.
- Adaptive pruning yields significant memory reductions and up to 50% wall-time latency reductions for long contexts, enabling larger batch sizes.
- Throughput gains exceed 2x in some settings, with substantial memory savings.
- Zero-shot performance is preserved or even improved under sparsity for multiple tasks.
- Pruning tends to remove punctuation and stop words, offering interpretability into layer-specific decision patterns.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.