PropTest: Automatic Property Testing for Improved Visual Programming

Jaywon Koo, Ziyan Yang, Paola Cascante-Bonilla, Baishakhi Ray, Vicente Ordonez

Introduction

Visual reasoning tasks, such as identifying objects based on spatial relationships or specific attributes, present significant challenges for end-to-end neural networks. Visual Programming has emerged as a powerful paradigm where a Large Language Model (LLM) generates executable code (e.g., Python) to solve these tasks by orchestrating specialized vision tools. However, existing frameworks like ViperGPT often suffer from "silent failures"—logical errors where the code executes without crashing but produces an incorrect answer.

Comparison of Baseline vs. PropTest showing how property tests prevent logical errors by validating the semantic category of the answer.

PropTest addresses this by introducing a "test-first" development cycle to visual programming. By automatically generating property tests (assertions) before the solution code, the system can detect semantic and logical mismatches that traditional error handling misses.

Methodology

The PropTest framework operates through a three-stage pipeline designed to enforce logical consistency and type safety in generated visual programs.

The three-stage PropTest pipeline: Property Test Case Generation, Code Generation, and Execution with fallback.
  1. Property Test Generation: The LLM first generates a suite of assertions (execute_test). These tests define the expected properties of the answer, including data types (e.g., string vs. bounding box), formatting (e.g., word count), and semantic validity. Semantic checks often utilize an LLM-as-a-judge to verify if a result belongs to a specific category (e.g., assert is_appliance(result)).
  2. Code Generation: With the property tests acting as a formal specification, the LLM generates the main logic (execute_command). The presence of these tests narrows the search space, guiding the model toward more robust and relevant code structures.
  3. Execution and Fallback: The system executes the generated code. If any assertion fails, or if a standard runtime/syntax error occurs, the system discards the code and falls back to a robust pre-trained Vision-Language Model (VLM) like BLIP-2 to provide a baseline answer.

Experimental Evaluation

PropTest was evaluated across several rigorous benchmarks, including GQA (compositional VQA), A-OKVQA (knowledge-based VQA), and RefCOCO/RefCOCO+ (visual grounding). The researchers utilized open-source models such as Llama 3 (8B/70B) and CodeLlama (7B/34B) to ensure reproducibility.

Key Results

  • Performance Gains: PropTest consistently outperformed the ViperGPT baseline. On GQA, it achieved 46.1% accuracy (+6.0% over baseline) using Llama 3-8B. On RefCOCO+, it reached 59.5% IoU (+8.1% improvement) with CodeLlama-34B.
  • Error Reduction: The framework significantly reduced the frequency of "silent failures." On the GQA dataset, PropTest reduced syntax errors from 89 to 36 and runtime errors from 322 to 227 compared to the baseline.
  • Model Efficiency: Interestingly, specialized code models like CodeLlama-34B often outperformed larger general-purpose models like Llama 3-70B, highlighting the importance of domain-specific pre-training for visual programming tasks.

Discussion and Conclusion

PropTest demonstrates that treating visual reasoning as a software engineering problem—specifically through Test-Driven Development (TDD)—can substantially improve the reliability of LLM-generated code. The use of semantic assertions allows the system to bridge the gap between rigid programmatic logic and the inherent ambiguity of visual concepts. While the approach introduces some inference overhead, the resulting improvements in accuracy and interpretability make it a compelling framework for complex visual reasoning.

Summary updated

BibTeX
@inproceedings{koo2024proptest,
  author = {Jaywon Koo and Ziyan Yang and Paola Cascante-Bonilla and Baishakhi Ray and Vicente Ordonez},
  title = {{PropTest: Automatic Property Testing for Improved Visual Programming}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.483},
}
Figure