Visual Program Unit Testing for Reliable Reasoning

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing visual programming systems generate non-transferable and unreliable code due to flawed underlying logic, despite producing correct outputs on training data, leading to difficulties in generating good training data and ensuring code reliability.

Innovation Solution

Utilize a Large Language Model (LLM) to automatically generate unit tests with image descriptions and expected answers, apply these tests to multiple programs, and select the highest scoring program, with reinforcement learning to improve model performance and reliability.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If supervised methods are used to improve visual program synthesis performance, then the model can leverage training data to generate correct outputs, but the underlying logic may be flawed leading to non-transferable and unreliable code

Engineering Contradiction:
Improveoutput correctnessVSAvoidcode reliability
Core Design Contradiction:
Measurement precisionVSReliability

Solution Approach 1:

The system performs preliminary actions by generating multiple candidate programs before selecting the final one. Instead of directly generating a single program from training data, the model creates several candidate solutions and evaluates them against unit tests, ensuring that the selected program has sound underlying logic and will transfer reliably to new tasks.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system implements feedback mechanisms by using unit tests to evaluate candidate programs. The results of these tests provide feedback that guides the selection process, allowing the system to identify and select programs with correct logic rather than merely those that happen to produce correct outputs on training data.

Inventive Principle:
Principle #23Feedback

2Adaptability or versatility

If a language model generates code to answer visual questions, then the system can handle compositional reasoning tasks, but the generated code may produce correct outputs for incorrect reasons

Engineering Contradiction:
Improvecompositional reasoning capabilityVSAvoidreasoning correctness
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

The system generates multiple candidate programs as preliminary actions before final selection. This allows the model to explore different reasoning approaches and select the one with correct logic, rather than committing to the first generated solution that may have flawed reasoning despite producing correct outputs.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

Unit tests provide feedback on the reasoning correctness of candidate programs. By evaluating each candidate against carefully designed unit tests that check for correct reasoning patterns, the system can identify programs that produce correct outputs for incorrect reasons and eliminate them in favor of programs with sound logic.

Inventive Principle:
Principle #23Feedback

3Reliability

If multiple programs are generated and evaluated with unit tests, then the reliability of the selected program improves, but the computational complexity and time required increases

Engineering Contradiction:
Improveprogram reliabilityVSAvoidevaluation time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The system applies partial action by generating a limited but sufficient number of candidate programs rather than exhaustively searching all possible programs. This generates enough candidates to ensure reliable selection while avoiding excessive computational overhead. The unit test evaluation is also applied selectively to focus on discriminating between correct and incorrect reasoning patterns.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The system performs preliminary filtering of candidate programs before full evaluation. By quickly assessing candidates and eliminating obviously incorrect ones, the system reduces the number of programs that require comprehensive unit test evaluation, thereby reducing overall evaluation time while maintaining reliability.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS20260044436A1Systems and methods for visual programming
Publication Date: 2026.02.12 SALESFORCE INC
  • US20260044436A1 patent drawing
  • US20260044436A1 patent drawing
  • US20260044436A1 patent drawing

AI summary

Embodiments described herein provide for utilizing a large language model (LLM) to automatically generate unit tests, comprising image descriptions and expected answers for specified queries for use in visual programming. Further, text-to-image generation models are utilized to create images that align with the descriptions provided in each unit test. In some embodiments, a system executes only the top-scoring programs, reverts to a baseline model in cases of low scores, uses unit tests for re-prompting, and/or applies unit tests in reinforcement learning scenarios.