FlexTok: Resampling Images into 1D Token Sequences of Flexible Length

Roman Bachmann, Jesse Allardice, David Mizrahi, Enrico Fini, Oğuzhan Fatih Kar +4 more
2/19/2025
cs.CVcs.LG

No official code found. Best implementation: apple/ml-flextok (335 stars, last commit 2025-06-02).

Abstract

Image tokenization has enabled major advances in autoregressive image generation by providing compressed, discrete representations that are more efficient to process than raw pixels. While traditional approaches use 2D grid tokenization, recent methods like TiTok have shown that 1D tokenization can achieve high generation quality by eliminating grid redundancies. However, these methods typically use a fixed number of tokens and thus cannot adapt to an image's inherent complexity. We introduce FlexTok, a tokenizer that projects 2D images into variable-length, ordered 1D token sequences. For example, a 256x256 image can be resampled into anywhere from 1 to 256 discrete tokens, hierarchically and semantically compressing its information. By training a rectified flow model as the decoder and using nested dropout, FlexTok produces plausible reconstructions regardless of the chosen token sequence length. We evaluate our approach in an autoregressive generation setting using a simple GPT-style Transformer. On ImageNet, this approach achieves an FID<2 across 8 to 128 tokens, outperforming TiTok and matching state-of-the-art methods with far fewer tokens. We further extend the model to support to text-conditioned image generation and examine how FlexTok relates to traditional 2D tokenization. A key finding is that FlexTok enables next-token prediction to describe images in a coarse-to-fine "visual vocabulary", and that the number of tokens to generate depends on the complexity of the generation task.

View on arXivView PDF

Code Implementations(1)

apple/ml-flextokCommunity65%

FlexTok: Resampling Images into 1D Token Sequences of Flexible Length

33519Python, Jupyter NotebookApr 1, 20251 years agoNOASSERTION

Similar Papers

Cite this paper

@article{bachmann2025flextok,
  title  = {FlexTok: Resampling Images into 1D Token Sequences of Flexible Length},
  author = {Roman Bachmann and Jesse Allardice and David Mizrahi and Enrico Fini and Oğuzhan Fatih Kar and Elmira Amirloo and Alaaeldin El-Nouby and Amir Zamir and Afshin Dehghan},
  year   = {2025},
  eprint = {2502.13967},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.13967v2},
  journal = {ICML 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.13967.svg)](https://codeofpaper.com/paper/2502.13967)

Discussion