Efficient Transformers with Dynamic Token Pooling
Piotr Nawrot, Jan Chorowski, Adrian Łańcucki, Edoardo M. Ponti
TL;DR
This work tackles the inefficiency of Transformers by introducing a dynamic-pooling mechanism that learns variable-length token segments in intermediate layers, preserving autoregressive generation. A boundary predictor jointly learns segmentation and language modelling, with training signals ranging from end-to-end Gumbel-Sigmoid to supervision via Unigram tokenization, entropy spikes, or whitespace cues. Empirical results across English and morphologically diverse languages show that dynamic pooling yields faster training and improved perplexity (lower BPC) compared to vanilla and fixed-pooling Hourglass models, with whitespace and Unigram supervision performing best. The approach scales well, reduces memory and time by substantial factors at higher shortening rates, and remains competitive or superior as model depth increases, suggesting a promising path for scalable, efficient language modelling. Limitations include language dependence of boundaries (e.g., Finnish’s morphology), the restriction to contiguous segments, and the potential gains from more tightly coupled boundary decisions.
Abstract
Transformers achieve unrivalled performance in modelling language, but remain inefficient in terms of memory and time complexity. A possible remedy is to reduce the sequence length in the intermediate layers by pooling fixed-length segments of tokens. Nevertheless, natural units of meaning, such as words or phrases, display varying sizes. To address this mismatch, we equip language models with a dynamic-pooling mechanism, which predicts segment boundaries in an autoregressive fashion. We compare several methods to infer boundaries, including end-to-end learning through stochastic re-parameterisation, supervised learning (based on segmentations from subword tokenizers or spikes in conditional entropy), as well as linguistically motivated boundaries. We perform character-level evaluation on texts from multiple datasets and morphologically diverse languages. The results demonstrate that dynamic pooling, which jointly segments and models language, is both faster and more accurate than vanilla Transformers and fixed-length pooling within the same computational budget.
