NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Toeplitz Neural Network for Sequence Modeling

Zhen Qin, Xiaodong Han, Weixuan Sun, Bowen He, Dong Li, Yuchao Dai, Lingpeng Kong, Yiran Zhong

TL;DR

The Toeplitz Neural Network (TNN) is a novel architecture that replaces the quadratic $O(n^2)$ complexity of standard Transformer attention with a log-linear $O(n \log n)$ Toeplitz matrix-vector operation. By relying on relative position encoding rather than content-based attention, TNN achieves state-of-the-art performance on long-sequence benchmarks while being significantly faster and capable of extrapolating to sequences nearly 30x longer than those seen during training.

What Problem Does This Paper Address?

The "Transformer tax" is well-known: the self-attention mechanism scales quadratically with sequence length. This makes processing long documents, high-resolution images, or long-range time series prohibitively expensive in terms of both time and GPU memory.

While many "efficient Transformers" (like Linear Attention or Performers) have attempted to solve this, they often sacrifice performance or struggle with length extrapolation—the ability of a model trained on short sequences (e.g., 512 tokens) to maintain performance when tested on much longer ones (e.g., 14,000 tokens). The authors ask a provocative question: Can we build a powerful model that relies entirely on relative position information rather than calculating pairwise content similarities?

Methods

TNN Architecture

The core innovation is the use of Toeplitz matrices for token mixing. A Toeplitz matrix is a matrix where each diagonal descending from left to right is constant. This structure perfectly represents relative position relations: the interaction between token $i$ and token $j$ depends only on their distance $|i-j|$.

Key components include:

  • Toeplitz Neural Operator (TNO): Instead of an attention matrix, TNN uses a Toeplitz matrix $T$. Token mixing becomes a matrix-vector product $y = Tx$. Thanks to the properties of Toeplitz matrices, this can be computed in $O(n \log n)$ time using Fast Fourier Transforms (FFT).
  • Relative Position Encoder (RPE): Rather than learning the Toeplitz coefficients as static parameters (which would fix the sequence length), the authors use a lightweight MLP to generate these coefficients based on relative distance. This allows the model to handle any sequence length at inference time.
  • Exponential Decay Bias: To improve long-range stability and extrapolation, they apply a decay factor $\lambda^{|i-j|}$ to the Toeplitz coefficients, effectively telling the model to "pay less attention" to tokens that are very far away.
  • Gated Architecture: The TNO is wrapped in a Gated Toeplitz Unit (GTU), which, combined with a Gated Linear Unit (GLU), forms the basic building block of the network.

Datasets

The authors evaluated TNN across a diverse set of benchmarks:

  • Language Modeling: WikiText-103 (both autoregressive and bidirectional).
  • Long-Range Arena (LRA): A standard benchmark for efficient models including ListOps, Text, Retrieval, Pathfinder, and Image tasks.
  • Image Classification: ImageNet-1k (using a DeiT-style structure).
  • GLUE: For evaluating downstream natural language understanding.

Key Insights and Ideas

  • Unifying Sequence Models: One of the most elegant parts of the paper is the theoretical proof that TNN is a general form of sequence modeling. The authors show that CNNs, State-Space Models (like S4), and even certain Transformers can be viewed as special cases of a Toeplitz Neural Network.
  • Content vs. Position: TNN suggests that for many tasks, the relative position of tokens is a sufficient proxy for the complex content-based routing performed by standard attention. By focusing on position, the model gains massive efficiency without a significant drop in "intelligence."
  • The Power of FFT: By framing token mixing as a Toeplitz operation, the authors tap into decades of signal processing optimization. The shift to $O(n \log n)$ is what allows the model to stay "constant" in performance (log PPL) even as sequence length explodes.

Key Results

TNN Performance and Extrapolation
  • Superior Efficiency: On the Long-Range Arena benchmark, TNN outperformed all competitors, including the highly-regarded S4 model, in terms of average score (74.97 vs S4's 70.87).
  • Speed and Memory: TNN is significantly faster than vanilla Transformers. For a sequence length of 4K, TNN is roughly 2.6x faster than a standard Transformer and uses far less GPU memory.
  • Extrapolation King: In a striking result, a TNN trained on 512-token sequences maintained nearly constant perplexity when tested on sequences up to 14,336 tokens. In contrast, standard Transformers and many efficient variants see their performance collapse (perplexity goes to infinity) as soon as they exceed their training length.

Limitations and Future Work

  • Purely Positional: While TNN performs exceptionally well, there may be specific tasks where "content-to-content" addressing (e.g., "find the noun this pronoun refers to") is strictly necessary and cannot be fully captured by relative position alone.
  • Causal vs. Non-Causal: While the paper covers both, the implementation details of the Toeplitz matrix change slightly between autoregressive (triangular Toeplitz) and bidirectional tasks.
  • Scaling: While the results on ImageNet and WikiText are promising, it remains to be seen how TNN scales to the multi-billion parameter regime occupied by models like GPT-4 or Llama.

Reference: Qin, Z., Han, X., Sun, W., He, B., Li, D., Li, D., Dai, Y., Kong, L., & Zhong, Y. (2023). Toeplitz Neural Network for Sequence Modeling. ICLR 2023. GitHub Link

Summary updated

BibTeX
@inproceedings{qin2023toeplitz,
  author = {Zhen Qin and Xiaodong Han and Weixuan Sun and Bowen He and Dong Li and Dongxu Li and Yuchao Dai and Lingpeng Kong and Yiran Zhong},
  title = {{Toeplitz Neural Network for Sequence Modeling}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=IxmWsm4xrua},
}
Figure