Abstract
We introduce Kosmos-2, a Multimodal Large Language Model (MLLM), enabling new capabilities of perceiving object descriptions (e.g., bounding boxes) and grounding text to the visual world. Specifically, we represent refer expressions as links in Markdown, i.e., “text span”, where object descriptions are sequences of location tokens. Together with multimodal corpora, we construct large-scale data of grounded image-text pairs (called GrIT) to train the model. In addition to the existing capabilities of MLLMs (e.g., perceiving general modalities, following instructions, and performing in-context learning), Kosmos-2 integrates the grounding capability into downstream applications. This work lays out the foundation for the development of Embodiment AI and sheds light on the big convergence of language, multimodal perception, action, and world modeling, which is a key step toward artificial general intelligence.
Introduction
While current Multimodal Large Language Models (MLLMs) excel at general image description, they often lack a "spatial interface." They can identify a "dog in a field" but struggle to precisely locate it or respond to specific spatial queries. Kosmos-2 addresses this by bridging the gap between text and pixels, treating spatial coordinates as discrete "location tokens." By training on a massive new dataset of 91 million grounded image-text pairs (GRIT), the model gains the ability to link specific words to image regions and vice versa, laying the groundwork for more interactive and embodied AI.
Methods: Spatial Information as Language
The core innovation of Kosmos-2 is its representation of spatial information. Instead of a separate architectural head for coordinates, space is treated as part of the language itself.
- Location Tokens: The image is divided into a $32 \times 32$ grid. Each point is assigned a unique token (e.g.,
<loc44>) in the model's vocabulary. A bounding box is represented by two tokens: the top-left and bottom-right corners. - The "Hyperlink" Format: To link text to these boxes, Kosmos-2 uses a Markdown-inspired syntax:
[text span](bounding boxes). In the model's actual input/output stream, this looks like:<p> a campfire </p> <box> <loc4> <loc1007> </box>.
- Architecture: Built on the KOSMOS-1 foundation, it uses a Transformer-based causal language model. It processes images through a vision encoder and a "resampler" to turn visual data into embeddings that the language model can read alongside text tokens.
- Unified Training: The model is trained using a standard next-token prediction task on a mix of grounded data, interleaved image-text data, and pure text corpora.
The GRIT Dataset
The researchers introduced GRIT (Grounded Image-Text pairs), a large-scale dataset created via an automated pipeline. Derived from the massive LAION-2B and COYO-700M datasets, it contains approximately 91 million images, 115 million text spans, and 137 million bounding boxes. The construction involved using spaCy to extract noun phrases from existing captions and a pretrained grounding model (GLIP) to predict the bounding boxes for those phrases.
Key Insights: Multimodal Referring and Grounding
The most significant insight is that spatial coordinates do not need special treatment; if discretized, the Transformer can learn the relationship between a word and a coordinate just as easily as it learns semantic relationships. Furthermore, Kosmos-2 doesn't just output boxes; it can take a box as input. This allows for a "visual dialogue" where a user points to a region and asks a question, and the model responds with context-aware text.
Key Results
- Zero-Shot Grounding: Kosmos-2 achieved impressive results on Flickr30k Entities, outperforming specialized models like GRILL that rely on attached detectors.
- Referring Expression Generation: On the RefCOCOg benchmark, Kosmos-2's zero-shot performance (CIDEr score of 60.3) outperformed some previously state-of-the-art models that were specifically finetuned for the task.
- General Intelligence Preservation: Importantly, adding these spatial capabilities did not degrade the model's performance on standard NLP tasks or general image captioning.
Limitations and Future Work
Current limitations include resolution constraints, as the $32 \times 32$ grid may struggle with very small objects. Additionally, because GRIT was generated by another model (GLIP), Kosmos-2 is limited by the accuracy and potential biases of its "teacher." Future work aims to use this grounding capability as a stepping stone toward "Embodied AI," where models can act within the physical world by grounding instructions to physical coordinates.
Summary updated