[Paper Review] TokenLearner: What Can 8 Learned Tokens Do for Images and Videos?
TokenLearner introduces a learnable module that adaptively selects 8–16 important visual tokens from images and videos, replacing fixed patch-based tokenization in Vision Transformers. By using spatial attention to focus on salient regions and reducing the number of tokens processed at each layer, it achieves state-of-the-art performance on ImageNet and multiple video benchmarks while cutting computation and memory use by half or more.
In this paper, we introduce a novel visual representation learning which relies on a handful of adaptively learned tokens, and which is applicable to both image and video understanding tasks. Instead of relying on hand-designed splitting strategies to obtain visual tokens and processing a large number of densely sampled patches for attention, our approach learns to mine important tokens in visual data. This results in efficiently and effectively finding a few important visual tokens and enables modeling of pairwise attention between such tokens, over a longer temporal horizon for videos, or the spatial content in images. Our experiments demonstrate strong performance on several challenging benchmarks for both image and video recognition tasks. Importantly, due to our tokens being adaptive, we accomplish competitive results at significantly reduced compute amount. We obtain comparable results to the state-of-the-arts on ImageNet while being computationally more efficient. We also confirm the effectiveness of the approach on multiple video datasets, including Kinetics-400, Kinetics-600, Charades, and AViD. The code is available at: https://github.com/google-research/scenic/tree/main/scenic/projects/token_learner
Motivation & Objective
- To address the high computational cost of Vision Transformers that process thousands of fixed patches or tubelets.
- To improve efficiency and accuracy in image and video recognition by learning a small set of representative tokens instead of uniformly sampling patches.
- To enable effective modeling of long-range spatial and temporal dependencies with minimal computational overhead.
- To demonstrate that only 8–16 learned tokens can match or exceed the performance of models using hundreds of fixed tokens.
Proposed method
- TokenLearner uses a learnable spatial attention mechanism to identify important regions in input features, replacing fixed patch-based tokenization.
- It applies convolutional layers or MLPs to compute attention maps that highlight salient spatial regions in the feature map.
- The attention maps are applied to the input feature map to weight regions adaptively, followed by spatial average pooling to generate a small set of learned tokens.
- The resulting tokens are fed into a standard Transformer encoder, where they are processed via a vectorized self-attention mechanism that preserves channel-wise information.
- The module can be inserted at any layer in a Vision Transformer, allowing flexible integration and computation savings across the network.
- The method supports both image and video inputs by applying the same mechanism to spatial and spatiotemporal feature maps.
Experimental results
Research questions
- RQ1Can a small number of adaptively learned tokens replace dense patch tokenization in Vision Transformers without sacrificing performance?
- RQ2Does the use of adaptive token selection improve accuracy while reducing computational cost in image and video recognition tasks?
- RQ3How does TokenLearner compare to fixed-patch methods and other state-of-the-art models in terms of FLOPS and accuracy?
- RQ4What is the optimal placement and number of learned tokens (e.g., 8 vs. 16) for maximizing efficiency and performance?
Key findings
- TokenLearner achieves comparable ImageNet top-1 accuracy to state-of-the-art models while reducing FLOPS by over 50%.
- On Kinetics-400, Kinetics-600, Charades, and AViD, TokenLearner-based models set new state-of-the-art results with only 8–16 learned tokens per frame.
- Inserting TokenLearner early in the network (e.g., at the 2nd or 3rd layer) leads to superior accuracy and greater efficiency gains.
- The vectorized Transformer formulation with learned tokens outperforms standard multi-head self-attention (MHSA) in ablation studies, achieving 59.6% accuracy on Charades.
- The combination of TokenLearner, vectorized attention, and a TokenFuser module yields the best performance (59.6% on Charades), demonstrating the effectiveness of the full pipeline.
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.