World to Code: Multi-modal Data Generation via Self-Instructed Compositional Captioning and Filtering

Jiacong Wang, Bohong Wu, Haiyong Jiang, Xun Zhou, Xin Xiao, Haoyuan Guo, Jun Xiao

Introduction

The performance of Vision-Language Models (VLMs) is fundamentally constrained by the quality and scale of image-text alignment data. While high-quality human annotations are the gold standard, they are prohibitively expensive and difficult to scale. Consequently, researchers have turned to synthetic data generation. Current state-of-the-art synthetic pipelines often rely on a "mixture of specialists"—employing separate models for object detection, OCR, and captioning—or expensive closed-source APIs like GPT-4V. These approaches are either operationally complex or costly. Moreover, standard natural language captions often lack precise spatial reasoning and are prone to hallucinations.

To address these challenges, we present World to Code (W2C), a novel data construction pipeline that enables VLMs to generate their own high-quality training data by representing images as structured Python code. By treating an image as a software environment, W2C leverages the inherent structure of code to improve visual reasoning and grounding.

The W2C Pipeline

The W2C pipeline transforms an image into a structured NaturalEnv Python class through a four-stage process:

  1. Visual Concept Extraction: The VLM generates a global caption, from which noun phrases (concepts) are extracted. A grounding model (e.g., Grounding DINO) then maps these concepts to specific bounding boxes.
  2. Self-Instructed Information Extraction: For each detected object, the VLM provides detailed region-level descriptions (attributes like color and material) and performs localized OCR within the specific crop.
  3. Consistency Filtering: To mitigate hallucinations, the VLM acts as its own validator. It is prompted to verify its findings (e.g., confirming object counts). Inconsistent outputs across different prompts result in the data being discarded.
  4. Structured Formatting: All validated data is organized into a Python class where objects are attributes with properties like description, text, and bounding_box.
The W2C pipeline transforms visual scenes into structured Python code through multi-stage VLM prompting and self-consistency checks.

Key Insights

Code as a Structured Representation

A core premise of W2C is that Python code serves as a superior representation for complex visual details compared to standard prose. Code is unambiguous and hierarchical, forcing the VLM to "parse" a scene into a formal definition. This structured approach achieves better cross-modal equivalence, ensuring the text more accurately reflects the visual reality.

Self-Correction via Consistency

W2C leverages the "generator-validator" gap: VLMs are often more reliable at verifying a fact than generating it. By cross-checking captions through counting and re-ranking prompts, the model effectively filters out its own hallucinations without requiring external supervision.

Reducing Model Bloat

Unlike previous methods requiring over a dozen specialized models, W2C relies primarily on the VLM itself. This simplifies the pipeline, making it more scalable and easier to automate for large-scale unlabeled datasets.

Experimental Results

The W2C pipeline was evaluated using the ShareGPT4V dataset as a source. Models trained with W2C data consistently outperformed baselines and models trained on other high-quality synthetic datasets across a wide range of benchmarks.

Performance comparison of LLaVA models across various VQA and reasoning benchmarks. W2C-enhanced models show consistent improvements in most categories.

Key findings include:

  • VQA Performance: W2C achieved top results in 7 out of 9 benchmarks for LLaVA-NeXT-7B.
  • Visual Grounding: Models showed significant improvements in object localization, with Mean IoU increases of 1.5 to 3.5 across the RefCOCO series.
  • Reasoning Efficiency: The code-parsing ability learned via W2C allows models to answer complex questions about an image even in zero-shot or few-shot settings, outperforming standard detailed captions.

Limitations and Future Work

While effective, W2C's performance is currently limited by the OCR density of the source datasets and the inherent "intelligence" of the base VLM used for self-consistency checks. Future research will explore scaling W2C to billion-scale unlabeled image pools to further enhance the foundation of multi-modal learning.

Summary updated

BibTeX
@inproceedings{wang2024world,
  author = {Jiacong Wang and Bohong Wu and Haiyong Jiang and Xun Zhou and Xin Xiao and Haoyuan Guo and Jun Xiao},
  title = {{World to Code: Multi-modal Data Generation via Self-Instructed Compositional Captioning and Filtering}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.265},
}
Figure