TL;DR
Vision-Language Models (VLMs) exhibit a bizarre paradox: they can write precise 3D simulation code to reconstruct a scene, yet fail at basic spatial questions (like counting the objects) about the exact same image. This paper exploits this quirk by using 3D geometric primitives in code as an intermediate "spatial language," introducing a training-free inference strategy (Code-CoT) and a self-supervised fine-tuning method ($S^3$-FT) that dramatically improve VLM spatial reasoning without requiring human labels.
What Problem Does This Paper Address?
Despite their impressive capabilities, modern VLMs suffer from a "task-routing failure" when it comes to spatial understanding. If you show a VLM a simple image of a cube and a cylinder and ask "how many objects?", it will frequently hallucinate an incorrect answer. However, if you ask the same model to write Three.js or Blender Python code to reconstruct the scene, it will often generate a perfect script placing the exact correct number of shapes at the right 3D coordinates.
The spatial knowledge is clearly inside the model, but standard natural-language prompting fails to access it. The authors set out to diagnose this format-dependency gap, benchmark it across various programming languages, and leverage it to improve general VLM spatial reasoning.
Methods
The authors introduce two primary interventions to bridge the spatial reasoning gap:
- Code-CoT (Code Chain-of-Thought): A training-free inference strategy. Instead of answering a spatial question directly, the VLM is prompted to first write a complete 3D primitive-based code reconstruction of the scene. It then answers the natural-language question conditioned on its own generated code.
- $S^3$-FT (Self-Supervised Spatial Fine-Tuning): A three-phase pipeline designed to distill a model's implicit spatial code knowledge into general visual reasoning:
- Phase 1 (Generation): The base VLM generates Three.js reconstruction code for thousands of primitive images.
- Phase 2 (Extraction): A deterministic parser translates the model's valid code into structured scene graphs, bounding boxes, and synthetic QA pairs.
- Phase 3 (Fine-Tuning): The model is fine-tuned via LoRA on this self-generated multi-task mixture. Crucially, this requires zero human labels and no teacher model.
Datasets
The paper introduces SPATIALBABEL, a new benchmark to evaluate VLM spatial understanding via 3D reconstruction and QA. It features two main splits:
- Primitive Scenes: 1,000 procedurally generated Blender images containing 3 to 20 geometric shapes (cubes, spheres, cones, etc.) across five complexity tiers.
- Hypersim Indoor Scenes: 405 photorealistic indoor renders used as a complex validation domain with real-world furniture and heavy object occlusion.
Reconstructions are evaluated across six distinct "scene-code languages": Three.js, Unity C#, Blender Python, Open3D Python, Canonical JSON, and Scene Language DSL.
For out-of-distribution validation, the authors test their models on standard real-photo benchmarks: CV-Bench-2D/3D, HallusionBench, and BLINK.
Key Insights and Ideas
- Code as Spatial Tokenization: VLM code pre-training has implicitly tokenized 3D space through geometric primitives. Writing code forces the model to systematically account for shape, scale, position, and orientation in a way that natural language cannot.
- Extreme Format Sensitivity: A VLM's spatial fidelity changes drastically depending on the requested programming language. The authors observed up to a 5.7× variance in object-detection F1 score within the same model simply by changing the target code language.
- Upstream Bottleneck: Relational QA performance is weakly correlated with raw code-generation skill. This suggests that the bottleneck isn't a lack of spatial evidence, but rather the model's inability to route that evidence to a natural language output without an explicit scaffold.
Key Results
- Code-CoT Improvements: Applying Code-CoT boosted spatial QA accuracy by up to +6.4% on primitive scenes and lifted real-photo CV-Bench-3D accuracy by +5.0% for models with strong coding capabilities (like Claude Sonnet 4.6).
- $S^3$-FT Performance: Fine-tuning on self-generated primitive data yielded massive out-of-distribution gains on real-world photo benchmarks. For example, Qwen3-VL-8B improved by +9.7% on CV-Bench-2D and +17% on HallusionBench.
Limitations and Future Work
The primary limitation of $S^3$-FT is its dependency on the base model's initial code-generation quality. On highly cluttered real-world scenes (like the Hypersim dataset), the base models only managed to capture about 38% of the objects, introducing substantial label noise that caused the fine-tuning recipe to regress.
For future work, the authors plan to expand the primitive vocabulary to better approximate complex real-world geometries, introduce occlusion-aware training signals, and scale the pipeline to larger frontier models.
Summary updated