ClawMachine: Learning to Fetch Visual Tokens for Referential Comprehension

## Abstract

Abstract An essential topic for multimodal large language models (MLLMs) is aligning vision and language concepts at a finer level. In particular, we devote efforts to encoding visual referential information for tasks such as referring and grounding. Existing methods, including proxy encoding and geometry encoding , incorporate additional syntax to encode the object’s location, bringing extra burdens in training MLLMs to communicate between language and vision. This study presents ClawMachine, offering a new methodology that notates an entity directly using the visual tokens. It allows us to unify the prompt and answer of visual referential tasks without additional syntax. Upon a joint vision-language vocabulary, ClawMachine unifies visual referring and grounding into an auto-regressive format and learns with a decoder-only architecture. Experiments validate that our model achieves competitive performance across visual referring and grounding tasks with a reduced demand for training data. Additionally, ClawMachine demonstrates a native ability to integrate multi-source information for complex visual reasoning, which prior MLLMs can hardly perform without specific adaptions.

## 1 Introduction

Large language models (LLMs) [, , , , ] have opened a new era in artificial intelligence. To further unleash its potential, researchers proposed multimodal large language models (MLLMs) [, , , ] for visual understanding and investigated the multimodal dialogue task to unify various visual perception tasks. Recently, these tasks have been upgraded from image-level captioning or question answering [, ] to instance-level [, ], urging the MLLMs to align vision and language concepts at a finer (e.g., region or instance) level. These referential tasks, such as visual referring and grounding, demand the MLLM to understand the user’s intention to describe referred visual entities and predict the positional information of language-queried objects, which is beyond the original scope of natural language.

There are mainly two methodologies to support the referential dialogues, which we call proxy encoding and geometry encoding, respectively. The proxy encoding methods [, , , ] introduce proxy token as intermediates, which are processed by incorporated vision modules (e.g., RoIAlign [], RegionCLIP [], and GroundingDINO []) to identify visual entities. Differently, the geometry encoding methods describe positional information with coordinate-like text tokens [, , ] or grid-like location tokens [, ] and adapt the MLLM to process these new tokens. Despite their ability to perform referential understanding, we argue that their shared methodology, which introduces extra syntax for fine-level vision-language alignment, often requires a larger amount of training data and is hard to generalize to complex visual reasoning tasks.

To address this, we propose ClawMachine(^1^11The name ‘ClawMachine’ comes from an analogy that our model ‘fetches’ visual tokens for the MLLM to process, just like a claw machine that fetches prizes and returns them to the player.), a novel MLLM that achieves referential understanding without any extra syntax. ClawMachine is equipped with a new mechanism that notates visual entities directly using visual tokens (instead of introducing proxy tokens or coordinates). As a result, visual referring and grounding tasks can be prompted and answered in the same form, i.e., a mixed token sequence using a joint vocabulary of vision and language. From the vision perspective, the visual tokens produced by the model can be converted into detection boxes or segmentation masks with simple post-processing algorithms. The new design offers two-fold benefits. On the one hand, a broad range of vision-language tasks can be formulated into a unified form, making it easier to share knowledge between various sources of training data. On the other hand, the learning task is unified into an auto-regressive format, which incorporates no customized modules in training. One can apply the decoder-only architecture which was validated to scale up and generalize better.

We conduct extensive experiments to evaluate ClawMachine’s multimodal understanding ability. With data sourced from merely the COCO[] and Visual Genome [] datasets, ClawMachine learns to fetch discrete tokens to propose a visual entity, just like citing specific phrases in natural language. Through a designed dual-training that fits our unified format, we feed the model to outperform current models that consume much more data than us. It can also generalize to simpler tasks (like VQA) and more complex ones (like interleaved visual reasoning, see Figure 5) without additional codec. Such versatility has not been observed in any existing MLLMs. We expect our research can shed light on future research to equip MLLMs with a native ability to unify multiple modalities.

## 2 Related Work

Multimodal large language models.
The community is witnessing a trend towards unifying the vision and language modalities using multimodal large language models (MLLMs) [, , , ]. Early endeavors like Flamingo adapted LLMs to visual tasks by internal cross-attention design [], while BLIP-2 [] introduced Q-former as an external block for vision-language alignment. Later works like LLaVA [, ] apploed effective projectors for alignment pre-training, providing a ViT-MLP-LLM architecture for the community alongside the visual instruction-tuning method. Recently, a stream of works [, ] unified more modalities like video and audio into the model’s vocabulary with advanced autoencoder designs [], paving a promising path for large multimodal models.

Referential notations.
Referential notations are important for MLLMs to align text and image modalities at a finer level. A lot of prior works were dedicated to achieving this goal [, , , , , ]. We categorize them into two types. In methods that utilized proxy encoding [, , , ], the model leverages the referential proxy as a signal for agents and incorporated a specially-designed module to encode region-features. When asked to ground visual objects, the model produces an intermediate embedding supervised by detection or segmentation decoders [, ]. Another research line applies the geometry encoding [, , , ] that utilizes discrete tokens to annotate instance positions and train the MLLM in an end-to-end manner, providing a unified method for the model to recognize and generate instance positions. Both methodologies have drawbacks: proxy encoding often suffers limited generalization ability beyond the customized tasks, and geometry encoding requires more data and has a training burden to adapt to the new syntax. This paper presents a new referential notation mechanism to alleviate these drawbacks.

Discrete representation for visual data.
Besides the efforts of aligning language with vision in the continuous embedding space, the community is also exploring a discrete representation for vision modality.
The BEiT series [, , ] leveraged tokenized image patches as supervision to propose powerful cross-modal encoders. CM3 [] extended this idea to learning from mixed-modal documents through interleaved image and text tokens, allowing for joint reasoning over both modalities within a unified architecture. Based on DALL·E []’s token-based image generation, the Emu series [, ] combined visual generation tasks with multimodal comprehension, and LaVIT [] organized extended visual vocabulary to simplify the training objective.
As the discontinuity gap between vision and language narrows, we hope to excavate and form a stronger spatial correlation within the multimodal embedding space.

## 3 Methodology

### 3.1 Model Architecture

As shown in Figure 2, we follow a general design of MLLMs [] that uses an LLM for logical understanding and unifies vision and language data in the embedding space before the decoding process. The key difference from the prior MLLMs is that, instead of introducing extra syntax for referential tasks, we align both modalities in a unified embedding space (i.e., a mixed visual-linguistic vocabulary) and directly notate visual entities using visual tokens. The overall architecture consists of four parts, namely, (1) a multimodal tokenizer that converts both language and image into discrete tokens, (2) a vision-language mounting module, (3) a multimodal large language model for auto-regressive learning, and (4) post-processing the geometry of output tokens. We provide a detailed description for each component in the following paragraphs.

Multimodal tokenizer.
We encode vision and language inputs into the same embedding space. For the vision part, given an image $\mathbf{I}\in\mathbb{R}^{H\times W\times C}$, we use an EVA-CLIP encoder [] to extract $N=(W/P)\times(H/P)$ features from non-overlapping patches, where $P$ is the width and height of each patch. We then utilize a corresponding pre-trained dynamic tokenizer [] to quantize the visual features into a sequence of discrete tokens, $\mathbf{V}=(v_{1},\ldots,v_{N^{\prime}})$, $v_{n}\in\{1,2,\ldots,16\rm{,}384\}$ where $16\rm{,}384$ is the size of the visual vocabulary. For the language part, given a sentence $\mathbf{S}$, we use LLaMA-2’s tokenizer []) to convert it into a language token sequence, $\mathbf{L}=(l_{1},...,l_{M})$, $l_{m}\in\{1,2,\ldots,32\rm{,}000\}$ where $32\rm{,}000$ is the size of the language vocabulary. To avoid confusion, we add $32\rm{,}000$ to the index of quantized visual tokens. Thus, the multimodal tokenizer has a vocabulary size of $16\rm{,}384+32\rm{,}000=48\rm{,}384$.

There are two important design choices here. First, to avoid the redundancy in visual features that may diminish the efficacy of the next-token prediction training, the tokenizer we use has a select-and-merge procedure to reduce the number of distinct tokens. In practice, we compute the informativeness score of each token [, ] and sample the token set using the Gumbel softmax []. As a result, the number of preserved tokens for each image is often smaller than $N$. Second, we follow some existing MLLMs that used a ViT-MLP-LLM architecture [], and add a image-language connector where the raw (non-quantized) visual features can bypass the embedding layer and be directly projected into the language space. This mixed-quantization strategy allows us to always keep the quantization option meanwhile preserving sufficient visual information when necessary. In the ablative studies, Section 4.4, we will show that both strategies improve the model’s performance.

Figure: Figure 2: We use an example that contains both visual referring and grounding to show the framework of ClawMachine. When an image (or a region) is referred to, the corresponding visual tokens are directly embedded into the natural language. The MLLM performs next-token prediction, and the output visual tokens are projected back to the image for grounding. The red and blue rectangles indicate visual and language tokens, respectively. This figure is best viewed in color.
Refer to caption: x2.png

Vision-language (V-L) mounting.
The key element to visual referring and grounding is the syntax of referential regions. We use a mounting operation to express it with visual tokens. We map the bounding box as a rectangle to the image lattice and fetch all the visual tokens with their center coordinates located within the rectangle. These tokens are sorted according to their center coordinates (primary: top to bottom, secondary: left to right) and then used as the referential elements in the dialogue. The mounting algorithm can be seamlessly transplanted to other types of referential regions (e.g., a free-form mask).

Multimodal large language model for auto-regressive generation.
With the above mechanism for tokenization and mounting, the learning objective of both visual referring and grounding is written in an auto-regressive form, which the MLLM can learn more efficiently by predicting tokens using a simple classification loss. This allows us to train a decoder-only architecture validated to scale up and generalize in a broad domain. Specifically, we initialize the MLLM from LaVIT-7B [] (a model based on LLaMA-2 []), of which the embedding layer supports the extended visual vocabulary so that we can get a primarily image-level aligned vision-language embedding space.

Post-processing for visual grounding.
We use a simple post-processing algorithm to nominate the bounding box. We first project the model’s generated tokens back to the image lattice and address the result as active points. Then, we employ a region proposer to make initial box proposals, which are converted into 2D Gaussian distributions on the image. Next, we apply a probabilistic model to assign each Gaussian distribution a score corresponding to its fitness to the active points. The bounding box with the highest scored distribution is nominated as the model’s output. More implementation details are provided in the Appendix C. With this strategy, we avoid training the model with specific grounding requirements, like predicting the rectangular boundary for each object, while providing solid results for evaluation. In Section 4.2, we will evaluate both the intermediate metrics and the grounding accuracy to show the effectiveness of our design.

### 3.2 Data Preparation

Data preparation plays a crucial role in current multimodal model research. In our training process, we only utilize the object annotations from Visual Genome (VG)  [], and the RefCOCO series (including RefCOCO, RefCOCO+, RefCOCOg; we denote it as RefCOCO/+/g).
Besides the official annotation, we leverage additional instruction tuning data with LLM-generated dialogues [] around the COCO and VG images. We sourced 190K dialogues containing multiple objects from previous works. Among them, the Osprey-724K [], All-Seeing Project [], and ChatterBox-300K [] contribute 67K, 63K, and 60K pairs respectively. Further details are provided in Table 9.

We train ClawMachine to answer two kinds of referential questions, i.e., visual referring and grounding, and show that it generalizes to more complex scenarios. The input and output of visual referring are curated into the following format:

When the input is loaded, <image_tokens> will be substituted with the visual token sequence $\mathbf{V}$ and <ref_tokens> substituted with the token sequence produced by V-L mounting. A trigger token <ref> is placed before the entity, notifying the MLLM that visual tokens will follow. Two special tokens, <boi> and <eoi>, are used to wrap these visual tokens. Similarly, the input and output of visual grounding are curated into the following format:

where [object] can be substituted with any text description of the object. With the unified next-token prediction objective, we can combine the curated datasets for referring and grounding and train a single model for both tasks. We call it the dual training data and will show in Section 4.4 that it benefits the model’s performance.

### 3.3 Training Process and Implementation Details

The training process is partitioned into three stages, supervised by a next-token prediction loss. We use the AdamW [] optimizer with the cosine annealing scheduler [] to adjust the learning rate. The initial learning rate is set to $1\times 10^{-3}$, $2\times 10^{-5}$, and $1\times 10^{-5}$ for the three stages, respectively, and a warm-up ratio of $0.03$ is used. The global batch size remains constant at $256$ throughout all stages. The training is conducted on 8$\times$NVIDIA A800 GPUs with 80GB memory. The FlashAttention-2 and DeepSpeed libraries with zero2 are employed for efficient training. The input image size is set to $224\times 224$ with a patch size $P=14$, and the maximum sequence length in the MLLM is $2048$. The training datasets are combined into a single dataloader using the V-L mounting algorithm. The image-language instruction tuning pairs are randomly selected during training. The data is only traversed for one epoch in each training stage.

Stage 1: vision-language alignment.
We train an image-text projector following LLaVA-1.5 []. Unveiling the visual world to the model with discrete tokens may help with vision-language alignment. Still, we noticed that feeding quantized features to the model from the start may harm its visual perception of details. So, we skip the quantization of the tokenizer in this stage so that the encoded image features from ViT remain continuous after being selected, merged, and fed to the projector. The filtered CC3M data introduced in LLaVA are employed as the training data, and only the projector is trained (both the image encoder and MLLM are frozen).

Stage 2: image-level pre-training.
We guide the model in performing basic multimodal conversational tasks with the projected visual information. We notice that LLaVA-generated data with OCR or region-level understanding incurs considerable hallucination and helps little to our goal, so we only utilize the image-level understanding subset (this strategy achieves better results in VQAv2). About 400K training data is used in this stage. At the end of this stage, we obtain an MLLM that can handle image-level features with dynamic lengths. Only the language model and the projector are fine-tuned at this stage,

Stage 3: fine-tuning towards referential understanding.
We shortcut the projector in this stage and apply quantization to the tokenized visual features. The visual features become discrete tokens and then are interleaved with language as referential tokens. The model’s referring and grounding ability is trained simultaneously with the dual curated data, which is verified effective (see Section 4.4 for details) to improve the model’s grounding performance. The image encoder remains frozen at this stage and the MLLM is fine-tuned.

## 4 Experiments

### 4.1 Visual Referring

We first evaluate ClawMachine on the visual referring task to assess its ability of region-level understanding. The prompt for visual referring has the form of Please provide a detailed description for this <ref> region <ref_tokens>, where <ref_tokens> is replaced by the visual tokens within the target region as explained in the V-L mounting part. Table 1 presents our results on two established region captioning benchmarks, RefCOCOg [] and Visual Genome []. Without task-specific fine-tuning, ClawMachine demonstrates competitive performance among recent MLLMs that mainly employed complex designs and used much more training data than ours. This highlights the effectiveness of using visual tokens to notate specific objects. Table 1 includes two versions of ClawMachine using continuous and discrete image features, respectively. As expected, the model with access to continuous image features performs better because the quantization loss is eliminated (the referring tokens are quantized in both settings).

**Table 1: Results on the visual referring task. ClawMachine is trained with discrete image features and evaluated with either discrete or continuous features (the latter is denoted by *). The dual-data composition is used in training. All other MLLMs use continuous features. The referring tokens have been quantized in both versions.**
| Method | RefCOCOg | Visual Genome |  |  |
| --- | --- | --- | --- | --- |
| METEOR | CIDEr | METEOR | CIDEr |  |
| GRiT [] | 15.2 | 71.6 | 17.1 | 142 |
| Kosmos-2 [] | 14.1 | 62.3 | - | - |
| GPT4RoI [] | - | - | 17.6 | 146.8 |
| Shikra [] | 15.2 | 72.7 | - | - |
| GlaMM [] | 16.2 | 105.0 | 19.0 | 163.9 |
| Osprey [] | 16.6 | 108.3 | - | - |
| ClawMachine | 16.2 | 106.3 | 17.9 | 151.7 |
| ClawMachine * | 16.9 | 112.4 | 19.1 | 166.7 |

### 4.2 Visual Grounding

Figure: Figure 3: ClawMachine generates visual tokens, projects them to the image lattice (denoted by stars), and predicts the grounded box (denoted by rectangles). The top row shows the ability to ground different objects within one image. The bottom row shows visual tokens with the same ID.
Refer to caption: x3.png

Next, we study visual grounding (a.k.a. referring expression comprehension, REC), the counterpart task to visual referring that requires the model to identify the location of an object with language descriptions. By utilizing discrete visual tokens for image encoding, ClawMachine can understand visual content like reading a paragraph. Consequently, cross-domain grounding is transformed into a token retrieval task in the joint vision-language vocabulary. Hence, visual grounding is solved straightforwardly, i.e., the visual tokens produced by the MLLM are projected to the image lattice, and a post-processing algorithm estimates the grounded bounding box using a simple statistical model, as described in Section 3.1.

ClawMachine learns visual concepts in quantized tokens.
Figure 3 visualizes some visual grounding examples. One can see that the retrieved tokens are strongly related to the query. Delving into the output, we find that ClawMachine learns to connect visual words in the joint vocabulary with linguistic concepts, e.g., tennis ball is correlated with the 13635-th visual word and person (in small scale) is correlted with the 14781-th visual word. This makes it much easier for the MLLM to perform visual grounding: it only needs to look up the elements in <image_tokens> that are most related to [object].

Quantitative evaluation of the retrieved visual tokens.
As the intermediate result of visual grounding, the quality of retrieved tokens heavily impacts the accuracy of grounding. Note that the MLLM does not always generate complete visual tokens that cover the entire target and sometimes generates repeated visual tokens. We diminish the repeated tokens by considering several token sets, where $\mathcal{G}_{\mathrm{image}}$, $\mathcal{G}_{\mathrm{pred}}$, and $\mathcal{G}_{\mathrm{gt}}$ denote the set of whole-image tokens, predicted tokens, and ground-truth tokens, respectively. Note that the ground truth is extracted from the bounding box, which may contain some background tokens. We then define four metrics for the validity (the tokens should appear in the referred image), precision, recall, and IoU, respectively:

$$ $\begin{array}[]{rcl}\mathrm{validity}&=&|\mathcal{G}_{\mathrm{pred}}\cap \mathcal{G}_{\mathrm{image}}|~{}/~{}|\mathcal{G}_{\mathrm{pred}}|\\ \mathrm{precision}&=&|\mathcal{G}_{\mathrm{pred}}\cap\mathcal{G}_{\mathrm{gt}} |~{}/~{}|\mathcal{G}_{\mathrm{pred}}|\\ \mathrm{recall}&=&|\mathcal{G}_{\mathrm{pred}}\cap\mathcal{G}_{\mathrm{gt}}|~{ }/~{}|\mathcal{G}_{\mathrm{gt}}|\\ \mathrm{IoU}&=&|\mathcal{G}_{\mathrm{pred}}\cap\mathcal{G}_{\mathrm{gt}}|~{}/~ {}(|\mathcal{G}_{\mathrm{pred}}\cap\mathcal{G}_{\mathrm{image}}|+|\mathcal{G}_ {\mathrm{gt}}|-|\mathcal{G}_{\mathrm{pred}}\cap\mathcal{G}_{\mathrm{gt}}|)\end {array}.$ (1) $$

**Table 2: Evaluating intermediate results using the four metrics in Eqn (1). We denote the combined training set of the RefCOCO series (RefCOCO, RefCOCO+, RefCOCOg) as RefCOCO/+/g. The test set is RefCOCOg-val. REC denotes the final accuracy of visual grounding.**
| Model | Training data | validity | precision | recall | IoU | REC |
| --- | --- | --- | --- | --- | --- | --- |
| ClawMachine | RefCOCO/+/g | 51.6 | 25.9 | 39.3 | 36.1 | 68.1 |
| Visual Genome | 49.7 | 33.5 | 35.4 | 33.9 | 75.3 |  |
| both | 50.1 | 34.1 | 45.5 | 52.8 | 87.5 |  |

Figure: Figure 4: The diversity of training data improves the accuracy of retrieved visual tokens. See Table 2 for the quantitative results on the entire dataset.
Refer to caption: x4.png

Results of different ClawMachine variants are summarized in Table 2. There are valuable discoveries. (1) The precision of retrieved tokens increases with an increasing amount and diversity of training data (i.e., both RefCOCO/+/g and Visual Genome are used). (2) The recall of retrieved tokens is higher when the training data is in the same domain (RefCOCO/+/g), yet data from another domain (Visual Genome) compensates. Hence, a good strategy is to improve the diversity of training data. The visualization results shown in Figure 4 also support this claim.

Visual grounding results.
We use the post-processing algorithm described in Section 3.1 to convert each set of retrieved visual tokens into a bounding box, the final output of visual grounding. In this model, we have also used the dual data composition policy (i.e., by including the training data curated for visual referring) to improve the performance – see the ablation in Section 4.4. The comparison of ClawMachine against existing MLLMs for visual grounding is shown in Table 3. ClawMachine reports competitive performance among the MLLMs that utilize extensive training data or specifically designed architectures for visual grounding.

**Table 3: Results on the visual grounding (REC) task. We report accuracy with the IoU threshold set to $0.5$. Note that the size of training data for ClawMachine is much smaller than that for other models (see Appendix B for details).**
| Method | RefCOCO | RefCOCO+ | RefCOCOg | Average |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| val | test-A | test-B | val | test-A | test-B | val | test |  |  |
| OFA-L [] | 79.9 | 83.7 | 76.4 | 68.3 | 76.0 | 61.8 | 67.6 | 67.6 | 72.7 |
| Shikra [] | 87.8 | 91.1 | 81.8 | 82.9 | 87.8 | 74.4 | 82.3 | 82.2 | 82.9 |
| MiniGPT-v2 [] | 88.7 | 91.6 | 85.3 | 80.0 | 85.1 | 74.5 | 84.4 | 84.7 | 84.3 |
| Qwen-VL [] | 88.5 | 92.3 | 84.5 | 82.8 | 88.6 | 76.8 | 85.9 | 86.3 | 85.4 |
| Ferret [] | 89.5 | 92.4 | 84.4 | 82.8 | 88.1 | 75.2 | 85.8 | 86.3 | 85.6 |
| ClawMachine | 88.9 | 92.1 | 85.6 | 82.7 | 88.5 | 75.5 | 85.2 | 86.1 | 85.6 |

Figure: Figure 5: ClawMachine can solve complex visual reasoning tasks. See the texts for explanations.
Refer to caption: x5.png

### 4.3 Complex Visual Reasoning

ClawMachine benefits from two-fold advantages: (i) it has a native ability to perform visual referring and grounding so that a question can contain both image and text elements, and (ii) it builds a clear relationship between visual and linguistic tokens so that the same concept can be delivered using either image or text. Integrating these advantages allows it to solve complex visual reasoning tasks. Figure 5 shows examples including (1) region-text interleaved VQA, where the answer to the visual question lies within image-embedded prompts, (2) grounding-upon-referring, where the query to visual grounding contains image-embedded tokens, and (3) multi-object referring segmentation, where multiple sets of retrieved tokens are converted into instance segmentation results. ClawMachine solves the first two tasks using the native next-token prediction mechanism, while none of the existing MLLMs can solve them within one model. Solving the third task requires replacing the post-processing algorithm for detection with a segmentation model, which is much easier than training a standalone model for referring segmentation.

### 4.4 Ablative Studies

The select-and-merge strategy.
This strategy was described in Section 3.1 as a design choice of the multimodal tokenizer. As shown in Table 5, the select-and-merge strategy improves the referring performance regardless of whether quantization is used. This owes to its effect on reducing information redundancy, as shown in recent works [, ]. Incidentally, although the quantization of visual tokens may bring some performance drop in referring, it is crucial to visual grounding and must be turned on. We will discuss the strategy in the next paragraph.

The quantization strategy for visual tokens.
When fed into the MLLM, the visual tokens can be quantized into a discrete element in the vocabulary or remain continuous. From Table 5, one can see that introducing the quantization process in Stage 2 harms the model’s basic visual perception ability, e.g., its referring performance drops. However, the quantization is pivotal for visual grounding (see Table 5) because the discrete tokens are retrieved much easier in our next-token prediction framework. To keep the best property for both tasks, we design a sophisticated schedule where the referential tokens are always quantized but the image-level visual information fed into the MLLM has a continuous form in Stage 2 with the mixed-precision strategy (described in Section 3.1). As shown in Table 7, this continuous-then-discrete training strategy is the best choice for simultaneously optimizing the model’s referring and grounding abilities.

**Table 4: Ablation of the setting of tokenization. The REF score (on RefCOCOg-val) is tested in Stage 3. S&M: the select-and-merge strategy.**
| Stage 2 | S&M | VQ | REF |
| --- | --- | --- | --- |
| ✗ | ✗ | 15.6 |  |
| ✔ | ✗ | 16.9 |  |
| ✗ | ✔ | 15.2 |  |
| ✔ | ✔ | 16.2 |  |

**Table 6: Ablation of whether the image features are quantized in Stage 2/3. The REF score is tested on RefCOCOg-val.**
| Stage 2 | Stage 3 | REF w/ VQ | REF w/o VQ |
| --- | --- | --- | --- |
| ✔ | ✔ | 15.5 | 15.9 |
| ✗ | ✗ | 13.9 | 17.0 |
| ✗ | ✔ | 16.3 | 16.9 |

Effectiveness of dual data.
We study the impact of using different sources of training data in Stage 3, and report the model’s visual grounding performance in Table 7. We compare the contribution of the plain data (the dialogue data without region-level questions, sourced from the mixed dataset of LLaVA-1.5 []) and dual data (the visual referring data), and find that the latter brings significant gain in the grounding performance (although the former is also useful in maintaining the model’s VQA ability). This validates that ClawMachine can absorb the knowledge from both referring and grounding data into one model, which mainly owes to its formulation that unifies referring and grounding into the next-token prediction task.

## 5 Conclusion

We propose ClawMachine, a multimodal large language model capable of unifying various fine-level multimodal understanding tasks such as visual referring and grounding. At the core of ClawMachine lies the idea to notate visual entities directly with visual tokens so that no extra syntax is required for task description. This simplifies the data curation procedure and largely reduces the amount of data to train a versatile MLLM with the elegant next-token-prediction formulation. Additionally, ClawMachine can also perform complex visual reasoning tasks by interleaving visual and linguistic tokens into the same sequence.

Limitation and future work.
Vision data contains rich information; the quantization of visual tokens inevitably loses fine-grained information. We expect a more advanced encoding mechanism that maximally reduces the information loss when embedding the visual data into the joint vocabulary. Moreover, the probabilistic nature of large language models can cause the output of visual tokens unstable and incomplete (e.g., unable to cover the entire grounded target). We expect a unified learning procedure that adapts the LLM with the visual encoder to alleviate the issue.

## Appendix A Implementation Details with Discussion

We discuss about some design and implementation details in this section.

We use the standard tokenizer of LLaMA-2 [] for natural language, with a vocabulary size of 32000. A sequence of tokens $\mathbf{L}=(l_{1},...,l_{M})$ will be prepared after processing the language part. For the visual input, given an image $\mathbf{I}\in\mathbb{R}^{H\times W\times C}$, we partition it into $N=(W/P)\times(H/P)$ patches with a patch size $P=14$ and no overlapping. A pre-trained ViT encoder, specifically, EVA-CLIP [] takes in these patches and produce a sequence of features $\mathbf{X_{0}}=(x_{1},\ldots,x_{N})$. A direct tokenization method will be to project these features to low dimensions, and apply the vector-quantization to get discrete results with a learned codebook. However, as the redundant information in visual patches may diminish the efficacy of the next-token paradigm of language model in comprehending visual knowledge, we utilize a pre-trained dynamic tokenizer [] with a codebook size of 16384. The feature sequence will first be converted into a select&merged sequence $\mathbf{S}=(s_{1},\ldots,s_{N^{\prime}})$, then vector-quantized into discrete tokens $\mathbf{V}=(v_{1},\ldots,v_{N^{\prime}})$. During the select&merge process, a binary decision map $M$ that determines for each token in $\mathbf{X_{0}}$, whether to preserve it or merge it to the preserved ones will be generated.

With $\mathbf{V}=(v_{1},\ldots,v_{N^{\prime}})$ and $\mathbf{L}=(l_{1},\ldots,l_{M})$ prepared for input, the material is capable of demonstrating visual question answering tasks for the entire image. To specify a certain entity/region in the image, we apply a simple and intuitive method: fetch all the tokens within the region and mount them after the linguistic reference. So that when you refer to an object in the question, just paste the corresponding visual tokens after the pronoun it. The model will also learn to answer with visual tokens when asked for grounding. As the binary decision map $M$ is reserved for the fetch process, and tokens encoded from non-overlapping patches can be re-mapped to its original place, this mounting is easily implemented with parallel computing.

In language model architectures like LLaMA, the data pipeline will embed the input_ids(language tokens) into continuous embedding and feed it to the model. Popular multimodal understanding models use a ViT-MLP-LLM structure [], where the continuous visual features bypass the embedding layer, and are projected into the language embedding space using MLP. Reserving continuous information is beneficial for visual understanding, however, the model cannot learn to speak explicit visual content as it’s not in model’s vocabulary. In another domain, current multimodal models focusing on generation tasks have been managing to inject quantized visual tokens into language models and tame them to do a visual speech. We initialize LLM from LaVIT-7B (an MLLM tuned from LLaMA-2), of which the embedding layer supports the extended visual vocabulary, so that we can get a well-aligned primary visual-language embedding space. Nevertheless, the bypass of continuous visual embedding is reserved for inference.

## Appendix B Data Preparation Details

We make a comparison with other popular models in Table 8, and summarize our used data and dataset origins in Table 9.

**Table 8: A comparison of dataset usage with popular models.**
| Method | RefCOCO/+/g | VG | Flickr30K | Object365 | Others |
| --- | --- | --- | --- | --- | --- |
| Shikra [] | ✔ | ✔ | ✔ | ✗ | PointQA [] |
| GlaMM [] | ✔ | ✔ | ✔ | ✗ | SA-1B [] |
| Ferret [] | ✔ | ✔ | ✔ | ✔ | LVIS [] |
| Qwen-VL [] | ✔ | ✔ | ✗ | ✗ | GRIT [] |
| Osprey [] | ✔ | ✔ | ✗ | ✗ | LVIS [] |
| ClawMachine | ✔ | ✔ | ✗ | ✗ | None |

**Table 9: Detailed Data composition in Stage 3**
|  | Dataset Origin | Composition |
| --- | --- | --- |
| Referring | RefCOCO/+/g, Visual Genome | Official dataset’s expression and bbox annotations. About 280K object annotations from RefCOCO/g/+ and 3M object annotations from Visual Genome. Detailed description and curated conversations by ChatterBox [], Osprey [], and All-Seeing project []. |
| Grounding | RefCOCO/+/g, Visual Genome | Official dataset’s expression and bbox annotations. The Scene graph description of COCO images by All-Seeing project [] is also utilized. |

## Appendix C Decoding Visual Tokens as an Entity

We explain how our grounding method works and provide some details for decoding visual tokens into bounding boxes in this section.

Retrieving Tokens in Image.
Let $\mathcal{G}_{\mathrm{image}}$ represent the group of image tokens, $\mathcal{G}_{\mathrm{pred}}$ the group of generated tokens.
We get $\mathcal{G}_{\mathrm{pred\cap image}}=\mathcal{G}_{\mathrm{image}}\cap\mathcal
{G}_{\mathrm{pred}}$ as the primary material for further processing.
For each element $v_{i}\in G_{pred\cap image}$, as its index in the visual tokenizer’s codebook is determined, we can easily retrieve its original place with $\mathbf{V}=\{v_{1},...v_{N^{\prime}}\}$ and the binary decision map $M$ mentioned in Sec.A.
As the tokenizer has limited vocabulary and may not assign every patch of the image a different code, we firstly retrieve visual tokens that appear only once in $\mathcal{G}_{\mathrm{image}}$.
Then for $v_{i}$ that appear more than once in $\mathcal{G}_{\mathrm{image}}$, we scan all of its possible origins and append the index that is nearest to the already picked tokens to minimize extra noise. After this procedure, we can get a retrieval map for model’s output visual tokens, which just looks like the stars on a canvas as we illustrated in demo Figure 7.

Clustering Points into an Entity.
We use Co-DETR [], a detection model as the region proposer out-of-the-box with no tuning. For a given image, it can provide prediction boxes with a score higher than 0.3 by default, and we use them as the region proposals. We do not give it any clue like language or other form instructions.
For each proposed box, we initialize a 2D gaussian distribution based on it. We noticed that the model’s output tokens keeps a roughly same density, so we suppose the gaussian distribution’s variance shall be inversely proportional to box’s size with a certain power, while the covariance matrix of the distribution follows the shape of the rectangle. We use these pre-defined distributions to construct a simple Gaussian Mixture Model (GMM), and predict the points’ intention. This will result in a prediction label for each point that decides which distribution it belongs. After using the prediction results and points’ density to score each box, we nominate the box with highest scores as model’s prediction results.

## Appendix D More Experiments

We report some additional experiment results in this section.

Visual Question Answering
In addition to region-level tasks, we further evaluate ClawMachine on conversational VQA benchmark, LLaVA Bench [], which contains questions about conversations, detailed descriptions and complex reasoning. See Table 10.This demonstrates that ClawMachine maintains competitive image understanding and visual chatting abilities. For the under performance in conversation and description, we speculate this could be resulted from the quantization loss of image features, and a little forgetting as the conversational VQA data is not used in stage 3.

**Table 10: LLaVA-Bench results. Tested with quantized visual features after Stage 3 fine-tuning.**
| Method | Conversation | Description | Reasoning | Average |
| --- | --- | --- | --- | --- |
| LLaVA [] | 85.4 | 68.3 | 92.1 | 81.9 |
| Kosmos-2 [] | 71.7 | 63.4 | 74.9 | 70.0 |
| Shikra [] | 80.6 | 70.7 | 88.1 | 79.9 |
| Ferret [] | 84.4 | 79.4 | 96.3 | 86.7 |
| ClawMachine | 82.8 | 74.5 | 93.5 | 83.6 |

## Appendix E An intuitive demonstration for our training strategy

In the ablation study, we conduct quantitative experiments to investigate a optimus strategy for model’s balanced performance. We provide a demonstration in Figure 6 to help understand the routines we investigated. Routine a. is firstly excluded for its bad performance of grounding. Routine b. is abandoned for similar reason, and its referring ability is also ordinary due to the quantization loss applied in stage 2. Routine c. performs a relatively good grounding ability, but also suffers from quantization that results in its unsatisfying referring ability. Routine d. gives bad grounding results as its discrete visual tokens are not fully activated during training. We choose routine e. as our final strategy, which finds a good balance between referring (second best result) and grounding (best result).

Figure: Figure 6: An intuitive demonstration of our training strategies. Best viewed in color.
Refer to caption: x6.png

## Appendix F More Visualization Examples

We provide more visualized examples of ClawMachine’s output here. As the resulted points serve as a task-agnostic supervision intermediate for downstream tasks, we also use it as a prompt to fuel powerful pre-trained segmentation models []. The points’ convex closure can be regarded as a semantic segmentation with rough granularity, which is finely post-processed by segmentation specialist models. We show some examples in Figure 7.

Figure: Figure 7: More visualized examples of ClawMachine’s output. The visual tokens serve as a novel and useful intermediate for downstream decoders. The bottom two rows show some segmentation results we get from SAM [], using points as the prompt.
Refer to caption: x7.png

## Peer Reviews

confidence: 5
contribution: 3
initial_rating: 5
presentation: 3
questions: Please see the weaknesses. Will consider revising the review if the author(s) can solve my concern in rebuttal.


===========================

After reading the rebuttal of the author(s), I'd like to raise my rating as my concerns are alleviated.
soundness: 3
strengths: 1. The idea of token collectives enables referring and grounding in MLLM in a hybrid way, unifying both continuous region features and discrete region tokens.

2. Instead of generating coordinates as in previous works, this paper proposed to generate discrete tokens for corresponding regions, and then do a patch-based matching and retrieval to ground back to the region in the image. Also, a delicately designed resampler is introduced to ensure the accuracy of grounding boxes.

3. The performance is impressive, outperforming many existing works in a wide range of tasks.
summary: The paper proposed a hybrid way to incorporate continuous features and discrete tokens in MLLM for referring and grounding. Different from using coordinate location to represent regions, this work introduced discrete image tokens in both input and output. A systemic workflow is proposed to accommodate the change. In the experimental result, the proposed model can outperform previous works in multiple tasks and shows good qualitative analysis.
weaknesses: 1. It's a bit unclear whether the good performance comes from data or model design. I.e., the proposed model design needs to be ablated and compared with other baselines in the same training and dataset setup as used in this paper. For example, there are a few necessary ablations I could think of: replacing the referring LaVIT token with discrete coordinates; replacing the grounding LaVIT token to be predicted with discrete coordinates, remove the LaVIT token for the global image. Please make sure the other settings are the same (using the same pre-training and instruction-tuning datasets as in the paper, the same training stages and steps, same backbone).

2. Efficiency and Complexity: The proposed method requires two image encoders: LaVIT for discrete token generation and Eva-CLIP for continuous token. Also in decoding, the proposed method requires a detector to provide prior in the Region Sampler. Essentially, other existing works don't require that many additional components. A detailed comparison in terms of efficiency analysis (total model parameter, FLOPs, memory) with and without detector/LaVIT is needed.

3. An advantage of hybrid representation is about free-form referring and grounding(segmentation). However, this paper doesn't benchmark that quantitatively.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 2
questions: - The paper uses an out-of-the-box object detector, as mentioned in line 205 and Table 12. Since this is also a pre-trained external model, what is the advantage of this in comparison with other detector modules in 'proxy encoding' and 'geometry encoding' methods?

- As stated in line 821: '...We do not give it any clue like class or description...' Is it correct that the region sampler can propose an arbitrary number of boxes (as long as the confidence score is greater than 0.3), and that all tokens within these boxes are extracted to form the 'token collective' set?

- In Table 1, the proposed method uses another image encoder, EVA-G/14 (1.0), compared to previous methods. Since the proposed strategy for extracting 'Token Collectives' does not depend on the choice of image encoder, how would the method's performance be affected if it used the same encoder as in previous works?

- In Table 6, why does training on RefCOCO/+ and RefCOCOg lead to better recall and IoU in the Token Collectives generation step when compared with Visual Genome, yet result in a lower REC score? Additionally, what are the results when training only on GRIT-20M? (rather than on RefCOCO+GRIT-20M)

- In line 188, the paper states that tokens are sorted with primary sorting from top to bottom and secondary sorting from left to right. Will the results be impacted if random shuffling or another sorting strategy is applied?

- Is there any experiment conducted for "free-form masks" rather than bounding boxes, as mentioned in line 190?
soundness: 3
strengths: 1. The idea of representing entities using the introduced concept of a 'token collective' is novel and interesting, as it eliminates the need to train a separate object detector in 'proxy encoding' approaches, allowing for end-to-end joint optimization. Additionally, it removes the difficulty in aligning language with exotic location tokens in the other 'geometry encoding' methods.

2. The proposed solution is simple yet effective. Extensive experiments across several datasets and settings are conducted to show the approach's effectiveness. The paper also provides adequate ablation studies to analyze the model's behavior. The qualitative results presented in Figures 3 and 7 provide insights and illustrate the proposed approach's ability to generate relevant visual tokens.
summary: This paper proposes a novel approach for aligning vision and language concepts in multimodal large language models. Unlike other works in the literature that use additional syntax to encode spatial information, this approach introduces a new strategy for representing entities using token collectives—groups of visual tokens that represent entities at a semantic level
weaknesses: While the method itself is not very complex, the presentation in the paper is difficult to follow and understand the details. The two most important figures (Figures 1 and 2) are not referenced anywhere in the main text. The core section of the paper, Section 3.1, contains very limited information. Although additional explanations are provided in Appendix A.4, relying solely on textual explanations makes some aspects ambiguous.

Please also see further concerns in the question section below.

---

confidence: 3
contribution: 3
initial_rating: 6
presentation: 2
questions: * What are the performances of the model after pre-training but without instruction tuning?

* Table 6 shows that adding the GRIT-20M dataset as pre-training data leads to large improvements for the proposed precision / recall / IoU. However this does not lead to such a gap in REC performances. Have the authors interpretation on this?

* In future works the authors mention not relying on quantized tokens. Would the type of approach described in GIVT [2] be an interesting way of doing so?

[1] Xiao, Bin, et al. "Florence-2: Advancing a unified representation for a variety of vision tasks." Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2024.

[2] Tschannen, Michael, Cian Eastwood, and Fabian Mentzer. "Givt: Generative infinite-vocabulary transformers." European Conference on Computer Vision. Springer, Cham, 2025.
soundness: 3
strengths: * ClawMachine does not require additional syntax to embed the localisation. 

* ClawMachine can be trained with the simple next token prediction task and instruction tuning.

* ClawMachine has strong experimental results in referring and grounding.

* The paper claims that models and data will be made available.
summary: The paper proposes ClawMachine, a new method to train MLLMs for referring and grounding. The method allows a fine-grained alignment of vision and language in large transformers. It introduces “token collective”, which are groups of visual tokens representing regions of images. ClawMachine uses text-vision interleaved data and simple next token prediction to train MLLMs. ClawMachine can then perform several tasks, such as referring and grounding, together with other complex tasks necessitating a fine vision-language understanding.
weaknesses: * The section `Methodology` is very succinct and lacks some motivations:
    * Using both continuous and discrete tokens (only motivated in experiments)
    * Training details are tedious as ClawMachine leverages multiple existing elements. It would make it easier to follow to have a detailed table indicating the parts that are used from previous works / and which are fine-tuned or frozen.
    * The visual token generation is not clear to me, is the supervision the patch index, or the vocabulary index?

* ClawMachine is a supervised method. ClawMachine relies on datasets such as RefCOCOg etc. which are supervised datasets. The question remains of how scalable this method is. 

* The paper does not include the recent Florence-2 [1]; which can perform both referring and grounding. It also has much fewer parameters.

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 3
questions: Please refer to the weaknesses section.
soundness: 3
strengths: 1. The idea of utilizing token collectives for object referring and grounding is innovative and may inspire future research on integrating multiple modalities.
2. The experimental results show the effectiveness of the proposed method.
3. The paper is well-written and easy to follow.
summary: This paper proposes to use token collectives for representing visual concepts in MLLMs, which avoids learning proxy or geometric tokens. As a result, the visual referring and grounding tasks can be prompted and answered in a unified form. The extensive experiments demonstrate the effectiveness of the proposed method.
weaknesses: 1. The input image is encoded to 16*16=256 patches, leading to a large number of tokens for referring or grounding an object. For grounding an object, geometry-encoding methods and proxy-encoding methods only one or a few tokens, while ClawMachine needs to output hundreds of tokens (for a large object), which largely increase the inference time cost. However, Table 13 does not appear to reflect this discrepancy in grounding time. Could you provide more details on how the inference time is measured and if there are any techniques used to maintain efficiency despite the potential for increased token output?
2. The Region Sampler relies on a pre-trained detector to obtain grounding results, which may hinder overall model performance if the detector fails to identify the target object. This reliance on detection could limit scalability compared to one-stage methods such as Ferret and GLaMM.
3. As stated in the Limitation section, the vector quantization of visual features results in a loss of fine-grained details, as well as a larger vocabulary usage than previous methods. This also poses challenges on aligning linguistic and visual tokens to some extent.

Meta-review: This paper proposed a novel approach for referring and grounding in MLLM. Concretely, the tokenized image patch is directly served as input and output target for the MLLM. This novel design explores a new direction for adding the position information to the MLLM. The proposed approach achieves good performance on the benchmarks.

The reviewers support this paper for:
1. novel architecture design
2. strong performance
3. simplified architecture / method

The reviewers argue this paper for:
1. whether data / model contributes to the final perfomrance.
2. presentation of this paper.
3. efficiency of the proposed approach.
4. results for the free-form referring and grounding.

Based on the discussion, majority of the reviewers agree that the pointed out weaknesses have been addressed. Only reviewer gC1c didn't respond to the rebuttal. Based on the rebuttal, I would rule that the concerns have been addressed.

Based on the support, I vote this paper for accept.

Decision: Accept (Poster)