Introduction
The standard Transformer architecture faces a significant scalability challenge due to its quadratic complexity: memory and computational requirements grow at a squared rate relative to the input sequence length. While various "sparse" Transformers have been proposed to mitigate this, many still necessitate the calculation of a full $O(n^2)$ matrix simply to determine which elements to ignore. This paper introduces Sparsefinder, a novel framework designed to predict the sparsity pattern of $\alpha$-entmax attention in a low-dimensional space, effectively bypassing redundant computations.
Methodology: The Sparsefinder Framework
Sparsefinder treats a pretrained $\alpha$-entmax Transformer as a "teacher" to learn its inherent sparsity patterns. Unlike standard softmax, $\alpha$-entmax naturally produces exact zeros for irrelevant tokens, creating a sparse graph.
The framework operates through three primary stages:
- Low-Dimensional Projection: High-dimensional query ($q$) and key ($k$) vectors (e.g., $d=64$) are projected into a significantly smaller space (e.g., $r=4$) using a linear layer. This is trained via a contrastive hinge loss to ensure active pairs are proximal in the low-dimensional space.
- Prediction Strategies: The authors explore three methods for identifying attention edges:
- Distance-based: Connecting pairs within a specific Euclidean distance threshold.
- Quantization: Using buckets to group queries and keys.
- Clustering: Employing $k$-means to restrict attention to intra-cluster pairs.
- Hybrid Pattern Integration: To ensure high recall, learned patterns are augmented with fixed local (sliding window) and global (e.g.,
[CLS]token) attention patterns.
Evaluation and Datasets
The researchers evaluated Sparsefinder across two core NLP tasks:
- Machine Translation (MT): Using the IWSLT17 dataset (English to German/French) with a Transformer-Large architecture.
- Masked Language Modeling (MLM): Finetuning a RoBERTa-base model on WikiText-103. The projection layers were trained on small data subsets, demonstrating the method's data efficiency.
Results and Analysis
Sparsefinder consistently achieves a superior balance between efficiency and accuracy, often residing on the "Pareto frontier" of the sparsity-recall tradeoff.
Key findings include:
- Performance Dominance: The distance and $k$-means variants of Sparsefinder outperformed established models such as Reformer, Routing Transformer, and BigBird.
- Scalability: In MT tasks, Sparsefinder maintained high BLEU scores even after pruning over 80% of attention connections.
- Linguistic Interpretability: Qualitative analysis revealed that the model learns to group tokens by linguistic function, such as linking coreferent pronouns or grouping verbs and nouns.
Conclusion and Future Work
Sparsefinder offers a mathematically grounded approach to attention sparsity, leveraging the properties of $\alpha$-entmax to achieve theoretical efficiency gains of up to 16x. However, realizing these gains in "wall-clock" time currently depends on the availability of optimized GPU kernels for unstructured sparsity. Future research directions include end-to-end training of the sparsity predictor and exploring non-linear projection methods to capture more complex attention dynamics.
Summary updated