Reformer is a Transformer that runs fast and with little memory even on long sequences by gathering similar queries and keys into the same "bucket" with locality-sensitive hashing (LSH) and computing attention only within each bucket. Kitaev et al. at Google Research and UC Berkeley proposed it in 2020 in the paper "Reformer: The Efficient Transformer" (ICLR 2020).
Standard multi-head attention computes weights for every pair of tokens in a sequence of length , so its computation and memory grow in proportion to . In the paper's example, for a sequence of length 64K takes 16 GB in 32-bit floats even with a batch size of 1.
Reformer starts from the property that the result of a softmax is dominated by its largest values. What matters for each query is only the few keys with large dot products (similar directions), so if those nearby keys can be found quickly, the remaining pairs need not be computed. Hashing takes on this job of "finding what is close."
Besides attention, Reformer combines two more techniques for reducing memory.
| Technique | What it reduces |
|---|---|
| LSH attention | Turns the of attention into |
| Reversible residual layers | Activations stored per layer for backpropagation shrink to one copy for the whole model (the factor of the number of layers disappears) |
| Chunking the feed-forward layers | Activations of the intermediate width are computed a piece at a time by splitting the sequence |
As a library analogy: instead of comparing every book with every other book one by one, books with similar content are shelved together, and only books on the same shelf are compared.
The right side of the figure at the top of the article shows the essence of LSH attention. When tokens are sorted by bucket and split into chunks of fixed length, pairs in the same bucket gather near the diagonal. Only that region is computed.

