Abstract
Solving geometry problems is a multi-stage challenge for Vision-Language Models (VLMs), requiring accurate visual perception, formula recall, and precise calculation. We introduce GeoCoder, a framework that shifts the mathematical burden from the model's parametric memory to an external Python interpreter. GeoCoder generates modular code that calls a library of 47 verified geometric functions. Our approach achieves a 16% average performance boost over standard reasoning methods, reaching 95.7% accuracy on synthetic benchmarks and significantly outperforming baselines on real-world geometry exams.
Introduction
Despite the success of models like GPT-4o, geometry remains a "final boss" for multimodal AI. Success requires three distinct capabilities: visual perception of diagrams, mathematical reasoning to sequence formulas, and precise calculation. Current models often fail because they rely on parametric memory to both recall formulas and perform calculations, leading to hallucinations and arithmetic errors. GeoCoder addresses this by enabling the model to act as a "tool-user," generating code that executes in a deterministic environment.
Methodology
The GeoCoder framework consists of two primary models: the base GeoCoder and the retrieval-augmented RAG-GeoCoder.
Modular Code Generation
Instead of natural language "Chain-of-Thought" (CoT), GeoCoder generates Python code. This code utilizes a predefined library of 47 modular functions, such as area_of_trapezoid or length_of_third_side. This ensures that the model applies verified mathematical formulas rather than hallucinating its own.
Knowledge Distillation and RAG
To train the student VLM (LLaVA 1.5 7B), a text-only teacher LLM (Llama 3.1 70B) was provided with TikZ code descriptions of geometry figures to generate "gold" Python solutions. These solutions were then used for fine-tuning. To further enhance performance, RAG-GeoCoder incorporates a multimodal retriever. Using a VISTA encoder and FAISS, the system identifies relevant functions from the library based on the problem image and text, injecting their definitions directly into the model's prompt. This retrieval mechanism increased library function usage by 17%.
Datasets
The study introduces a first-of-its-kind multimodal dataset containing 35k points from GeomVerse (synthetic) and 48k from Geo170k (real-world), specifically paired with modular Python code. Real-world problems were derived from Chinese middle school exams (GeoQA-NO), representing a significant leap in complexity over synthetic data.
Key Insights and Results
GeoCoder transforms stochastic math into a deterministic process. By picking the right "tool" from the library, the model avoids arithmetic errors. Furthermore, the system provides high interpretability; each library function includes templated print statements that generate human-readable explanations of the solution steps.
Performance Metrics
GeoCoder significantly outperformed state-of-the-art baselines on the GeomVerse dataset:
- Simple Problems (Depth 1): 95.7% accuracy (vs. 82% for baseline LLaVA).
- Complex Problems (Depth 3): 60.1% accuracy (vs. 42% for baseline).
- Real-World (GeoQA-NO): 42.3% accuracy, a 14.3% improvement over CoT baselines.
Conclusion
GeoCoder demonstrates that offloading calculation and formula recall to external tools significantly enhances VLM performance in geometry. While currently limited by the scope of its 47-function library and the visual parsing capabilities of current encoders, it provides a scalable path toward more reliable multimodal reasoning. Future work will focus on expanding the function library and improving visual perception for noisy, real-world diagrams.
Summary updated