ERNIE-SPARSE: Learning Hierarchical Efficient Transformer Through Regularized Self-Attention

Yang Liu, Jiaxiang Liu, Li Chen, Yuxiang Lu, Shikun Feng, Zhida Feng, Yu Sun, Hao Tian, Hua Wu, Haifeng WangarXiv 2022 · DOI

Abstract

ERNIE-SPARSE is a novel Transformer architecture designed to efficiently process long sequences without compromising performance. It addresses two critical limitations of existing sparse Transformers: information bottlenecks caused by limited global tokens and topological instability due to fixed sparse patterns. By introducing a Hierarchical Sparse Transformer (HST) mechanism and a Self-Attention Regularization (SAR) technique, ERNIE-SPARSE achieves state-of-the-art results on the Long Range Arena (LRA) benchmark and various downstream NLP tasks.

Introduction

Standard Transformers face a "quadratic bottleneck" where computational costs scale with the square of the sequence length ($O(N^2)$). While Sparse Transformers mitigate this by limiting token attention to local and global subsets, they suffer from two major flaws:

  1. Information Bottleneck Sensitivity: A small number of global tokens can become overwhelmed, failing to capture comprehensive context.
  2. Topological Inconsistency: Fixed sparse patterns make models sensitive to input shifts, leading to unstable attention outputs compared to dense models.

Methods

Hierarchical Sparse Transformer (HST)

To overcome the limitations of static global tokens, HST employs representative tokens for every local block. This hierarchical approach operates in two stages:

  • Local Stage: Tokens within a block interact with each other and a designated representative token.
  • Global Stage: These representative tokens, acting as block summaries, perform dense attention with one another.

This "relay" system ensures a richer information path across long sequences compared to traditional sparse methods.

Comparison of information flow and attention patterns between standard Sparse Transformer (ST) and the proposed Hierarchical Sparse Transformer (HST).

Self-Attention Regularization (SAR)

SAR addresses the instability of sparse patterns. During training, the model processes the same input using two different sparse patterns (e.g., a default and a shifted version). The model is penalized via bidirectional KL divergence if the outputs differ, forcing the network to learn representations robust to the specific attention mask geometry.

The Self-Attention Regularization (SAR) mechanism, which minimizes the KL divergence between outputs of different sparse attention patterns for the same input.

Evaluation and Results

ERNIE-SPARSE was evaluated on the Long Range Arena (LRA) benchmark, text classification (Arxiv, IMDB), and question answering (WikiHop, TriviaQA).

Key results include:

  • LRA Benchmark: Achieved an average score of 57.78%, outperforming standard Transformers (54.39%) and BigBird (55.01%).
  • QA Performance: Reached 75.76% accuracy on WikiHop, a significant improvement over BigBird’s 72.30%.
  • Pretraining Efficiency: Achieved a lower Bits Per Character (BPC) of 1.67 in Masked Language Modeling, indicating superior learning efficiency from raw text.
  • Ablation Study: Removing SAR resulted in a 3.5-point performance drop on the Pathfinder task, highlighting its importance for spatial reasoning stability.

Discussion

The success of ERNIE-SPARSE highlights that effective sparse attention requires maintaining "information bandwidth" through hierarchical structures. Furthermore, regularizing the connectivity pattern (SAR) rather than just weights or neurons provides a robust way to emulate dense model behavior at a fraction of the cost.

While highly effective, the SAR method adds slight complexity (1.03x training time increase) and requires tuning of the representative token count and loss coefficients. Future work will explore scaling ERNIE-SPARSE to billions of parameters to test hierarchical benefits at extreme scales.

Summary updated

BibTeX
@misc{liu2022ernie,
  author = {Yang Liu and Jiaxiang Liu and Li Chen and Yuxiang Lu and Shikun Feng and Zhida Feng and Yu Sun and Hao Tian and Hua Wu and Haifeng Wang},
  title = {{ERNIE-SPARSE: Learning Hierarchical Efficient Transformer Through Regularized Self-Attention}},
  year = {2022},
  eprint = {2203.12276},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.12276},
}
Figure