Skip to main content
QUICK REVIEW

[Paper Review] Toeplitz Neural Network for Sequence Modeling

Zhen Qin, Xiaodong Han|arXiv (Cornell University)|May 8, 2023
Topic ModelingComputer Science5 citations
TL;DR

This paper proposes the Toeplitz Neural Network (TNN), a sequence modeling architecture that replaces attention mechanisms with learnable Toeplitz matrices to achieve log-linear space-time complexity. By using a lightweight relative position encoder and exponential decay bias, TNN maintains consistent performance across sequence lengths up to 14K tokens, outperforming competitors on long-context tasks like Long-Range Arena while being significantly faster.

ABSTRACT

Sequence modeling has important applications in natural language processing and computer vision. Recently, the transformer-based models have shown strong performance on various sequence modeling tasks, which rely on attention to capture pairwise token relations, and position embedding to inject positional information. While showing good performance, the transformer models are inefficient to scale to long input sequences, mainly due to the quadratic space-time complexity of attention. To overcome this inefficiency, we propose to model sequences with a relative position encoded Toeplitz matrix and use a Toeplitz matrix-vector production trick to reduce the space-time complexity of the sequence modeling to log linear. A lightweight sub-network called relative position encoder is proposed to generate relative position coefficients with a fixed budget of parameters, enabling the proposed Toeplitz neural network to deal with varying sequence lengths. In addition, despite being trained on 512-token sequences, our model can extrapolate input sequence length up to 14K tokens in inference with consistent performance. Extensive experiments on autoregressive and bidirectional language modeling, image modeling, and the challenging Long-Range Arena benchmark show that our method achieves better performance than its competitors in most downstream tasks while being significantly faster. The code is available at https://github.com/OpenNLPLab/Tnn.

Motivation & Objective

  • To address the quadratic complexity bottleneck in self-attention mechanisms of Transformers for long sequence modeling.
  • To explore whether relative positional information alone can enable effective sequence modeling without content-based attention.
  • To design a parameter-efficient architecture that generalizes across variable sequence lengths without retraining.
  • To achieve strong performance and extrapolation capability on long-context benchmarks like Long-Range Arena.

Proposed method

  • Replace standard attention matrices with learnable Toeplitz matrices that encode relative positional relationships between tokens.
  • Leverage the fast Fourier transform (FFT)-based Toeplitz matrix-vector multiplication to reduce computation from O(n²) to O(n log n).
  • Introduce a lightweight relative position encoder (RPE) that generates Toeplitz coefficients with a fixed parameter budget, independent of sequence length.
  • Apply an exponential decay bias directly to the Toeplitz matrix to enable generalization to longer sequences during inference.
  • Use a gated linear unit (GLU) with Gated-Tied-Unit (GTU) for improved representational capacity in the token mixing block.
  • Formulate the TNN as a unifying framework that generalizes Transformers, CNNs, and state-space models as special cases.

Experimental results

Research questions

  • RQ1Can a sequence model achieve strong performance using only relative positional encoding, without relying on content-based attention?
  • RQ2Can a model with log-linear complexity outperform quadratic-complexity Transformers on long-context sequence modeling tasks?
  • RQ3Can a parameter-efficient architecture generalize to sequence lengths far beyond its training length, such as 14K tokens, without fine-tuning?
  • RQ4How does the proposed TNN compare to state-of-the-art models in terms of speed, memory, and accuracy on long-context benchmarks?
  • RQ5Is the TNN a unifying framework that subsumes existing architectures like Transformers and CNNs?

Key findings

  • TNN achieves a test perplexity of 23.98 on the WikiText-103 language modeling benchmark, outperforming the baseline Transformer and other efficient attention variants.
  • On the Long-Range Arena benchmark, TNN achieves the highest inference speed (25.72 steps/sec at 1K sequence length) and maintains consistent performance across all sequence lengths tested.
  • The model generalizes to 14K-token sequences in inference with an average perplexity of 23.70, even when trained only on 512-token sequences, demonstrating strong extrapolation.
  • The relative position encoder (RPE) improves performance by 2.47 PPL over a TNN variant without RPE, confirming its effectiveness in learning position-aware representations.
  • Exponential decay with rate 0.99 enables stable extrapolation, while no decay or learnable decay leads to significant performance degradation.
  • TNN is mathematically shown to generalize Transformers, CNNs, and state-space models as special cases, establishing a unified view of sequence modeling.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.