Smart Bird: Learnable Sparse Attention for Efficient and Effective Transformer

Chuhan Wu, Fangzhao Wu, Tao Qi, Binxing Jiao, Daxin Jiang, Yongfeng HuangarXiv 2021

Abstract

Smart Bird is a novel Transformer architecture designed to address the quadratic computational complexity of standard self-attention. By implementing a "sketch-and-sample" mechanism, Smart Bird utilizes a low-dimensional, single-head Transformer to identify significant token interactions, which then guide a sparse high-dimensional attention process. This learnable sparsity allows the model to capture context-specific, long-range dependencies more effectively than fixed heuristic patterns. Experimental results across various long-sequence NLP benchmarks demonstrate that Smart Bird achieves superior performance and efficiency compared to existing sparse Transformer variants.

Introduction

The self-attention mechanism is the cornerstone of the Transformer's success, enabling every token in a sequence to attend to every other token. However, this flexibility comes at a high cost: computational complexity grows quadratically ($O(N^2)$) with the sequence length ($N$). This limitation makes processing long documents—such as books, legal filings, or scientific papers—prohibitively expensive in terms of both memory and time.

To mitigate this, existing research has largely focused on heuristic sparsity patterns, such as fixed sliding windows, strided patterns, or random selections. While efficient, these "blind" patterns often fail to capture critical, long-range dependencies that are specific to the context of the input text. Smart Bird addresses this by introducing a mechanism to learn which token pairs are important without incurring the full $O(N^2)$ cost in high-dimensional space.

The Smart Bird Architecture

The core innovation of Smart Bird is a two-stage "sketch-and-sample" approach that dynamically identifies important attention patterns.

1. Sketched Attention

The model first employs a "tiny" single-head Transformer with extremely low hidden dimensions (e.g., $d=4$). This tiny model computes a "sketched" attention matrix. Despite its low dimensionality, this operation captures the essential structural relationships between tokens. Because the dimensionality is so small, the $O(N^2)$ operation remains computationally lightweight.

2. Attentive Token Sampling

Rather than simply selecting the top-scoring pairs from the sketch, Smart Bird utilizes a probabilistic sampling method. Sketched attention weights are transformed into sampling probabilities using a squared inverse log function. This "sharpening" of the distribution helps distinguish truly informative interactions from background noise, allowing for a more robust selection of token pairs.

3. Sparse High-Dimensional Attention

For each head in the main, high-dimensional Transformer, the model samples $K$ tokens per row based on the probabilities derived from the sketch. The heavy-duty attention computation is then performed only on these selected sparse pairs, maintaining high representational capacity while significantly reducing total operations.

The overall framework of Smart Bird, showing the transition from a low-dimensional sketch to high-dimensional sparse attention.

Experimental Evaluation

The authors evaluated Smart Bird across six diverse NLP benchmarks requiring long-sequence processing, including AG's News, Amazon Electronics, IMDB, MIND, CNN/DailyMail, and PubMed (where average document length exceeds 3,000 words).

Key Insights

  • Low-Dimensional Structural Fidelity: A key discovery is that a tiny 4-dimensional attention head can learn structural patterns remarkably similar to a full 256-dimensional head. The Pearson correlation between their attention matrices is 0.67, suggesting that the "sketch" is a reliable proxy for full attention.
  • Sampling vs. Selection: Probabilistic sampling was found to be superior to simple "Top-K" selection. Sampling encourages exploration of a wider variety of interactions, preventing the model from over-relying on potentially noisy estimates from the sketching phase.
  • Context-Awareness: Unlike models with fixed patterns (e.g., BigBird), Smart Bird’s attention is data-dependent, allowing it to adapt its focus based on the specific content of the input.

Results

Smart Bird consistently outperformed vanilla Transformers and efficient variants like Longformer and BigBird across all tested tasks. On the PubMed summarization task, it achieved a ROUGE-L score of 35.49, surpassing BigBird's 34.53.

In terms of efficiency, Smart Bird demonstrates significant advantages as sequence length increases. While vanilla Transformers often encounter memory limits or extreme slowdowns at lengths of 4,096 tokens, Smart Bird maintains manageable training times and high accuracy.

Model accuracy across different text lengths. Smart Bird (d=4, d=8) consistently outperforms BigBird and standard Transformers as sequences grow.

Conclusion and Future Work

Smart Bird presents a compelling solution to the Transformer's scaling problem by making sparsity learnable and context-aware. While the sketching step is still technically $O(N^2)$, its low dimensionality makes it practical for current long-sequence tasks. Future work may involve further accelerating the sketching phase using low-rank approximation techniques to achieve truly linear complexity, and exploring the model's performance in large-scale generative pre-training.

Summary updated

BibTeX
@misc{wu2021smart,
  author = {Chuhan Wu and Fangzhao Wu and Tao Qi and Binxing Jiao and Daxin Jiang and Yongfeng Huang},
  title = {{Smart Bird: Learnable Sparse Attention for Efficient and Effective Transformer}},
  year = {2021},
  eprint = {2108.09193},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2108.09193},
}
Figure