Skip to main content
QUICK REVIEW

[Paper Review] Block-Recurrent Transformers

DeLesley Hutchins, Imanol Schlag|arXiv (Cornell University)|Mar 11, 2022
Topic ModelingComputer Science27 citations
TL;DR

The Block-Recurrent Transformer processes long sequences by applying a transformer layer recurrently over blocks, achieving linear complexity in sequence length and substantially better perplexity on long documents with similar or lower compute than non-recurrent baselines.

ABSTRACT

We introduce the Block-Recurrent Transformer, which applies a transformer layer in a recurrent fashion along a sequence, and has linear complexity with respect to sequence length. Our recurrent cell operates on blocks of tokens rather than single tokens during training, and leverages parallel computation within a block in order to make efficient use of accelerator hardware. The cell itself is strikingly simple. It is merely a transformer layer: it uses self-attention and cross-attention to efficiently compute a recurrent function over a large set of state vectors and tokens. Our design was inspired in part by LSTM cells, and it uses LSTM-style gates, but it scales the typical LSTM cell up by several orders of magnitude. Our implementation of recurrence has the same cost in both computation time and parameter count as a conventional transformer layer, but offers dramatically improved perplexity in language modeling tasks over very long sequences. Our model out-performs a long-range Transformer XL baseline by a wide margin, while running twice as fast. We demonstrate its effectiveness on PG19 (books), arXiv papers, and GitHub source code. Our code has been released as open source.

Motivation & Objective

  • Motivate and develop a transformer architecture that retains long-range memory without quadratic attention costs.
  • Introduce a recurrent cell that operates on blocks of tokens and state vectors to enable long-context modeling.
  • Maintain computational parity with standard transformers while achieving significant perplexity improvements on long-sequence language modeling tasks.

Proposed method

  • Use sliding-window (causal) attention with a block-wise recurrence that processes segments of length N by blocks of size W.
  • Implement a recurrent cell that combines vertical (self-attention + cross-attention to recurrent states) and horizontal (state-to-state self-attention with cross-attention to inputs) directions, with gates to forget/remember information.
  • Share keys and values between vertical and horizontal directions while keeping separate queries.
  • Introduce learned state IDs and a relative position bias to stabilize training over long sequences.
  • Experiment with gate configurations (fixed gate, LSTM-style gate) and evaluate stability, scaling, and ablations.

Experimental results

Research questions

  • RQ1Does block-wise recurrence in a Transformer yield memory of very long contexts (e.g., 60k tokens) with competitive or better perplexity than Transformer-XL baselines?
  • RQ2What is the impact of recurrence gate type and state size on perplexity, training stability, and computation cost?
  • RQ3How does a single recurrent layer compare to adding more non-recurrent layers in terms of performance and cost across long-document datasets?

Key findings

  • Recurrence with a single layer yields larger perplexity gains than adding a non-recurrent layer at similar compute.
  • On PG19, arXiv, and GitHub, Block-Recurrent variants outperform Transformer-XL baselines with similar or lower step times, and can run faster than stronger wide-context baselines.
  • Best configuration (Rec:fixed:skip) often outperforms other setups and can beat XL:2048 while running more than twice as fast; it also achieves state-of-the-art word-level perplexity (26.50) on PG19 with a 1.3B parameter model.
  • Scaling results show recurrence provides benefits across model sizes, with gains growing with model size beyond doubling parameters.
  • Recurrence with one layer is typically sufficient to reap most benefits; adding more than one recurrent layer yields limited or dataset-dependent improvements.
  • Block-recurrent models can match or exceed the performance of baselines with no specialized CUDA kernels and open-source release.

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.