TL;DR
Block-State Transformers (BST) introduce a novel hybrid architecture that merges the long-range computational efficiency of State Space Models (SSMs) with the powerful local processing capabilities of Transformers. By replacing sequential recurrence with parallelizable SSMs, BST achieves a 10x speedup over previous recurrent-block models while improving performance on language modeling tasks for sequences up to 65,000 tokens.
The Long-Context Bottleneck
Standard Transformers are the undisputed kings of language modeling, but they suffer from a well-known "long-tail" problem: their computational cost grows quadratically ($O(L^2)$) with the sequence length ($L$). This makes processing very long documents—like entire books or massive codebases—prohibitively expensive.
To circumvent this, researchers have historically explored two main workarounds:
- Recurrent Models: These process data in blocks and pass a "memory" state forward. While memory-efficient, they are inherently sequential, meaning training cannot be easily parallelized across a sequence.
- State Space Models (SSMs): These use linear dynamical systems to model sequences in sub-quadratic time ($O(L \log L)$). They excel at long-range tasks (such as the Long Range Arena benchmark) but often lag behind standard Transformers in actual language modeling quality.
The authors of this paper aim to bridge this gap, designing a model that is as fast and long-sighted as an SSM, yet as contextually "smart" as a Transformer.
Methods: The Block-State Transformer Layer
The core innovation of this work is the Block-State Transformer (BST) layer. Instead of a standard Transformer layer, a BST layer consists of two specialized internal sublayers working in tandem.
- The SSM Sublayer (Global Context): This acts as the model's "long-term memory." It processes the entire input sequence at once using a State Space Model (specifically variants like S4). Because SSMs can be computed as convolutions via Fast Fourier Transforms (FFTs), this step is highly parallelizable. It produces a "context sequence" of the same length as the input.
- The Block Transformer Sublayer (Local Focus): The input sequence is divided into small, manageable blocks (windows). Each block uses traditional self-attention to understand local context, and cross-attention to integrate the global context states produced by the SSM.
By relying on the SSM to handle the global context, the Transformer sublayer only needs to look at small local blocks. This keeps the overall complexity at $O(W^2 + L \log L)$, where $W$ is the small window size.
The authors tested three variants of how the SSM provides this context:
- Single-Head (SH): A single SSM filter projected to multiple attention heads.
- Multi-Head (MH): Separate SSM parameters for each attention head.
- Multi-Filter (MF): Multiple independent SSM kernels where only the last state of the previous window is used as context.
Key Insights and Results
The models were evaluated on several large-scale datasets known for long-range dependencies, including PG19 (books), arXiv (scientific papers), GitHub (source code), and the Long Range Arena (LRA) benchmark.
- Parallelism is the Killer App: The biggest advantage of BST over previous "Block-Recurrent" models is the removal of the sequential bottleneck. Because the SSM provides context for the entire sequence at once, the entire layer can be computed in parallel on modern hardware. This resulted in a 10x increase in speed at the layer level compared to the Block-Recurrent Transformer (BRECT) when using model parallelization.
- Complementary Strengths: SSMs and Transformers prove to be natural partners. SSMs provide a "blurry" but efficient global view, while Transformers provide the "sharp" local focus needed for precise language prediction. BST outperformed similar hybrid models (like GSS-Hybrid) by 1.5% to 4% in perplexity across the tested datasets.
- Retrievability vs. Redundancy: The "Single-Head" (SH) variant, despite being the most redundant (passing many similar states), often performed best on language modeling. This suggests that having "easy-to-find" redundant information helps the attention mechanism retrieve the right context.
- Length Generalization: Models trained on 4k-token sequences were able to generalize effectively to 65k-token sequences at inference time without a massive spike in error (perplexity), particularly the variant using the structured S4 kernel. Furthermore, the BST-SH-S4 model achieved a new state-of-the-art average score (86.96) on the LRA benchmark among models using chunked input sequences.
Limitations and Future Work
While highly effective, the architecture has a few limitations to address in future research:
- FFT Bottlenecks: While theoretically fast, FFT operations (the engine behind SSMs) can be a speed bottleneck on certain hardware like TPUs, though they remain highly efficient on GPUs.
- State Compression: A single vector representation from an SSM might eventually "forget" granular details in extremely long sequences. The authors suggest exploring "top-k retrieval" (similar to Memorizing Transformers) to pick the most relevant SSM states dynamically.
- Inter-sequence Cache: Unlike some recurrent models, the current BST lacks a mechanism to carry information across different training sequences (e.g., from one 4k chunk of a book to the next 4k chunk). Adding a non-differentiable cache could further improve performance on massive documents.
Summary updated