Abstract
Visual programs generated by Large Language Models (LLMs) often suffer from logic errors that undermine their performance on complex visual reasoning tasks. We present VDebugger, a framework that utilizes execution feedback to identify and rectify these errors. By training a critic-refiner model on step-by-step execution traces, VDebugger significantly enhances the accuracy and interpretability of visual reasoning across diverse benchmarks, demonstrating strong generalization to unseen tasks.
Introduction
Large Language Models (LLMs) are increasingly employed to solve complex visual reasoning tasks by generating "visual programs"—sequences of executable code that call specialized computer vision tools. While powerful, these programs are often brittle. Research indicates that approximately 58% of errors in such systems stem from program logic flaws rather than failures in the underlying vision tools. Existing debugging methods, such as zero-shot prompting, often fail to catch deep logic errors, particularly in smaller LLMs that lack the inherent self-correction capabilities of models like GPT-4.
The VDebugger Framework
VDebugger introduces a two-stage process for identifying and fixing code by leveraging execution feedback (the values of variables at every single line of code):
- The Critic: This model analyzes the program alongside its execution feedback. It predicts program correctness and localizes the exact line where an error occurs. By seeing the actual output of each step (e.g., a list of detected colors), the Critic can identify contradictions between the code's intent and its results.
- The Refiner: Once a bug is localized, the refiner utilizes the execution trace to rewrite the faulty line, correcting the logic.
Training via Mask-Best Sampling
To train VDebugger, the authors developed a "mask-best" sampling strategy to generate a massive dataset of 47.7k program pairs. This automated pipeline injects realistic errors into correct programs by masking code segments and prompting an LLM to fill them using low-probability samples from the "tail" of the distribution. This creates plausible but logically flawed programs (e.g., API misuse or incorrect spatial reasoning) that mirror the mistakes humans or LLMs actually make.
Experimental Results
VDebugger was evaluated on diverse benchmarks including GQA, TallyQA, NLVRv2, and RefCOCO. Key findings include:
- Accuracy Boost: VDebugger improved downstream task accuracy by up to 3.2% on standard benchmarks, consistently outperforming baselines like SelfDebug and LDB.
- Cross-Model Debugging: Models trained on CodeLlama successfully debugged programs generated by GPT-3.5 and DeepSeek-Coder, showing that debugging logic transfers across architectures.
- Generalization: On the unseen COVR task (reasoning over a variable number of images), it provided a 2.3% improvement, demonstrating that it learns general debugging principles rather than just memorizing dataset patterns.
Conclusion and Future Work
VDebugger demonstrates that execution feedback is essential for debugging visual programs. By explicitly training smaller models on execution traces, they can achieve high-level debugging performance. Future work aims to develop multimodal debuggers that can inspect visual intermediate outputs and provide natural language explanations for identified bugs.
Summary updated