[Paper Review] Sparse Sinkhorn Attention
Sparse Sinkhorn Attention introduces a differentiable sorting mechanism to create memory-efficient, sparse attention, enabling quasi-global context via local windows and competitive performance with vanilla Transformers.
We propose Sparse Sinkhorn Attention, a new efficient and sparse method for learning to attend. Our method is based on differentiable sorting of internal representations. Concretely, we introduce a meta sorting network that learns to generate latent permutations over sequences. Given sorted sequences, we are then able to compute quasi-global attention with only local windows, improving the memory efficiency of the attention module. To this end, we propose new algorithmic innovations such as Causal Sinkhorn Balancing and SortCut, a dynamic sequence truncation method for tailoring Sinkhorn Attention for encoding and/or decoding purposes. Via extensive experiments on algorithmic seq2seq sorting, language modeling, pixel-wise image generation, document classification and natural language inference, we demonstrate that our memory efficient Sinkhorn Attention method is competitive with vanilla attention and consistently outperforms recently proposed efficient Transformer models such as Sparse Transformers.
Motivation & Objective
- Motivate reducing the quadratic memory cost of dot-product attention while learning sparse attention outputs.
- Propose a differentiable sorting-based attention mechanism that rearranges input blocks to enable quasi-global context with local computation.
- Introduce causal variants (Causal Sinkhorn Balancing) for autoregressive decoding and a dynamic encoding (SortCut) to truncate sequences.
- Explore a Mixture model combining Sinkhorn attention with standard attention to boost performance.
- Demonstrate effectiveness across language modeling, image generation, document classification, and natural language inference.
Proposed method
- Introduce a parameterized meta sorting network (SortNet) that outputs block-wise permutation matrices.
- Use differentiable Sinkhorn balancing to project sorting matrices onto the doubly stochastic (Birkhoff) polytope.
- Sort blocks rather than individual tokens to preserve local neighborhoods while enabling quasi-global attention.
- Compute attention within sorted blocks and apply a shared sorting operator to keys and values.
- Incorporate Gumbel noise and temperature to approximate discrete permutations (Gumbel-Sinkhorn).
- Optionally mix Sinkhorn attention with standard vanilla attention (Mixture model).
- Extend to causal settings with (i) causal sorting networks based on cumulative sums and (ii) causal Sinkhorn balancing with future masking.
- Provide SortCut which post-sorting truncates sequences to a budget (N_k) to further reduce complexity.
Experimental results
Research questions
- RQ1Does Sparse Sinkhorn Attention achieve competitive performance with vanilla attention while reducing memory complexity?
- RQ2How do the proposed sorting-based, sparse attention variants (Causal Sinkhorn Balancing, SortCut) impact encoding/decoding efficiency and accuracy?
- RQ3Can a mixture of Sinkhorn and vanilla attention outperform each approach alone across diverse tasks?
- RQ4How does the memory complexity of Sparse Sinkhorn Attention compare to dense attention and Sparse Transformers in practice?
- RQ5What is the effect of sorting hyperparameters (temperature, number of Sinkhorn iterations) on performance?
Key findings
- Sparse Sinkhorn Attention reduces self-attention memory from O(ell^2) to O(B^2 + N_B^2) and, with SortCut, to linear-time O(ell N_k) in some settings.
- Across tasks (algorithmic sorting, language modeling, pixel-wise generation, document classification, and NLI), Sinkhorn Transformers match or outperform vanilla Transformers and often beat Sparse Transformers and Local Attention.
- In LM1B subword modeling, Sinkhorn Transformers outperform local attention and Sparse Transformer at several block sizes, with the Sinkhorn Mixture achieving the best results.
- For image generation on CIFAR-10, Sinkhorn Transformer achieves the best bytes-per-dimension (Bpd) among tested efficient models.
- SortCut encoders can achieve comparable performance to vanilla Transformers while substantially reducing memory usage.
- Ablations show that the sorting network works best in a simple linear form and that applying Sinkhorn normalization (N_k > 0) is crucial for performance.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.