[Paper Review] Flowformer: Linearizing Transformers with Conservation Flows
Flowformer introduces Flow-Attention based on flow conservation to linearize Transformer attention, achieving linear-time complexity with competitive performance across long sequences, language, vision, time series, and reinforcement learning.
Transformers based on the attention mechanism have achieved impressive success in various areas. However, the attention mechanism has a quadratic complexity, significantly impeding Transformers from dealing with numerous tokens and scaling up to bigger models. Previous methods mainly utilize the similarity decomposition and the associativity of matrix multiplication to devise linear-time attention mechanisms. They avoid degeneration of attention to a trivial distribution by reintroducing inductive biases such as the locality, thereby at the expense of model generality and expressiveness. In this paper, we linearize Transformers free from specific inductive biases based on the flow network theory. We cast attention as the information flow aggregated from the sources (values) to the sinks (results) through the learned flow capacities (attentions). Within this framework, we apply the property of flow conservation into attention and propose the Flow-Attention mechanism of linear complexity. By respectively conserving the incoming flow of sinks for source competition and the outgoing flow of sources for sink allocation, Flow-Attention inherently generates informative attentions without using specific inductive biases. Empowered by the Flow-Attention, Flowformer yields strong performance in linear time for wide areas, including long sequence, time series, vision, natural language, and reinforcement learning. The code and settings are available at this repository: https://github.com/thuml/Flowformer.
Motivation & Objective
- Introduce a flow-network view of attention to remove reliance on inductive biases.
- Develop Flow-Attention with source competition and sink allocation under flow conservation.
- Demonstrate linear-time attention that preserves performance across diverse domains.
Proposed method
- Reformulate attention as information flow from sources (values) to sinks (results) through learned flow capacities (attentions).
- Apply flow conservation to induce competition among sources and allocation to sinks without locality biases.
- Define Flow-Attention with competition and aggregation steps, using non-negative non-linear projection φ(·) for flow capacity.
- Normalize φ(K) by outgoing flow and φ(Q) by incoming flow to enforce flow conservation (Eq. 5).
- Compute conserved incoming/outgoing flows (Ĩ and Ŏ) and derive Flow-Attention: Competition (Softmax(Ŏ)·V), Aggregation (φ(Q)/I (φ(K)ᵀĤV)), Allocation (Sigmoid(Ĩ)⊙A) (Eq. 8).
- Replace standard attention in Transformers with Flow-Attention to obtain Flowformer with linear-time complexity.
Experimental results
Research questions
- RQ1Can attention be made non-trivial and unbiased without fixed inductive biases while achieving linear complexity?
- RQ2Does flow-conservation-based Flow-Attention provide competitive performance across long sequences, language, vision, time series, and reinforcement learning?
- RQ3What is the impact of competition and allocation components on attention quality and downstream tasks?
Key findings
- Flowformer achieves competitive or superior results versus strong baselines across long-sequence, language, vision, time-series, and offline RL benchmarks.
- In Long-Range Arena, Flowformer reaches 56.48 average accuracy, outperforming vanilla Transformer and many efficient-attention models.
- Ablations show competition and allocation each contribute to performance gains (≈1.23 and 0.90 average improvements in LRA when added respectively).
- On language modeling (WikiText-103), Flowformer achieves perplexity 30.8, better than baseline and ablations (Flowformer w/o Competition 31.2, w/o Allocation 32.2).
- On ImageNet-1K, Flowformer matches or exceeds linear-attention baselines and approaches or surpasses some full-attention models in Top-1/Top-5 accuracy.
- Flowformer demonstrates linear complexity with competitive accuracy and favorable efficiency, particularly as sequence length grows.
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.