Introduction
Vision-Language Models (VLMs) like GPT-4o and LLaVA have demonstrated remarkable multimodal capabilities. However, their performance on geometric reasoning tasks remains a significant challenge. The primary issues are twofold: stochastic calculation errors, where models hallucinate values for complex calculations, and formula misapplication, where models fail to recall or correctly apply geometric formulas from their parametric memory. Traditional Chain-of-Thought (CoT) methods, while improving step-by-step reasoning, do not solve these underlying mathematical inaccuracies.
Methodology: The GeoCoder Framework
To address these limitations, we introduce GeoCoder, a framework that shifts the reasoning paradigm from natural language generation to modular code generation. Instead of predicting a final numerical answer directly, the VLM is trained to generate Python code that utilizes a specialized geometry function library.
Modular Code-Finetuning and Function Library
GeoCoder employs a library of 47 specialized geometric functions (e.g., pythagorean_theorem, area_of_sector). By offloading calculations to a deterministic Python interpreter, the model avoids the pitfalls of autoregressive token prediction for math. Each function includes templated print statements to ensure the execution trace remains human-interpretable.
RAG-GeoCoder
To further enhance performance and reduce the model's reliance on memorizing the entire library, we developed RAG-GeoCoder. This variant incorporates a multimodal retriever that identifies the most relevant functions for a given problem and provides their definitions as context in the prompt. This retrieval-augmented approach significantly reduces syntax errors and improves library utilization.
Datasets and Evaluation
We evaluated GeoCoder on several benchmarks, including GeomVerse, GeoQA-NO, and Geo170k-NO. A key contribution of this work is the release of a first-of-its-kind multimodal dataset for code instruction-tuning, containing over 80,000 data points pairing geometry problems with executable Python code.
Results
The experimental results demonstrate that code-based reasoning provides a substantial advantage over traditional text-based methods. On the GeomVerse benchmark, GeoCoder and RAG-GeoCoder outperformed CoT-finetuned baselines by an average of 16%.
As shown in the table above, GeoCoder maintains high accuracy even as problem complexity (depth) increases. On "Depth 3" problems, GeoCoder achieved approximately 60% accuracy, compared to 42% for the LLaVA 1.5 7B baseline. Furthermore, on the MathVerse benchmark, GeoCoder outperformed the G-LLaVA model by over 10%, demonstrating strong generalization capabilities.
Conclusion and Future Work
GeoCoder represents a significant step forward in geometric reasoning for VLMs by leveraging the precision of executable code. While current limitations include the scope of the function library and the precision of vision encoders for abstract diagrams, future work will focus on expanding the library and integrating external mathematical APIs to further bolster reasoning robustness.
Summary updated