TL;DR
ElasticTok introduces a method for adaptive visual tokenization, allowing models to encode images and videos into a variable number of tokens based on their complexity. By using a simple yet effective random masking strategy during training, the authors achieve a 2–5x reduction in token usage for long videos without sacrificing reconstruction quality, effectively solving the "one-size-fits-all" bottleneck in current vision models.
What Problem Does This Paper Address?
In the world of Large Language Models (LLMs), text is naturally variable in length. However, in computer vision, most state-of-the-art models (like Video-LLMs or World Models) tokenize every frame into a fixed number of tokens, regardless of what is happening in the scene.
This creates a lose-lose scenario:
- Under-tokenization: Simple scenes are encoded efficiently, but complex scenes (like a busy city street or fine text) become blurry and lose critical detail.
- Over-tokenization: To capture the "worst-case" complex scene, models use a massive number of tokens for every frame. This leads to prohibitively long sequences that choke memory and compute, especially for long-form video.
The authors argue that a "static wall" should require fewer tokens than a "moving person," and they propose a way to make tokenization "elastic" and context-aware.
Methods
The core innovation of ElasticTok is its training and inference strategy, which is surprisingly elegant:
- Random End-Masking: During training, for any given image or video block, the model samples a random number of tokens ($\ell$) to keep from a total budget ($N$). Crucially, it always keeps the first $\ell$ tokens and masks out the rest. This forces the encoder to prioritize the most important, global information in the earlier tokens and relegate fine-grained details to the later ones.
- Temporal Conditioning: For video, the model doesn't just look at one frame in isolation. It uses Block Causal Masking and RingAttention to condition the current frame's encoding on previous frames. If a scene is static, the model realizes it already has most of the information and can represent the new frame with very few additional tokens.
- Adaptive Inference: At test time, the user can choose how to allocate tokens:
- Target Length: Specify a fixed budget (e.g., "use 512 tokens").
- Target Threshold: Specify a quality bar (e.g., "use the minimum tokens needed to reach an MSE of 0.003"). To find this minimum, the authors tested several search strategies, including Binary Search and a Neural Regressor that predicts the required token count in a single pass.
Datasets
The models were trained and evaluated on a massive scale:
- Images: ImageNet for benchmarking and COYO-700M (a dataset of 700 million image-text pairs) for large-scale pretraining.
- Video: A custom dataset of 6 million videos (4 seconds to 2 minutes long) scraped from the web, and WebVid10M for downstream task tuning.
- Downstream Benchmarks: Evaluated on standard Vision-Language tasks including GQA (visual reasoning), POPE (object hallucination), MSVD-QA, and MSRVTT-QA (video question answering).
Key Insights and Ideas
- Inherent Priority: By always masking from the right, the model learns a "nested" representation. The first 10% of tokens might capture the layout and colors, while the last 10% capture the texture of a blade of grass.
- Complexity Correlation: The authors found a high correlation (0.77) between the number of tokens the model "wants" to use and the amount of high-frequency detail (edges and textures) in the image.
- Semantic Flexibility: Because the tokens are ordered by importance, users can adaptively trade off compute for accuracy on the fly. A robot might use few tokens for navigation but "zoom in" with more tokens when it needs to read a label.
- Context is King: In video, the "elasticity" is even more pronounced. The model effectively learns to encode the residuals—only using a high token count when there is a scene cut or fast motion.
Key Results
- Efficiency Boost: ElasticTok achieves the same reconstruction quality as fixed-token baselines while using 2x to 5x fewer tokens on average.
- Downstream Parity: When plugged into a Large Multimodal Model (like OpenLLaMA-3B), ElasticTok matches the performance of baseline models on VQA tasks while allowing users to dynamically adjust the compute budget at inference time.
- Long-Context Scaling: By leveraging RingAttention, the authors successfully scaled the model to handle sequences of up to 1 million tokens (roughly 40 seconds of high-quality video), a feat that would be impossible with standard fixed-length tokenizers.
Limitations and Future Work
- Tail-End Performance: The model slightly underperforms at the extreme ends of the token range (very few or very many tokens). The authors suspect this is due to "conflicting representations" where the model struggles to balance global and local features in a single shared latent space.
- Masking Schemes: The current "left-aligned" masking is simple but might not be optimal. Future work could explore learnable masks that decide which specific spatial regions of an image deserve more tokens.
- Perceptual Loss: To maintain stability during long-video training, the authors avoided GAN losses. This results in slightly "softer" reconstructions at very low token counts compared to models that use adversarial training.
- Beyond Vision: While focused on images and video, the "elastic" philosophy could be extended to other continuous signals like audio or robotic proprioception.
Summary updated