[Paper Review] Learned Token Pruning for Transformers
The paper introduces Learned Token Pruning (LTP), a threshold-based token pruning method for transformers that adaptively prunes tokens per layer using learnable per-layer thresholds, achieving significant FLOPs reductions with minimal accuracy loss and improved robustness to input length variation.
Deploying transformer models in practice is challenging due to their inference cost, which scales quadratically with input sequence length. To address this, we present a novel Learned Token Pruning (LTP) method which adaptively removes unimportant tokens as an input sequence passes through transformer layers. In particular, LTP prunes tokens with an attention score below a threshold value which is learned for each layer during training. Our threshold-based method allows the length of the pruned sequence to vary adaptively based on the input sequence, and avoids algorithmically expensive operations such as top-k token selection. We extensively test the performance of LTP on GLUE tasks and show that our method outperforms the prior state-of-the-art token pruning methods by up to ~2.5% higher accuracy with the same amount of FLOPs. In particular, LTP achieves up to 2.1x FLOPs reduction with less than 1% accuracy drop, which results in up to 1.9x and 2.0x throughput improvement on Intel Haswell CPUs and NVIDIA V100 GPUs, respectively. Furthermore, we demonstrate that LTP is more robust than prior methods to variations on input sentence lengths. Our code has been developed in PyTorch and has been open-sourced.
Motivation & Objective
- Reduce inference cost of transformer models by pruning tokens adaptively per layer.
- Develop a differentiable, threshold-based pruning mechanism that avoids top-k token selection.
- Learn per-layer pruning thresholds during training and apply hard pruning at inference.
- Demonstrate efficiency gains and robustness across GLUE and SQuAD datasets.
Proposed method
- Define token importance via average attention probabilities across heads and tokens.
- Replace top-k pruning with a learnable, differentiable soft mask using a sigmoid-based threshold, enabling gradient flow to thresholds.
- Train thresholds jointly with model parameters in a soft-pruning phase, then binarize and fine-tune (three-step process).
- Introduce an L1 regularization term to encourage pruning and stabilize threshold learning.
- Show compatibility with quantization and knowledge distillation to further compress models.
Experimental results
Research questions
- RQ1Can threshold-based token pruning achieve comparable accuracy with significant FLOPs reductions across NLP tasks?
- RQ2Do learnable per-layer thresholds provide robustness to varying input sequence lengths compared to fixed pruning configurations?
- RQ3How does LTP compare to prior token pruning methods (SpAtten, LAT) in terms of accuracy vs. FLOPs?
- RQ4Is the approach compatible with other compression techniques such as quantization and distillation?
Key findings
- LTP achieves up to 2.10× FLOPs reduction with less than 1% accuracy drop on GLUE/SQuAD, and up to 1.93–1.97× throughput gains on CPU/GPU.
- LTP consistently outperforms SpAtten and LAT at the same FLOPs, with up to ~2.5% higher accuracy across tasks.
- LTP shows strong robustness to input length variations, outperforming LAT with large margins on tasks with varying sentence lengths.
- Direct hardware throughput demonstrations indicate up to ~1.9×–2.0× gains, increasing with batch size.
- Quantization and knowledge distillation can further reduce BOPs by up to 10× with minor accuracy loss when combined with LTP.
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.