Efficient Transformers with Dynamic Token Pooling

Piotr Nawrot, Jan Chorowski, Adrian Lancucki, Edoardo Maria Ponti

Abstract

The standard Transformer architecture faces a significant efficiency bottleneck due to the quadratic complexity of self-attention relative to sequence length. While fixed-length pooling methods like the Hourglass Transformer offer some relief, they fail to account for the non-uniform nature of linguistic information. This paper introduces the Dynamic-Pooling Transformer, which utilizes a boundary predictor to group tokens into variable-length segments aligned with natural linguistic units. Our results demonstrate that dynamic pooling shifts the Pareto front of the accuracy-efficiency trade-off, outperforming both vanilla and fixed-pooling Transformers across diverse languages.

Introduction: The Efficiency Bottleneck

The self-attention mechanism, central to modern Large Language Models, scales quadratically ($O(l^2)$) with input length. To mitigate this, researchers previously developed "Hourglass Transformers" that pool tokens into fixed-size blocks (e.g., every 4 tokens) in intermediate layers, reducing the computational load. However, language is hierarchical and non-uniform; words, morphemes, and phrases vary in length. Forcing these into rigid buckets treats high-entropy segments the same as low-information ones, leading to sub-optimal representations.

Architecture and Methodology

The proposed model extends the Hourglass architecture by replacing fixed pooling with a learnable Dynamic Boundary Predictor.

The Dynamic-Pooling Transformer architecture. A boundary predictor determines segment lengths, allowing the model to pool tokens into variable-sized representations (s) before processing them through shortened Transformer layers.

The system consists of three primary components:

  1. Encoder: Processes the initial full-resolution sequence.
  2. Shortened Block: Operates on a pooled sequence at a reduced resolution, where the pooling boundaries are determined dynamically.
  3. Decoder: Up-samples the compressed representations back to the original sequence length for autoregressive prediction.

The authors explored several strategies for boundary prediction, including Gumbel-Sigmoid (end-to-end learning), Subword Supervision (mimicking tokenizers like Unigram), and Entropy Spikes (placing boundaries where conditional entropy is high). To maintain the autoregressive property, a shifting mechanism is used during up-sampling to ensure no future information leaks into current predictions.

Performance and Efficiency

The model was evaluated on character-level language modeling across English (text8, wiki40b), Finnish (agglutinative), Hebrew (introflexive), and Vietnamese (isolating).

Performance comparison (BPC vs. Shortening factor). Dynamic pooling (Gumbel and Unigram) consistently maintains lower BPC as the shortening factor increases compared to fixed-length pooling across multiple datasets.

Key Results:

  • Pareto Front Shift: As shown in the figure above, dynamic pooling methods (orange and green) maintain significantly lower Bits Per Character (BPC) than fixed pooling (blue) as the sequence is shortened. This indicates a superior trade-off between compression and accuracy.
  • Speed and Memory: On the English text8 dataset, the model achieved a 2.5x training speedup and reduced memory usage by over 50% compared to a vanilla Transformer, while maintaining or improving accuracy.
  • Cross-Lingual Robustness: The model adapts to different linguistic structures. While whitespace-based pooling is effective for English, Unigram-based supervision proved superior for morphologically complex languages like Finnish.

Discussion and Future Work

The success of dynamic pooling suggests that aligning computation with the inductive bias of language—processing it in meaningful chunks—is more efficient than uniform processing. Methods like "Entropy Spikes" are particularly promising as they are modality-agnostic, potentially extending these benefits to speech and vision Transformers where natural units (like phonemes or objects) also vary in size.

Current limitations include the restriction to contiguous segments, which may be sub-optimal for languages with non-contiguous roots like Hebrew. Future research will focus on capturing longer-range hierarchical structures and applying these dynamic mechanisms to non-textual data.

Summary updated

BibTeX
@inproceedings{nawrot2023efficient,
  author = {Piotr Nawrot and Jan Chorowski and Adrian Lancucki and Edoardo Maria Ponti},
  title = {{Efficient Transformers with Dynamic Token Pooling}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.353},
}
Figure