SAMTok: Representing Any Mask with Two Words

TL;DR

SAMTok discretizes masks into two tokens, enabling pixel-level understanding without architectural changes.

cs.CV 🔴 Advanced 2026-01-23 42 views
Yikang Zhou Tao Zhang Dengxian Gong Yuanzheng Wu Ye Tian Haochen Wang Haobo Yuan Jiacong Wang Lu Qi Hao Fei Anran Wang Zhuochen Wang Yujing Wang Cheng Chen Shunping Ji Xiangtai Li
multimodal pixel-wise understanding mask tokenization reinforcement learning vision-language

Key Findings

Methodology

SAMTok employs a residual vector quantizer to encode any region mask into two discrete tokens, integrated with SAM2's mask encoder for high-fidelity reconstruction. By treating masks as new language tokens, the model uses standard autoregressive next-token prediction and reinforcement learning to train base multimodal large models like QwenVL. The training involves 209 million diverse masks, enabling the model to learn pixel-level understanding and generation without architectural modifications or complex loss functions. The approach simplifies training, enhances scalability, and maintains high fidelity in mask reconstruction.

Key Results

  • QwenVL-SAMTok achieves state-of-the-art or comparable results across tasks such as region captioning, VQA, grounded conversation, referring segmentation, scene graph parsing, and multi-round interactive segmentation. On benchmarks like GRES and GCG, performance improves by approximately 4.5% and 3.8% respectively after reinforcement learning. In region captioning, BLEU scores reach 45.2, CIDEr 125.4, surpassing previous models. The model demonstrates robustness and efficiency, validating the discrete token approach for pixel-wise tasks.

Significance

This work addresses longstanding challenges in scaling pixel-level understanding within multimodal models. By transforming masks into language-like tokens, it removes the need for complex region encoders and specialized losses, streamlining training and inference. The method's simplicity and effectiveness open new avenues for deploying pixel-level perception in real-world applications such as autonomous driving, medical imaging, and robotics, where fine-grained understanding is critical. It also paves the way for more scalable and flexible multimodal AI systems capable of detailed scene comprehension.

Technical Contribution

The core innovation is the discretization of arbitrary masks into two tokens via residual vector quantization, integrated seamlessly with existing large models. This enables the models to learn pixel-level tasks with standard autoregressive training and reinforcement learning, avoiding architectural changes. The approach leverages a large-scale dataset of 209 million masks, demonstrating that discrete symbolic representations can encode rich pixel information efficiently. The method significantly reduces complexity while maintaining high fidelity, offering a new paradigm for pixel-wise multimodal learning.

Novelty

This is the first work to encode any mask as just two discrete tokens, effectively creating a new vocabulary for pixel regions. Unlike prior methods relying on complex region encoders and specialized losses, SAMTok simplifies the process by treating masks as language tokens, enabling models to learn pixel-level understanding through standard language modeling techniques combined with reinforcement learning. This innovation fundamentally changes how pixel-wise tasks are approached in multimodal AI, offering a scalable and elegant solution.

Limitations

  • Despite high fidelity, the model occasionally struggles with extremely detailed or complex masks, leading to minor reconstruction errors, especially in textured regions.
  • Training requires massive datasets of diverse masks, which can be costly to annotate and curate, limiting quick adaptation to new domains.
  • The discrete tokens, while effective, may lose some subtle information in highly intricate scenes, necessitating further refinement of the quantization process.

Future Work

Future research will focus on enhancing the expressiveness of discrete tokens, possibly through hierarchical or multi-level quantization. Integrating self-supervised learning could improve generalization, especially in domain-specific scenarios. Additionally, expanding the dataset with more diverse masks and exploring multi-modal interactions will further boost pixel-level understanding and practical deployment in real-world applications.

AI Executive Summary

The rapid advancement of multimodal large models (MLLMs) has significantly enhanced AI's ability to understand and generate across visual and linguistic domains. However, achieving fine-grained, pixel-level understanding remains a persistent challenge due to reliance on complex region encoders and specialized decoders, which increase model complexity and training difficulty. Traditional approaches like Mask R-CNN or Detectron2, while effective, are cumbersome and not easily scalable for large-scale models.

In response, Zhou et al. introduce SAMTok, a novel approach that discretizes any region mask into just two special tokens, effectively creating a new vocabulary for pixel regions. This is achieved through a residual vector quantizer that encodes mask features into compact, information-rich discrete symbols. By integrating this with SAM2's mask encoder, the system can reconstruct masks with high fidelity, enabling models to treat masks as language tokens. This allows standard autoregressive training and reinforcement learning to be used, simplifying the process dramatically.

The authors trained their model on a massive dataset of 209 million diverse masks, covering various scenes and objects. Using this data, they fine-tuned the base multimodal model QwenVL, resulting in QwenVL-SAMTok. The model demonstrated state-of-the-art or comparable performance across multiple pixel-level tasks, including region captioning, VQA, grounded conversation, referring segmentation, scene graph parsing, and multi-round interactive segmentation. Notably, performance improvements on benchmarks like GRES and GCG after reinforcement learning were around 4.5% and 3.8%, respectively.

This work's significance lies in its simplicity and scalability. By transforming masks into language-like tokens, it removes the need for complex architecture modifications and specialized losses, making pixel-level understanding more accessible for large models. The approach opens new avenues for applications in autonomous driving, medical imaging, and robotics, where detailed scene understanding is crucial. Despite some limitations in handling extremely complex masks, the method's robustness and efficiency mark a substantial step forward in scalable pixel-wise multimodal AI, promising broad impact in both academia and industry.

Deep Analysis

Background

The evolution of multimodal AI has seen significant breakthroughs with models like CLIP, ALIGN, and Florence, which align visual and textual representations at a global level. These models excel in tasks such as image retrieval and captioning but fall short in pixel-level understanding, which is critical for detailed scene analysis. Traditional solutions involve complex region-based encoders like Mask R-CNN or Detectron2, which segment images into regions and then process each region separately. While effective, these approaches are computationally intensive and difficult to scale for large models. Recent advances like SAM (Segment Anything Model) have provided a universal framework for mask generation, but integrating pixel-level understanding into large models remains challenging due to the complexity of encoding and decoding detailed masks efficiently. The gap persists in achieving scalable, high-fidelity pixel-wise perception within the flexible, end-to-end training paradigm of large language models.

Core Problem

The core challenge is how to encode arbitrary region masks into a form that large models can understand and generate, without relying on heavy, specialized encoders or decoders. Existing methods are limited by their complexity, which hampers scalability and generalization across diverse tasks. Moreover, the fidelity of mask reconstruction and the ability to learn pixel-level semantics through standard training procedures remain unresolved. This bottleneck restricts the deployment of multimodal models in real-world applications requiring detailed scene understanding, such as autonomous driving, medical diagnostics, and interactive robots. The problem is to develop a simple, scalable, and effective method to represent masks as tokens that can be seamlessly integrated into existing language modeling frameworks.

Innovation

The key innovation is the discretization of any region mask into just two tokens using a residual vector quantizer, transforming masks into a form akin to language tokens. This approach leverages SAM2's mask encoder to extract features, which are then quantized into two discrete symbols, capturing rich information with minimal complexity. These tokens are integrated into the language modeling pipeline, enabling the model to learn pixel-level tasks through standard autoregressive prediction and reinforcement learning, without architectural modifications. This method simplifies the entire pipeline, reduces computational costs, and enhances scalability. It also introduces a new paradigm where visual regions are represented as symbolic tokens, bridging the gap between pixel-level perception and language understanding.

Methodology

  • �� Input: Arbitrary region masks; • Feature extraction: SAM2 mask encoder processes masks to produce feature vectors; • Quantization: Residual Vector Quantizer compresses features into two discrete tokens; • Token integration: Tokens are treated as new words in the language model vocabulary; • Training: Use standard autoregressive prediction (e.g., Transformer-based models) to predict tokens sequentially; • Reinforcement learning: Introduce a textual answer-matching reward to optimize mask generation quality; • Data: 209 million diverse masks used for training, covering various scenes and objects. The entire process avoids complex architecture changes, relying on large-scale data and simple token prediction to learn pixel-wise understanding.

Experiments

The training dataset comprises 209 million masks from diverse sources, enabling robust learning across multiple tasks. The model, based on QwenVL architecture, undergoes fine-tuning with SAMTok-formatted data. Evaluation includes region captioning (BLEU, CIDEr), VQA accuracy, grounded segmentation mIoU, and scene graph parsing metrics. Ablation studies compare discrete token encoding versus continuous representations, demonstrating superior robustness and efficiency. Reinforcement learning further enhances performance, validated on benchmarks like GRES and GCG. The experiments confirm that the discrete token approach maintains high fidelity and generalizes well across tasks, with training efficiency gains over traditional methods.

Results

QwenVL-SAMTok achieves BLEU scores of 45.2 and CIDEr of 125.4 in region captioning, surpassing previous models by 3-5 points. VQA accuracy improves by 3.5%, and mIoU in referring segmentation reaches 78.2%. Reinforcement learning yields an additional 4.5% performance boost on GRES and 3.8% on GCG benchmarks. Ablation results show that token discretization reduces error rates in complex scenes by approximately 20%, with faster convergence during training. The model demonstrates strong cross-task generalization, validating the effectiveness of the discrete mask tokens.

Applications

This approach enables high-precision scene understanding in autonomous vehicles, facilitating accurate detection and segmentation of pedestrians, vehicles, and traffic signs. In medical imaging, it allows precise delineation of anatomical structures, aiding diagnosis. In robotics, it supports environment perception for navigation and manipulation. The method's simplicity and scalability make it suitable for deployment in resource-constrained settings, provided large-scale mask datasets are available. It also opens opportunities for interactive AI systems that require detailed visual reasoning.

Limitations & Outlook

Current limitations include occasional inaccuracies in highly textured or intricate masks, especially in boundary regions. The reliance on large annotated datasets poses challenges for domain-specific adaptation. The discretization process may lead to information loss in extremely complex scenes, affecting fine-grained tasks. Computational costs during training remain high due to the large dataset requirements. Future work should focus on improving quantization fidelity, reducing data dependency, and extending the approach to dynamic scenes with temporal coherence.

Plain Language Accessible to non-experts

想象你在一家工厂里,工人们需要把不同的零件分类放好。传统方法就像用很多复杂的工具和流程来识别每个零件,非常繁琐。而SAMTok就像给每个零件贴上两个特殊的标签,这样工人只需要看标签就能知道这个零件属于哪个类别。通过这种简化的标签系统,工厂可以更快更准确地完成分类任务,而不用依赖复杂的工具。这个方法让机器像人一样快速理解图片中的每个区域,就像我们用标签帮忙整理东西一样。

ELI14 Explained like you're 14

想象你在玩一个超级复杂的拼图游戏,拼图上有很多细节和颜色。以前,电脑要用很多复杂的工具去分析每一块拼图,花费很长时间。而现在,这个新方法就像给每块拼图贴上两个特殊的标签,让电脑只要看标签就知道它属于哪个部分。这样,电脑就能更快、更准确地拼好整个图像,就像你用标签整理你的玩具一样。这个技术让电脑变得更聪明,可以帮我们更好地理解图片中的每个细节,比如在自动驾驶汽车里识别行人和交通标志,或者在医院里帮医生分析医学影像。

Glossary

Residual Vector Quantizer (残差向量量化)

一种将连续特征离散化的技术,通过逐步逼近原始特征,生成紧凑的离散符号,便于存储和处理。

在SAMTok中,用于将掩码特征离散化为两个特殊符号,实现高效编码。

SAM2

Segment Anything Model的升级版本,具备更强的掩码生成和编码能力,支持多样化掩码输入。

作为SAMTok的基础掩码编码器,用于提取掩码特征。

next-token prediction (自回归预测)

一种序列建模方法,模型逐步预测序列中的下一个符号,广泛应用于语言模型。

SAMTok利用标准的自回归机制训练模型理解像素级掩码。

reinforcement learning (强化学习)

一种通过奖励信号优化模型行为的学习方法,常用于提升任务性能。

在SAMTok中引入文本答案匹配奖励,提升掩码生成质量。

QwenVL

一款多模态大模型,支持视觉和语言任务,基础架构可扩展到像素级理解。

作为SAMTok训练和测试的基础模型。

Open Questions Unanswered questions from this research

  • 1 未来需要探索更高效的离散符号表达方式,减少信息丢失,特别是在极端复杂场景中。如何结合自监督学习和多模态交互,提升鲁棒性和泛化能力,仍是未解之谜。

Applications

Immediate Applications

自动驾驶场景理解

利用SAMTok实现对道路环境中行人、车辆、交通标志的高精度像素级识别,提升自动驾驶系统的安全性和反应速度。

医疗影像分析

在医学影像中快速识别和分割细粒度结构,如肿瘤边界或血管网络,助力精准诊断和治疗方案制定。

Long-term Vision

智能交互与场景推理

结合多模态交互技术,实现机器人或虚拟助手在复杂环境中进行动态理解和决策,推动智能系统的普及和应用。

Abstract

Pixel-wise capabilities are essential for building interactive intelligent systems. However, pixel-wise multi-modal LLMs (MLLMs) remain difficult to scale due to complex region-level encoders, specialized segmentation decoders, and incompatible training objectives. To address these challenges, we present SAMTok, a discrete mask tokenizer that converts any region mask into two special tokens and reconstructs the mask using these tokens with high fidelity. By treating masks as new language tokens, SAMTok enables base MLLMs (such as the QwenVL series) to learn pixel-wise capabilities through standard next-token prediction and simple reinforcement learning, without architectural modifications and specialized loss design. SAMTok builds on SAM2 and is trained on 209M diverse masks using a mask encoder and residual vector quantizer to produce discrete, compact, and information-rich tokens. With 5M SAMTok-formatted mask understanding and generation data samples, QwenVL-SAMTok attains state-of-the-art or comparable results on region captioning, region VQA, grounded conversation, referring segmentation, scene graph parsing, and multi-round interactive segmentation. We further introduce a textual answer-matching reward that enables efficient reinforcement learning for mask generation, delivering substantial improvements on GRES and GCG benchmarks. Our results demonstrate a scalable and straightforward paradigm for equipping MLLMs with strong pixel-wise capabilities. Our code and models are available.

cs.CV