TL;DR
Text-only Large Language Models (LLMs) possess a surprising amount of spatial and visual knowledge embedded within their text-based representations. By prompting LLMs to generate image-rendering code, this paper demonstrates that they can draw complex scenes, improve their drawings through text-based self-correction, and even produce synthetic datasets capable of training competitive computer vision models without ever seeing a real pixel.
What Problem Does This Paper Address?
Do language models truly understand the visual world? Because LLMs are trained purely on text, they are exposed to rich descriptions of shapes, colors, and spatial layouts, but they lack direct access to pixels. Previous research probed LLM internal representations for specific attributes (like color or size), but these methods are limited to predefined features and require access to the model's internal weights.
The authors of this paper tackle a broader question: What do text-only language models actually know about the visual world, and can we use that knowledge to train a vision system for natural images? To bypass the pixel limitation, they use code (such as Python or Processing) as a universal intermediate language to evaluate how well LLMs can "draw" (generate) and "see" (recognize) arbitrary visual concepts.
Methods
The researchers designed a multi-part framework to test and exploit the visual capabilities of text-only LLMs (specifically GPT-3.5, GPT-4, and Davinci):
- Text-to-Code-to-Image Generation: LLMs are prompted to write code in four different programming languages (
python-matplotlib,python-turtle,Processing, andTikZ) to render specific visual concepts. - Visual Recognition from Code: To test if LLMs can "see," the authors fed human-authored drawing code into the LLMs and asked them to predict what object or scene the code would render.
- Textual Self-Correction: The authors closed the loop by prompting the LLM with its own generated code and asking, "How can you do better?" This allowed the model to iteratively refine its drawings using text-only self-feedback.
- Bootstrapping a Vision Model: They generated a dataset of 80k images using LLM code, scaled it up to 1.3 million images using MixUP data augmentation, and used it to pre-train a standard ResNet-50 vision backbone via self-supervised contrastive learning (MoCo-v2).
Datasets
The paper introduces and utilizes several distinct datasets:
- The Visual Aptitude Dataset: A new hierarchical dataset created by the authors to evaluate LLMs. It spans three levels of complexity:
- Shapes and Compositions: 400k examples detailing primitive shapes with 32 distinct attributes (color, location, texture).
- Objects: The 1,000 most frequent object categories from the ADE20K dataset.
- Scenes: 1,000 complex scene descriptions sampled from MS-COCO.
- Human Drawings Dataset: A crowdsourced dataset of 600 human drawings recorded as Processing code, used to evaluate the LLM's recognition capabilities on out-of-distribution data.
- Downstream Evaluation Datasets: ImageNet-1k and ImageNet-100 were used to benchmark the performance of the vision models trained on LLM-generated images.
Key Insights and Ideas
- LLMs understand layout but lack texture: LLMs are surprisingly adept at handling spatial relations (e.g., arranging a "row of bicycles" horizontally) and abstract compositions (e.g., a "car-shaped cake"). However, they struggle heavily with fine-grained textures, precise geometries, and realistic object-to-object contact.
- Creation is easier than verification: For humans, recognizing an object is usually easier than drawing it. For LLMs, the opposite is true. They can generate highly detailed scene code but fail miserably at reading similar code to identify what it depicts.
- Self-talk bridges the capability gap: Iterative text-based feedback acts as a powerful regularizer. Through multiple rounds of self-correction, a weaker model like GPT-3.5 can be boosted to match the drawing capabilities of a baseline GPT-4.
- Text models can bootstrap vision models: The structural and spatial priors embedded in LLM-generated code are rich enough to train a vision model that transfers successfully to real-world natural images.
Key Results
- Fidelity and Diversity: LLMs do not just output a single memorized prototype; they can generate highly diverse interpretations of the same concept.
- Recognition Failure: LLMs performed poorly when classifying human drawings from code. On the complex scenes category, GPT-3.5 achieved an accuracy of 38.0% and GPT-4 achieved 21.2% (where chance was 20.0%), highlighting a severe limitation in code-based spatial reasoning.
- Vision Training Success: A ResNet-50 trained purely on LLM-generated images achieved a 36.16% top-1 linear accuracy on ImageNet-1k. When the LLM images were combined with a texture-rich procedural dataset (Shaders-21k), the performance jumped to 46.03%, outperforming state-of-the-art procedural baselines like FractalDB and Dead-leaves.
Limitations and Future Work
- The Realism Gap: LLM-generated images look like primitive vector graphics or clip art. They entirely lack natural textures, complex shading, and photographic realism, which limits their standalone utility for training vision models.
- Code Execution Dependency: This methodology relies entirely on the LLM's ability to write valid, executable code. Smaller, open-source models (like Llama-2-70B) failed to generate reliable code and had to be excluded from the main study.
- Future Directions: The authors suggest exploring how explicit prompts for procedural textures might close the realism gap, and how the emergence of native multimodal models (like GPT-4V) will change our understanding of what language-only models can encode.
Summary updated