Manuscript Offprint
arXiv:2610.38737RuleForge: Inferring and Instantiating Latent Visual Rules as Executable Programs
Weifeng Xu
Institute of Artificial Intelligence and
Brain Sciences, University of Macau
Macau, China
Faculty of Information Science and
Computing, University of Macau
Macau, China
Yaxiong Wang
Hefei University of Technology
Hefei, China
Zhedong Zheng
Institute of Artificial Intelligence and
Brain Sciences, University of Macau
Macau, China
Faculty of Information Science and
Computing, University of Macau
Macau, China

Figure 1: The proposed RuleForge framework for jointly learning visual rule understanding and executable generation. Given a Bongard-Forge100k problem containing six positive and six negative panels, the model selects the separating rule and provides a natural-language explanation. Through a separate generation interface, the corresponding target rule is provided as input, and the model generates an executable scene program that produces new rule-consistent instances under five fixed seeds. "What I cannot create, I do not understand." – Richard Feynman
Abstract
Visual rule reasoning asks whether multimodal models can recover an abstract concept from a few examples. Existing studies either infer rules from visual examples but evaluate only classification or verbalization, or supervise executable generation with rules provided as input. Consequently, the relationship between visual rule understanding and reliable rule instantiation remains insufficiently explored. We present Bongard-Forge100k, a controlled benchmark, together with RuleForge, a backbone-agnostic framework that jointly learns visual rule understanding and rule-conditioned executable generation. The benchmark contains 108,797 problems: 86,000 for training, 19,297 for testing familiar rules, and 3,500 for testing held-out rule compositions. The framework progresses through rule-understanding training, joint understanding and scene-program supervision, and refinement via execution-grounded reinforcement learning with Understanding Replay. Executing generated programs under multiple random seeds provides verifiable feedback on executability, rule satisfaction, diversity, and robustness. With UniLIP as the primary backbone, RuleForge improves multiple-choice accuracy over the base model by 20.93 percentage points on familiar
rules and 28.42 percentage points on held-out rule compositions, while increasing scene-level rule satisfaction on familiar rules from 2.91% to 70.99%. Additional experiments on InternVL3.5, Qwen3-VL, and Show-o2 demonstrate the effectiveness of the proposed training data and framework across diverse multimodal architectures.
CCS Concepts
• Information systems → Question answering; Multimedia content creation; • Computing methodologies → Rule learning; Reinforcement learning.
Web Relevance. This work advances verifiable understanding and generation of structured multimodal Web content, aligning with Web Mining and Multimedia Content Analysis.
1 Introduction
Multimodal visual assets on the Web [22, 24]—such as charts [20], infographics [27], and template-driven visual layouts [23, 41]—frequently convey meaning through structured visual relations [6] rather than isolated appearances [23, 26, 27]. For many such assets, correctness depends in part on relational invariants: when objects vary in scale, position, or styling, specified constraints such as cardinality, containment, spatial relations, or symmetry should remain satisfied. Analyzing and constructing such rule-governed visual content therefore involves two complementary capabilities: inferring latent relational rules from positive and negative visual examples, and constructing new instances that verifiably satisfy explicitly specified relational constraints.
Prior visual reasoning research has largely decoupled rule understanding from executable generation. Classical Bongard problems require a solver to infer and verbalize the rule separating two sets of visual examples [3, 7]. Modern Bongard-style benchmarks commonly operationalize this ability through query-image classification, while recent studies of multimodal large language models also examine natural-language rule descriptions [13, 25, 28]. Although these protocols evaluate whether a model can recognize or describe an abstract regularity, they do not test whether it can instantiate an explicitly specified rule through executable scene generation. Conversely, representative program-aided reasoning methods generate executable intermediate programs from explicit questions or instructions [8, 11, 34], rather than studying whether visual rule induction and rule-conditioned scene generation can be jointly supported by the same model. Existing protocols therefore leave an important question unresolved: whether a shared multimodal model can jointly acquire these two capabilities while retaining visual rule understanding during generation-oriented optimization.
Addressing this question requires an environment in which rules are formally defined, visual interventions are strictly controlled, and synthesized instances can be deterministically audited. Such a benchmark must jointly provide explicit relational rules, executable scene specifications, controlled visual interventions, and deterministic validators for newly generated instances. Bongard-Forge100k is designed to provide these capabilities. It contains 108,797 visual reasoning problems covering 62 registered base rules and 24 held-out rule compositions. The benchmark combines positive and negative visual panels under systematic variations of non-target attributes with structured rule specifications, programmatic scene generators, and deterministic rule checkers. This design enables rigorous evaluation of robustness to non-target visual variations under familiar rules, as well as systematic compositional generalization to unseen rule combinations.
Building on Bongard-Forge100k, we propose RuleForge, a three-stage, backbone-agnostic framework that progressively learns visual rule understanding and rule-conditioned program synthesis within a shared vision-language model. Stage I establishes visual rule understanding through multiple-choice rule prediction, natural-language rule explanation, candidate-rule verification, and structured scene-fact prediction. Stage II adds program synthesis conditioned on separately provided target-rule descriptions and jointly optimizes the two task families through shared model parameters
and a 2:1 understanding-to-generation mixture. Stage III refines candidate scene programs using Group Relative Policy Optimization (GRPO) [33], driven by multi-seed execution rewards that account for executability, rule satisfaction, structural diversity, scene integrity, and conjunct coverage. An Understanding Replay objective is retained during policy refinement to mitigate degradation in visual rule understanding.
We evaluate RuleForge across four multimodal backbones: UniLIP, InternVL3.5, Qwen3-VL, and Show-o2 [2, 35, 36, 42]. We additionally report zero-shot results from two commercial-model references, GPT-6-Sol and Gemini-2.5 Flash-Lite [9, 29]. On visual rule understanding, Stage III UniLIP improves multiple-choice accuracy over its base model by 20.93 percentage points on familiar rules, from 64.08% to 85.01%, and by 28.42 percentage points on held-out compositions, from 37.58% to 66.00%. On executable generation evaluated under separately provided target-rule descriptions, its scene-level rule satisfaction (RuleSat) increases from 2.91% to 70.99% on familiar rules and reaches 38.40% on held-out compositions. The other three backbones also improve over their respective base models in multiple-choice accuracy and familiar-rule scene-level RuleSat. Our main contributions are threefold:
- We formulate visual rule learning through the complementary evaluation and joint training of visual rule understanding and rule-conditioned program synthesis from separately provided target rules, and construct Bongard-Forge100k, a controlled diagnostic benchmark containing 108,797 problems with structured rule specifications, executable scene generators, and deterministic checkers.
- We propose RuleForge, a backbone-agnostic three-stage framework that combines progressive multimodal instruction tuning, multi-seed execution feedback, and Understanding Replay.
- We conduct systematic evaluations across four multimodal backbones, demonstrating consistent gains in visual rule understanding and executable program synthesis, and additionally report two zero-shot commercial-model references.
2 Related Work
Bongard Problems and Visual Rule Reasoning. Bongard problems study concept induction from small sets of positive and negative visual examples [3]. Modern benchmarks include programmatically generated geometric concepts in Bongard-LOGO [28], relational human-object interactions in Bongard-HOI [13], and free-form concepts in real-world images in Bongard-OpenWorld [39]. Recent analyses [7, 25] further show that multimodal large language models still struggle with abstract rule induction [15, 40] and systematic visual reasoning [21, 37]. Existing evaluation protocols primarily assess query classification or natural-language rule induction, leaving open whether a rule can also support the construction of new valid instances. Langenfeld et al. [18] instead generate parameterized programmatic hypotheses and fit them to classify candidate images. Bongard-Forge100k provides a complementary generative setting in which models are evaluated on visual rule understanding and rule-conditioned scene-program synthesis. RuleForge trains a shared backbone for both capabilities, while keeping their input interfaces explicitly separated.
Table 1: Comparison with representative Bongard benchmarks. Inventory entries follow the native definitions of the respective benchmarks and are therefore not directly equivalent measures of concept complexity. “Executable generation” indicates whether generating executable scene-construction programs constitutes an evaluated model task. Bongard-LOGO uses rendering programs to construct its benchmark, but its standard evaluation task is binary classification.
| Benchmark | Understanding task | Executable generation | Visual domain | # Problems | Concept inventory |
|---|---|---|---|---|---|
| Original Bongard Problems [3] | Verbal rule induction | No | Diagrams | 100 | Problem-specific visual concepts |
| Bongard-LOGO [28] | Binary classification | No | Drawings | 12,000 | 627 shape categories; 25 abstract attributes |
| Bongard-HOI [13] | Binary classification | No | HOI images | ~53,000 | 242 HOI concepts |
| Bongard-OpenWorld [39] | Binary classification | No | Web images | 1,010 | 1,010 free-form concepts |
| Bongard-Forge100k | Multiple-choice rule recognition;free-form rule explanation | Yes (scene programs) | Rendered scenes | 108,797 | 62 registered base rules; 24 held-out compositions |
Structured Visual Content and Unified Multimodal Models. Charts, infographics, and template-driven layouts illustrate how structured visual content depends on quantitative, spatial, and layout relations rather than isolated object appearance. ChartQA [26] and InfographicVQA [27] evaluate reasoning over such content, while LayoutPrompt [23] formulates layout generation through explicit element and spatial constraints. Unified multimodal models such as Janus [38], UniLIP [35], and Show-o2 [42] further support combinations of understanding and generation within shared architectures [1]. RuleForge focuses on whether the same backbone can acquire visual rule understanding and rule-conditioned structured generation. Generated programs are executed in a controlled scene environment and evaluated by deterministic rule checkers, allowing relational constraints to be audited directly [17] rather than through output plausibility alone.
Program Synthesis and Execution-Grounded Learning. Executable programs provide intermediate representations for reasoning and interfaces to external tools. PAL [8] delegates symbolic computation to a Python interpreter, whereas VisProg [11] and ViperGPT [34] compose vision models and code modules for multimodal queries. Self-Debugging [5] and CRITIC [10] use execution or tool feedback to revise outputs at inference time. Training-time approaches [14] such as CodeRL [19] optimize code generation using functional correctness, while DeepSeekMath [33] introduces Group Relative Policy Optimization for reasoning outputs. RuleForge extends execution-grounded learning to parameterized visual-scene construction: candidate programs are executed under multiple random seeds and evaluated for executability, rule satisfaction, structural diversity, scene integrity, and conjunct coverage. Understanding Replay, motivated by prior work that retains original objectives during policy optimization [30], limits degradation in visual rule understanding [44] while executable generation is refined.
3 The Bongard-Forge100k Benchmark
Bongard-Forge100k evaluates two complementary capabilities: inferring a latent visual rule from positive and negative examples, and constructing new scenes that satisfy a given rule through executable programs. We use scene to denote a structured object configuration, panel for its rendered image, and problem for an instance containing six positive and six negative panels.
We position Bongard-Forge100k relative to representative Bongard benchmarks in Table 1. While prior benchmarks primarily
evaluate query classification or verbal rule induction, Bongard-Forge100k additionally supports rule-conditioned executable scene-program generation. Its construction pipeline is summarized in Figure 2.
3.1 Rule Inventory and Specification
The rule inventory draws on recurring concepts in classical Bongard problems [3], Bongard-LOGO [28], and diagnostic visual reasoning datasets such as CLEVR [16]. We reorganize and extend these concepts into 62 registered base rules across 15 semantic families, covering counting, attributes, ranking, containment, topology, symmetry, alignment, grouping, contact graphs, logical equivalence, and set structure. A base rule denotes a registered construction unit and may contain more than one logical predicate.
Each rule has four mutually consistent components: a natural-language description , a structured specification, a scene sampler, and a deterministic checker . The checker determines whether scene satisfies the rule, making problem construction and generated-scene evaluation auditable. The eight display groups in Figure 2 aggregate finer rule-family metadata only for visualization and do not alter the taxonomy of 62 base rules and 15 semantic families.
A rule can be instantiated through many combinations of object identities, attributes, positions, and relations. Repeated problems therefore test invariance to non-target visual changes, while held-out compositions test whether familiar predicates can be recombined under unseen bindings. Language models were used only to help draft some initial rule descriptions; ground-truth semantics and labels are fixed by the structured specifications, samplers, and deterministic checkers.
3.2 Problem Construction and Supervision
For a target rule , the generator retains positive and negative scenes satisfying
Both groups share the same rendering vocabulary while varying in object identity, color, fill, size, position, and other non-target properties. Geometry and diversity checks reject malformed scenes, invalid relations, out-of-canvas objects, and near duplicates.
For a conjunctive rule , positive scenes satisfy both constituents. Close negative counterexamples satisfy one constituent while violating the other, preventing either constituent alone from separating the groups. The generator also rejects problem sets in which predefined non-target statistics, such as object
(a) Diverse Visual Rules

Figure 2: Overview of Bongard-Forge100k. (a) Representative problems covering counting, attributes and size, spatial relations, and containment. (b) The controlled construction pipeline, a structured problem record, and dataset composition. The donut chart's inner ring represents the training, familiar-rule test, and held-out-composition test splits. The outer ring partitions each split into eight display groups aggregated from finer rule-family metadata for legibility; sector sizes are proportional to problem counts. (c) Held-out compositions combine rules observed individually during training, requiring both constituent conditions to hold in positive examples.
counts or individual attribute frequencies, perfectly separate the two groups.
Each accepted problem contains six positive and six negative scenes rendered as a 4 × 3 contact sheet. Following the Bongard convention [3, 28], the positive and negative groups occupy the left and right halves, respectively, while panels are shuffled within each group.
Understanding supervision. Each visual problem supports multiple-choice rule recognition and free-form rule explanation, together with auxiliary verification and factual tasks used during training. The correct answer is derived from the registered rule and structured annotation. For expanded multiple-choice problems, Qwen3.5-9B proposes plausible distractors, which are screened for correctness, distinctness, and support from the displayed panels. This model-assisted process constructs challenging options but does not assign ground-truth labels.
Test-set fidelity and human audit. Automated checks verify scene polarity, annotations, option consistency, and duplicate content. We also manually audited 1,000 randomly sampled test problems. Of these, 966 passed all checks initially; the remaining 34 contained an ambiguous or invalid option and were corrected and rechecked before evaluation. The finalized benchmark retains its rule specifications, generation provenance, audit status, and checker outputs.
Executable-generation supervision. Generation records are maintained separately from visual problems. Each record provides a target-rule description and the scene API as input, with a reference scene program as output. During execution-grounded reinforcement learning, the reference program is removed, and generated scenes are evaluated against the structured target rule. Program records are therefore supervision views of the shared rule system rather than additional Bongard-Forge100k problems.
3.3 Dataset Statistics and Evaluation Splits
Bongard-Forge100k contains 108,797 visual reasoning problems: 86,000 for training, 19,297 for familiar-rule testing, and 3,500 for testing held-out rule compositions. The training set comprises 78,000 problems from 57 registered base rules and 8,000 problems from 40 training compositions.
The training data yield 172,000 understanding instruction records, including rule explanation, multiple-choice recognition, candidate verification, and factual prediction. Separate generation supervision provides 24,000 program records covering all 62 base rules, while execution-grounded reinforcement learning uses 16,000 prompts covering 163 rule compositions. These records do not increase the count of independent visual problems.
The familiar-rule test set contains new visual instantiations of rules present during training. The held-out set contains 3,500 problems from 24 predefined rule compositions whose exact combinations are excluded from training. Thus, 24 denotes distinct held-out compositions, whereas 3,500 denotes their visual instantiations under different object configurations and nuisance attributes.
Executable-generation evaluation uses 223 familiar-rule prompts and one prompt for each of the 24 held-out compositions. Each generated program is executed under five fixed random seeds to measure executability and rule consistency under scene variation. Unsuccessful executions remain part of the evaluation rather than being discarded.
Before evaluation, the test sets are frozen using checks for task-annotation correspondence, image decoding, exact and normalized-image duplication, source overlap, recomputed rule measurements, and multiple-choice consistency. Duplicate source or image content is excluded, and source hashes are retained to make the finalized test sets auditable.
4 Method
4.1 Task Formulation and Unified Model
RuleForge trains a unified vision-language model (VLM) for two complementary tasks that use different input interfaces but share the same multimodal backbone and language decoder.
Visual rule understanding. Given a contact sheet I containing positive and negative examples and an instruction , the model predicts a response . We consider four output types: multiple-choice rule prediction, natural-language explanation, candidate-rule verification, and structured scene-fact prediction. These tasks respectively provide supervision for rule discrimination, verbalization, consistency checking, and visual grounding.
For an understanding record with target tokens , we optimize the target-token-normalized understanding loss
Only response tokens contribute to the loss. Length normalization prevents longer explanations and structured fact sequences from dominating shorter classification or verification responses.
Rule-conditioned executable generation. Given a separately provided target-rule description and the scene-construction API , the model predicts a program using
The program constructs positive scenes satisfying the target rule and negative scenes violating it while allowing non-target properties to vary. Execution makes the model's interpretation directly testable by the deterministic Rule Checker.
The two tasks capture complementary directions of rule learning. Understanding maps visual evidence into rule language, whereas generation maps a separately provided rule into executable form. Generation does not directly consume the contact sheet, separating rule-recovery errors from program-synthesis errors while allowing both capabilities to benefit from shared model parameters.
Figure 3 summarizes the two interfaces and three-stage training process. We abbreviate the generation interface as Rule-Conditioned Generation, the scene-construction API as the Scene API, and its supervision as Program SFT.
We use LoRA [12] for parameter-efficient adaptation. The image encoder and base language-model weights remain frozen. Stage I updates the multimodal projector and language-model LoRA parameters, whereas Stages II and III freeze the projector and update only LoRA. This preserves the visual alignment established in Stage I while allowing later stages to introduce executable generation and execution-grounded refinement.
4.2 Progressive Supervised Training
RuleForge first establishes visual rule understanding and then adds program generation, providing the shared decoder with a stable rule-oriented representation before it learns structured programs.
Stage I: Visual Rule Understanding. Stage I optimizes Equation 2 over the four understanding tasks using a fixed task mixture.
Multiple-choice prediction supplies the main discriminative signal, while explanation, verification, and scene-fact prediction provide complementary semantic and perceptual supervision. The sampling probabilities are provided in the appendix.
This multi-task design reduces dependence on any single response format. Explanation requires independent rule verbalization, verification evaluates a proposed rule against all examples, and scene-fact prediction grounds the decision in object properties and relations. Target-token masking and response-length normalization balance short decisions against longer explanations and structured outputs.
Stage II: Joint Understanding and Executable Generation. Stage II retains Understanding SFT and introduces Program SFT using Equation 3. Each Program-SFT record contains a target-rule description, the Scene API, and a reference program. The program produces six positive scenes satisfying the target rule and six negative scenes violating it while varying rule-irrelevant attributes. These records teach the syntax and composition patterns of the Scene API without reducing generation to a fixed scene template.
Training interleaves two Understanding-SFT batches with one Program-SFT batch. This 2:1 schedule preserves visual rule understanding while adding executable generation through the shared decoder. We compare understanding-only, generation-only, 1:1, and 2:1 configurations in Table 5(a), where the selected mixture provides the strongest overall balance.
Program SFT teaches the model to imitate reference programs, but it does not directly determine whether sampled programs execute safely, satisfy the target rule, or remain reliable across random scene realizations. Stage III therefore evaluates generated programs through execution and uses their observed behavior as the optimization signal.
4.3 Execution-Grounded Program Refinement
Stage III applies GRPO [33] to the generation capability acquired in Stage II. For each target rule, the current model samples candidate programs. Every candidate is executed under the same training seed set , containing three seeds. Shared seeds control unrelated scene variation during group-relative comparison. Unsafe programs, syntax failures, and runtime failures receive failure-specific penalties. Final generation metrics are recomputed using five fixed evaluation seeds per program, as described in Section 5. Execution constraints and failure penalties are provided in the appendix.
For every successful execution, the deterministic Rule Checker evaluates six positive and six negative scenes. Positive scenes should satisfy the target rule, whereas negative scenes should violate it. The reward also considers structural diversity, scene integrity, and conjunct counterexample coverage. Diversity and integrity contribute only after full rule satisfaction, preventing visually varied but semantically invalid programs from receiving additional credit. For composite rules, conjunct coverage checks whether negative scenes expose violations of different rule constituents.
To reduce dependence on favorable random choices, RuleForge considers both average and worst-seed performance across the

Figure 3: Overview of RuleForge. A unified VLM supports visual rule understanding from examples and rule-conditioned program generation from a separately given rule. Stage I trains rule understanding; Stage II jointly performs Understanding SFT and Program SFT; and Stage III applies multi-seed execution feedback through GRPO with understanding replay. Six candidate programs are executed under three shared training seeds, while final evaluation uses five fixed seeds. The shared connector indicates that the same VLM is progressively updated across all stages.
shared training seeds. We evaluate the worst-seed and conjunct-coverage components in Table 5(b). The full reward definition, aggregation rule, and coefficients are provided in the appendix.
GRPO compares candidates within each group and updates the model toward programs with stronger relative execution outcomes. We follow the clipped policy-optimization procedure of GRPO and PPO [32], using the frozen Stage II model as the reference policy. To prevent execution optimization from degrading visual rule understanding, Stage III also replays records from the Stage I task mixture using Equation 2. The optimization and regularization settings are provided in the appendix. Understanding Replay preserves rule recognition and explanation while execution feedback improves rule-conditioned program generation.
5 Experiment
Experimental Setup. We evaluate RuleForge on UniLIP-3B [35], InternVL3.5-2B [36], Qwen3-VL-4B-Instruct [2], and Show-o2-1.5B [42]. For each backbone, we compare the base model with Stages I–III. GPT-6-Sol and Gemini-2.5 Flash-Lite [9] serve as zero-shot commercial references. All trainable models are trained once with model-training seed 42 on a single NVIDIA GeForce RTX 4090 GPU. We set and in Stage III. Complete LoRA, optimization, batching, decoding, and runtime settings are provided in Appendix A. Visual rule understanding is evaluated on 19,297 familiar-rule and 3,500 held-out-composition Bongard-Forge100k problems. Multiple-choice accuracy (MCQ) is computed by exact matching against the ground-truth option. Explanation correctness
(Exp.) is assessed by a Qwen3.5-2B [31] judge [4, 43] under a fixed semantic-matching rubric, and joint accuracy requires both outputs to be correct for the same problem. Unparsable predictions and invalid judge outputs are counted as incorrect. On 200 familiar-rule and 200 held-out-composition samples, the judge achieves 94% agreement with human assessment.
Executable generation is evaluated on 223 familiar-rule descriptions and all 24 held-out compositions. Each program is executed under five fixed seeds and produces six positive and six negative scenes per seed. We report program executability (Exec.) and scene-level rule satisfaction (RuleSat); unexecutable programs receive zero RuleSat. Commercial models receive the full API specification as zero-shot references, whereas trained models use short instructions after supervised API learning. These results therefore do not constitute a strictly matched-prompt comparison.
5.1 Visual Rule Understanding
We report visual rule understanding results in Table 2. On UniLIP, Stage III raises familiar-rule MCQ accuracy from 64.08% to 85.01% and held-out MCQ accuracy from 37.58% to 66.00%. Stage II gives the strongest UniLIP explanation results, while the small Stage II-to-III changes show that execution-grounded refinement largely preserves rule understanding.
The gains transfer across architectures: the best familiar-rule MCQ accuracy reaches 81.67% for Show-o2, 87.29% for Qwen3-VL, and 80.00% for InternVL3.5. Explanation remains substantially
Table 2: Visual rule understanding results (%). MCQ, Exp., and Joint denote multiple-choice, explanation, and joint accuracy. Bold marks the best RuleForge-trained result.
| Model | Stage | Familiar Rules | Held-Out Rule Compositions | ||||
|---|---|---|---|---|---|---|---|
| MCQ | Exp. | Joint | MCQ | Exp. | Joint | ||
| Commercial zero-shot references | |||||||
| Gemini-2.5 Flash-Lite [9] | – | 30.95 | 10.37 | 3.61 | 37.63 | 0.74 | 0.23 |
| GPT-6-Sol | – | 68.81 | 21.32 | 16.18 | 84.09 | 5.31 | 4.63 |
| Backbones trained with RuleForge | |||||||
| InternVL3.5-2B [36] | Base | 33.31 | 3.81 | 1.61 | 35.00 | 0.97 | 0.76 |
| I | 77.19 | 17.83 | 13.57 | 64.34 | 3.54 | 2.06 | |
| II | 79.92 | 18.82 | 15.15 | 67.46 | 1.06 | 0.91 | |
| III | 80.00 | 19.98 | 16.08 | 67.14 | 1.57 | 1.03 | |
| Show-o2-1.5B [42] | Base | 25.00 | 2.97 | 0.81 | 25.03 | 6.69 | 1.66 |
| I | 75.63 | 12.66 | 9.91 | 41.29 | 1.14 | 0.57 | |
| II | 81.40 | 24.11 | 20.60 | 42.43 | 1.43 | 0.77 | |
| III | 81.67 | 22.61 | 19.13 | 42.31 | 1.43 | 0.86 | |
| UniLIP-3B [35] | Base | 64.08 | 4.78 | 2.90 | 37.58 | 0.23 | 0.15 |
| I | 82.10 | 11.48 | 9.34 | 69.46 | 2.69 | 2.06 | |
| II | 84.95 | 25.80 | 22.55 | 66.60 | 16.83 | 7.26 | |
| III | 85.01 | 24.63 | 21.75 | 66.00 | 16.46 | 7.00 | |
| Qwen3-VL-4B-Instruct [2] | Base | 42.32 | 17.62 | 7.15 | 62.51 | 0.69 | 0.57 |
| I | 84.88 | 31.56 | 28.68 | 57.57 | 1.03 | 0.49 | |
| II | 87.15 | 38.30 | 35.25 | 58.69 | 1.29 | 0.69 | |
| III | 87.29 | 38.31 | 35.36 | 58.71 | 1.71 | 0.80 | |
harder under held-out compositions. For example, GPT-6-Sol obtains 84.09% held-out MCQ accuracy but only 5.31% explanation accuracy, whereas Stage III UniLIP reaches 16.46% explanation accuracy. This gap shows that selecting a candidate rule does not imply independently recovering and verbalizing it.
5.2 Rule-Conditioned Executable Generation
In Table 3, we evaluate whether a target-rule description can be translated into an executable scene program. The Base and Stage I models rarely generate valid programs because they receive no Program SFT. Stage II establishes executable generation across all four backbones, reaching 54.64–67.81% familiar-rule RuleSat. Stage III further improves every backbone. For UniLIP, familiar-rule RuleSat increases from 60.42% to 70.99%, while held-out RuleSat rises from 23.33% to 38.40% and held-out Exec. from 33.33% to 54.17%.
GPT-6-Sol achieves 85.41% familiar-rule and 83.40% held-out RuleSat under the API-documented zero-shot setting, showing that a strong general-purpose model can effectively use extensive API documentation in context. Gemini-2.5 Flash-Lite reaches 30.37% and 20.76%, respectively, and is surpassed by every Stage III backbone. The consistent Stage II-to-III gains provide the principal evidence for execution-grounded refinement beyond supervised program likelihood. In Figure 4, we provide matched-seed examples in which Stage III corrects semantic rule violations that remain after supervised Program SFT.
5.3 Inference-Time Chaining through the Shared Rule-Language Interface
The preceding experiments evaluate understanding and generation under their standard interfaces. To examine their inference-time connection, we evaluate , where the model first predicts
Table 3: Rule-conditioned executable generation results (%). Exec. denotes program executability, and RuleSat denotes scene-level rule satisfaction over five seeds. Bold marks the best RuleForge-trained result.
| Model | Stage | Familiar Rules | Held-Out Rule Compositions | ||
|---|---|---|---|---|---|
| Exec. | RuleSat | Exec. | RuleSat | ||
| API-documented commercial zero-shot references | |||||
| Gemini-2.5 Flash-Lite [9] | – | 45.47 | 30.37 | 33.33 | 20.76 |
| GPT-6-Sol | – | 94.71 | 85.41 | 91.67 | 83.40 |
| Backbones trained with RuleForge | |||||
| Qwen3-VL-4B-Instruct [2] | Base | 4.04 | 2.69 | 0.00 | 0.00 |
| I | 4.93 | 3.36 | 0.00 | 0.00 | |
| II | 69.24 | 54.64 | 37.50 | 25.00 | |
| III | 80.81 | 61.15 | 50.00 | 34.51 | |
| InternVL3.5-2B [36] | Base | 2.24 | 1.46 | 0.00 | 0.00 |
| I | 3.14 | 2.02 | 0.00 | 0.00 | |
| II | 75.78 | 59.57 | 29.17 | 18.75 | |
| III | 90.13 | 67.50 | 41.67 | 25.21 | |
| UniLIP-3B [35] | Base | 4.93 | 2.91 | 0.00 | 0.00 |
| I | 4.93 | 2.69 | 0.00 | 0.00 | |
| II | 74.89 | 60.42 | 33.33 | 23.33 | |
| III | 87.44 | 70.99 | 54.17 | 38.40 | |
| Show-o2-1.5B [42] | Base | 3.59 | 2.02 | 0.00 | 0.00 |
| I | 4.04 | 2.47 | 0.00 | 0.00 | |
| II | 83.86 | 67.81 | 12.50 | 10.42 | |
| III | 92.38 | 71.42 | 41.67 | 22.99 | |
Table 4: Inference-time rule chaining (%). Ref. uses the reference rule; Pred. uses the model-predicted rule. Bold indicates the better stage under the same rule source.
| Stage | Source | Familiar | Held-Out | ||
|---|---|---|---|---|---|
| Exec. | RuleSat | Exec. | RuleSat | ||
| II | Ref. | 77.50 | 71.98 | 62.40 | 43.65 |
| III | Ref. | 88.70 | 79.37 | 79.20 | 50.09 |
| II | Pred. | 59.20 | 34.43 | 25.60 | 12.96 |
| III | Pred. | 69.50 | 38.69 | 42.60 | 21.20 |
a rule description from the contact sheet and then generates from . We use matched, rule-balanced subsets of 1,000 familiar-rule and 1,000 held-out-composition problems. For each Stage II and Stage III checkpoint, Reference supplies the ground-truth description, whereas Predicted uses the checkpoint's own free-form rule prediction. Both conditions use the same API and five-seed execution protocol. Sampling and bootstrap details are provided in Appendix B.
In Table 4, we observe a substantial reference-to-predicted gap: under Stage III, RuleSat decreases from 79.37% to 38.69% on familiar rules and from 50.09% to 21.20% on held-out compositions. Nevertheless, Stage III improves chained RuleSat over Stage II by 4.26 and 8.24 percentage points, with rule-cluster bootstrap 95% confidence intervals of [0.99, 7.44] and [4.47, 12.04], respectively; held-out Exec. also increases by 17.00 percentage points. These results demonstrate improvement in the complete inference chain while identifying explicit rule recovery as a major remaining bottleneck. Because each stage supplies both its own descriptions and

Figure 4: Matched-seed comparison between Stages II and III. Stage II produces executable but rule-violating positive scenes, whereas Stage III satisfies the target rules. Each displayed case uses one seed; RuleSat is computed over five fixed seeds.
Table 5: UniLIP-3B ablations (%). (a) Stage II task mixtures; (b) Stage III reward components.
| (a) Stage II task mixture | ||||
|---|---|---|---|---|
| Metric | U-only | G-only | 1:1 | 2:1 |
| Familiar MCQ | 70.80 | 61.50 | 72.90 | 84.95 |
| Held-out MCQ | 60.77 | 49.74 | 59.73 | 66.60 |
| Familiar Exp. | 24.80 | 5.40 | 25.90 | 25.80 |
| Held-out Exp. | 8.22 | 0.10 | 17.07 | 16.83 |
| Familiar RuleSat | 2.91 | 68.76 | 61.89 | 60.42 |
| Held-out RuleSat | 0.00 | 21.18 | 27.36 | 23.33 |
| (b) Stage III execution reward | |||
|---|---|---|---|
| Metric | w/o Worst | w/o Coverage | Full |
| Familiar RuleSat | 71.24 | 70.06 | 70.99 |
| Held-out RuleSat | 26.74 | 30.14 | 38.40 |
| Held-out Exec. | 45.83 | 46.67 | 54.17 |
| Held-out WorstRS | 25.69 | 29.17 | 36.46 |
| Held-out Coverage | 17.50 | 16.11 | 19.58 |
programs, the gains reflect their combined changes rather than an isolated improvement in robustness to description errors.
5.4 Ablation Studies
We report the complete stage-wise results in Tables 2 and 3, and visualize two representative trends in Appendix Figure 5. We conduct controlled UniLIP ablations of the Stage II task mixture, the Stage III execution reward, and Understanding Replay.
Stage-II task mixture. In Table 5(a), we compare understanding-only, generation-only, and two joint mixtures. Understanding-only training provides almost no executable generation, whereas generation-only training reaches 68.76% familiar RuleSat but substantially reduces understanding accuracy. The 2:1 mixture obtains the strongest familiar and held-out MCQ while remaining competitive on explanation and generation, motivating its use as the default.
Stage-III execution reward. In Table 5(b), we remove the worst-seed or conjunct coverage component. Removing the worst-seed term slightly improves familiar RuleSat but reduces held-out RuleSat from 38.40% to 26.74%. Removing coverage similarly weakens held-out RuleSat, executability, worst-seed satisfaction, and coverage. The full reward therefore primarily improves robustness under held-out compositions.
Understanding Replay. We ablate Understanding Replay by retraining Stage III from the same Stage II checkpoint without . As detailed in Appendix Table 7, removing replay increases held-out MCQ by 1.29 percentage points, but decreases explanation, joint, executability, and RuleSat by 3.37, 1.40, 8.34, and 8.05 points, respectively. These results support Understanding Replay as a cross-task regularizer that preserves explicit rule verbalization and executable generation, rather than as a uniform accuracy booster.
5.5 Qualitative Results
Figure 4 presents matched-seed comparisons between programs produced by Stages II and III. Although Stage II generally produces executable and visually valid scenes, it may still violate alignment, contact, attribute, counting, or conjunctive constraints. Stage III corrects these semantic violations while preserving variation in rule-irrelevant properties such as object identity, color, size, and position. The displayed familiar-rule cases improve from Stage II RuleSat values of 50.00–81.67% to 100.00%, while the held-out example jointly satisfies both constituents of an unseen composition. The examples also reveal that executability alone is insufficient: syntactically valid programs can still encode incomplete rule logic, whereas execution-grounded refinement improves semantic consistency across multiple realizations and random seeds. Because corresponding programs are rendered under the same seeds, these gains cannot be attributed solely to favorable random configurations. Instead, these cases show that execution feedback changes the underlying construction logic, complementing the aggregate results in Table 3 with concrete improvements in generated scene structure.
6 Conclusion
We presented Bongard-Forge100k, a controlled benchmark for visual rule understanding and rule-conditioned executable generation, together with RuleForge, a backbone-agnostic framework for jointly learning these two capabilities. Through progressive understanding training, joint scene-program supervision, and execution-grounded reinforcement learning with Understanding Replay, RuleForge improves both rule understanding and executable generation across UniLIP, InternVL3.5, Qwen-3-VL, and Show-o2. The Stage III UniLIP model surpasses the zero-shot GPT-6-Sol and Gemini-2.5 Flash-Lite references on all familiar-rule understanding metrics. It also surpasses both references on explanation and joint accuracy for held-out compositions, demonstrating the value of task-specific training for explicit rule recovery. Across the full training pipeline, familiar-rule RuleSat increases from 2.91% to 70.99%. More specifically, execution-grounded refinement improves RuleSat from 60.42% to 70.99% on familiar rules and from 23.33% to 38.40% on held-out compositions, supporting the effectiveness of multi-seed execution feedback. Together, Bongard-Forge100k and RuleForge provide a controlled foundation for learning and evaluating semantic and executable representations of visual rules, with potential extensions to rule-governed multimodal Web content such as interfaces, layouts, and infographics.
References
[1] Roman Bachmann, Oğuzhan F Kar, David Mizrahi, Ali Garjani, Mingfei Gao, David Griffiths, Jiaming Hu, Afshin Dehghan, and Amir Zamir. 2024. 4m-21: An any-to-any vision model for tens of tasks and modalities. Advances in Neural Information Processing Systems 37 (2024), 61872–61911.
[2] Shuai Bai, Yuxuan Cai, Ruizhe Chen, Keqin Chen, Xionghui Chen, Zesen Cheng, Lianghao Deng, Wei Ding, Chang Gao, Chunjiang Ge, et al. 2025. Qwen3-vl technical report. arXiv preprint arXiv:2511.21631 (2025).
[3] Mikhail Moiseevich Bongard. 1970. Pattern Recognition. Spartan Books, New York, NY, USA.
[4] Dongping Chen, Ruoxi Chen, Shilin Zhang, Yinuo Liu, Yaochen Wang, Huichi Zhou, Qihui Zhang, Yao Wan, Pan Zhou, and Lichao Sun. 2024. Mllm-as-a-judge: Assessing multimodal Ilm-as-a-judge with vision-language benchmark. arXiv preprint arXiv:2402.04788 (2024).
[5] Xinyun Chen, Maxwell Lin, Nathanael Schärli, and Denny Zhou. 2024. Teaching large language models to self-debug. In International Conference on Learning Representations, Vol. 2024. 8746–8825.
[6] Yue Dai, Soyeon Caren Han, and Wei Liu. 2025. Graph-Based multimodal contrastive learning for chart question answering. In Proceedings of the 48th International ACM SIGIR Conference on Research and Development in Information Retrieval. 2658–2663.
[7] Stefan Depewep, Contantin A Rothkopf, and Frank Jäkel. 2024. Solving bongard problems with a visual language and pragmatic constraints. Cognitive science 48, 5 (2024), e13432.
[8] Luyu Gao, Aman Madaan, Shuyuan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. 2023. Pal: Program-aided language models. In International conference on machine learning. PMLR, 10764–10799.
[9] Google. 2025. Gemini 2.5 Flash-Lite. https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash-lite. Accessed: 2026-10-23.
[10] Zhibin Gou, Zhihong Shao, Yeyun Gong, Yelong Shen, Yujiu Yang, Nan Duan, and Weizhu Chen. 2024. CRITIC: Large Language Models Can Self-Correct with Tool-Interactive Critiquing. In The Twelfth International Conference on Learning Representations. https://openreview.net/forum?id=Sx03q8qjek
[11] Tanmay Gupta and Aniruddha Kembhavi. 2023. Visual programming: Compositional visual reasoning without training. In 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 14953–14962.
[12] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2021. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685 (2021).
[13] Huaizu Jiang, Xiaojian Ma, Weili Nie, Zhiding Yu, Yuke Zhu, and Anima Anandkumar. 2022. Bongard-hoi: Benchmarking few-shot visual reasoning for human-object interactions. In 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 19034–19043.
[14] Nan Jiang, Xiaopeng Li, Shiqi Wang, Qiang Zhou, Soneya B Hossain, Baishakhi Ray, Varun Kumar, Xiaofei Ma, and Anoop Deoras. 2024. Lexed: Training LLMs to better self-debug and explain code. Advances in Neural Information Processing Systems 37 (2024), 35517–35543.
[15] Yifan Jiang, Jiarui Zhang, Kexuan Sun, Zhivar Sourati, Kian Ahrabian, Kaixin Ma, Filip Ilievski, and Jay Pujara. 2024. Marvel: Multidimensional abstraction and reasoning through visual evaluation and learning. Advances in Neural Information Processing Systems 37 (2024), 46567–46592.
[16] Justin Johnson, Bharath Hariharan, Laurens Van Der Maaten, Li Fei-Fei, C Lawrence Zitnick, and Ross Girshick. 2017. Clevr: A diagnostic dataset for compositional language and elementary visual reasoning. In Proceedings of the IEEE conference on computer vision and pattern recognition. 2901–2910.
[17] Christina Kanetou and Yannis Tzitzikas. 2026. Img2KG: Ontology-Driven Correction of Visual Triples. In Proceedings of the ACM Web Conference 2026. 8429–8432.
[18] Cassidy Langenfeld, Claas Beger, Gloria Geng, Wasu Top Piriyakulkij, Keya Hu, Yewen Pu, and Kevin Ellis. 2026. Bongards at the Boundary of Perception and Reasoning: Programs or Language? arXiv preprint arXiv:2602.03038 (2026).
[19] Hung Le, Yue Wang, Akhilesh Deepak Gotmare, Silvio Savarese, and Steven Chu Hong Hoi. 2022. Coder1: Mastering code generation through pretrained models and deep reinforcement learning. Advances in Neural Information Processing Systems 35 (2022), 21314–21328.
[20] Jia-Nan Li, Jian Guan, Wei Wu, Zhengtao Yu, and Rui Yan. 2025. 2d-tpe: Two-dimensional positional encoding enhances table understanding for large language models. In Proceedings of the ACM on Web Conference 2025. 2450–2463.
[21] Xinwei Li, Li Lin, Shuai Wang, and Hanqian Wu. 2025. Seeing beyond hallucinations: Llm-based compositional information extraction for multimodal reasoning. In Proceedings of the 48th International ACM SIGIR Conference on Research and Development in Information Retrieval. 1000–1010.
[22] Hongzhan Lin, Ziyang Luo, Wei Gao, Jing Ma, Bo Wang, and Ruichao Yang. 2024. Towards explainable harmful meme detection through multimodal debate between large language models. In Proceedings of the acm web conference 2024. 2359–2370.
[23] Jiawei Lin, Jiaqi Guo, Shizhao Sun, Zijiang Yang, Jian-Guang Lou, and Dongmei Zhang. 2023. Layoutprompter: Awaken the design ability of large language models. Advances in Neural Information Processing Systems 36 (2023), 43852–43879.
[24] Xuanrui Lin, Chao Jia, Junhui Ji, Hui Han, and Usman Naseem. 2025. Ask, acquire, understand: A multimodal agent-based framework for social abuse detection in memes. In Proceedings of the ACM on Web Conference 2025. 4734–4744.
[25] Mikolaj Makinski, Szymon Pawlonka, and Jacek Mańdzuk. 2024. Reasoning limitations of multimodal large language models. a case study of bongard problems. arXiv preprint arXiv:2411.01173 (2024).
[26] Ahmed Masry, Jia Qing Tan, Shafiq Joty, Enamul Hoque, et al. 2022. Chartqa: A benchmark for question answering about charts with visual and logical reasoning. In Findings of the association for computational linguistics: ACL 2022. 2263–2279.
[27] Minesh Mathew, Viraj Bagal, Ruben Tito, Dimosthenis Karatzas, Ernest Valveny, and CV Jawahar. 2025. Infographiccvq. In 2022 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV). IEEE, 2582–2591.
[28] Weili Nie, Zhiding Yu, Lei Mao, Ankit B Patel, Yuke Zhu, and Anima Anandkumar. 2020. Bongard-logo: A new benchmark for human-level concept learning and reasoning. Advances in neural information processing systems 33 (2020), 16468–16480.
[29] OpenAI. 2026. Introducing GPT-6 Sol and GPT-6 Luna. https://openai.com/index/introducing-gpt-6-sol-and-luna/. Accessed: 2026-10-23.
[30] Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. 2022. Training language models to follow instructions with human feedback. Advances in neural information processing systems 35 (2022), 27730–27744.
[31] Qwen Team. 2026. Qwen3.5: Towards Native Multimodal Agents. https://qwen.ai/blog?id=qwen3.5
[32] John Schulman, Filip Wolski, Prafulla Dhariwal, Alex Radford, and Oleg Klimov. 2017. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347 (2017).
[33] Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchuan Zhang, YK Li, Yang Wu, et al. 2024. Deepseekmath: Pushing the limits of mathematical reasoning in open language models. arXiv preprint arXiv:2402.03300 (2024).
[34] Didac Suris, Sachit Menon, and Carl Vondrick. 2023. Vipergpt: Visual inference via python execution for reasoning. In 2023 IEEE/CVF International Conference on Computer Vision (ICCV). IEEE, 11854–11864.
[35] Hao Tang, Chen-Wei Xie, Xiaoyi Bao, Tingyu Weng, Pandeng Li, Yun Zheng, and Liwei Wang. 2026. Unilip: Adapting clip for unified multimodal understanding, generation and editing. In International Conference on Learning Representations, Vol. 2026. 60440–60465.
[36] Weiyun Wang, Zhangwei Gao, Lixin Gu, Hengjun Pu, Long Cui, Xingguang Wei, Zhaoyang Liu, Linglin Jing, Shenglong Ye, Jie Shao, et al. 2025. InternVL3.5: Advancing Open-Source Multimodal Models in Versatility, Reasoning, and Efficiency. arXiv preprint arXiv:2508.18265 (2025).
[37] Yaxian Wang, Bifan Wei, Jun Liu, Lingling Zhang, Shuteng He, Jun Li, and Qika Lin. 2025. GIfoMR: a glance-then-focus multimodal reasoning framework for diagram question answering. In Proceedings of the 48th International ACM SIGIR Conference on Research and Development in Information Retrieval. 1130–1140.
[38] Chengyue Wu, Xiaokang Chen, Zhiyu Wu, Yiyang Ma, Xingchao Liu, Zizheng Pan, Wen Liu, Zhenda Xie, Xingkai Yu, Chong Ruan, et al. 2025. Janus: Decoupling visual encoding for unified multimodal understanding and generation. In 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 12966–12977.
[39] Rujie Wu, Xiaojian Ma, Zhenliang Zhang, Wei Wang, Qing Li, Song-Chun Zhu, and Yizhou Wang. 2024. Bongard-openworld: Few-shot reasoning for free-form visual concepts in the real world. In International Conference on Learning Representations, Vol. 2024. 20688–20718.
[40] Antonia Wüst, Tim Woydt, Lukas Helff, Inga Ibs, Wolfgang Stammer, Devendra S Dhami, Constantin A Rothkopf, and Kristian Kersting. 2024. Bongard in Wonderland: Visual Puzzles that Still Make AI Go Mad? arXiv preprint arXiv:2410.19546 (2024).
[41] Jiahao Xie and Guangmo Tong. 2026. VSAL: A Vision Solver with Adaptive Layouts for Graph Property Detection. In Proceedings of the ACM Web Conference 2026. 798–809.
[42] Jinheng Xie, Zhenheng Yang, and Mike Zheng Shou. 2025. Show-o2: Improved Native Unified Multimodal Models. In Advances in Neural Information Processing Systems, Vol. 38. Curran Associates, Inc., 47490–47518. doi:10.52202/085713-1584
[43] Tianyi Xiong, Xiyao Wang, Dong Guo, Qinghao Ye, Haoqi Fan, Quanquan Gu, Heng Huang, and Chunyuan Li. 2025. LLLaVA-critic: Learning to evaluate multimodal models. In 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 13618–13628.
[44] Yi-Kai Zhang, Shiyin Lu, Yang Li, Yanqing Ma, Qing-Guo Chen, Zhao Xu, Weihua Luo, Kaifu Zhang, De-Chuan Zhan, and Han-Jia Ye. 2024. Wings: Learning multimodal llms without text-only forgetting. Advances in Neural Information Processing Systems 37 (2024), 31828–31853.
RuleForge: Inferring and Instantiating Latent Visual Rules as Executable Programs
SUPPLEMENTARY MATERIAL
A Implementation and Evaluation Details
A.1 Parameter-Efficient Adaptation
For all four backbones, the image encoder and base language-model weights remain frozen throughout training. We insert LoRA adapters into the language model's query, key, value, and output projections, as well as its gate, up, and down projections. Unless otherwise specified, LoRA uses rank 32, scaling factor 64, and dropout 0.05. Stage I additionally updates the multimodal projector; the projector is frozen in Stages II and III.
Training uses BF16 precision without weight quantization. We optimize with AdamW, weight decay 0.01, a warmup ratio of 0.03, and gradient clipping at 1.0. All reported trainable models use model-training seed 42 and are trained once on a single NVIDIA GeForce RTX 4090 GPU. We summarize the stage-specific configuration in Table 6.
A.2 Stage-Specific Training Details
Stage I. The understanding sampler draws from multiple-choice prediction, free-form explanation, candidate verification, and structured scene-fact prediction with probabilities 0.60, 0.25, 0.10, and 0.05, respectively. Each epoch contains 156,000 sampled records, and the model is trained for two epochs. The full training pool contains 172,000 understanding records. The sampler traverses shuffled cycles while maintaining the prescribed task mixture and rule-balanced sampling.
Stage II. Stage II alternates two Understanding-SFT batches with one Program-SFT batch. Both batch types contain eight records, and four logical batches are accumulated before an optimizer update. Understanding responses are capped at 1,024 tokens in the training sequence, while scene programs use a maximum sequence length of 1,536 tokens. Stage II is trained for one epoch from the Stage I checkpoint. The multimodal projector remains frozen.
Stage III. For every target-rule prompt, the policy samples six candidate programs with temperature 0.8, top-, a maximum prompt length of 1,024 tokens, and at most 768 newly generated tokens. Candidates in the same group are executed under the same three random seeds. The GRPO clipping threshold is 0.2, and one policy epoch is applied per rollout group. We set the worst-seed aggregation weight to 0.25, the conjunct-coverage penalty coefficient to 0.25, , and . Each update includes eight understanding records drawn from the Stage I task mixture. LoRA dropout is disabled during on-policy rollout and optimization.
Unsafe programs, syntax failures, and runtime failures receive rewards of , , and , respectively. Program execution occurs in a restricted environment with a fixed API, resource limits, and failure handling. Candidates that produce no valid execution do not receive a positive policy reward.
A.3 Input Processing, Decoding, and Runtime
The complete Bongard contact sheet is resized using each backbone's native image processor without cropping away boundary panels. UniLIP, InternVL3.5, and Qwen3-VL use a input,
while Show-o2 uses . Architecture-specific visual token layouts and positional encodings are otherwise preserved.
Understanding evaluation uses deterministic decoding with maximum output lengths of 32 new tokens for multiple-choice prediction and 192 new tokens for rule explanation. Program evaluation allows up to 1,536 new tokens. Every generated evaluation program is executed under the same five fixed seeds:
Each seed produces six positive and six negative scenes, yielding 60 structured scenes per evaluated program.
For an executable program, per-seed RuleSat is the fraction of its six positive scenes accepted by the target-rule checker plus the fraction of its six negative scenes rejected by the checker, averaged over all 12 scenes. The final score averages over the five seeds and evaluation prompts. Unexecutable programs receive RuleSat zero and remain in the denominator.
The primary UniLIP training pipeline requires approximately 39 wall-clock hours on one RTX 4090. Runtime varies across backbones because their visual tokenizers, attention implementations, and generation speeds differ. Training-seed 42 controls model initialization and data sampling; it is distinct from the three execution seeds used for Stage III feedback and the five fixed seeds used for final generation evaluation.
B Inference-Time Chaining Details
The chaining experiment connects the two RuleForge interfaces without introducing additional training. Given a Bongard contact sheet , the checkpoint first produces a free-form rule description . The same checkpoint then receives together with the scene-construction API and generates a program :
The Reference condition replaces with the ground-truth target-rule description while keeping the generation prompt, API specification, decoding configuration, and execution seeds unchanged. The Predicted condition uses the checkpoint's own rule description without manual correction. Missing or invalid outputs remain failures rather than being removed.
We construct fixed, rule-balanced subsets of 1,000 familiar-rule and 1,000 held-out-composition problems. Sampling quotas are distributed as evenly as possible across rule identifiers, followed by deterministic within-rule sampling. The same problem identifiers are used for Stages II and III and for the Reference and Predicted conditions. Consequently, differences between stages are paired over the same visual inputs and execution seeds.
Every generated program is evaluated under the five fixed seeds used in the main generation experiment. The reported Exec. and RuleSat metrics use the same failure and averaging rules as Table 3. The chaining results therefore measure the complete inference path rather than a separately trained image-to-code model.
Because multiple problems share the same underlying rule, individual problems are not treated as statistically independent. We
Table 6: Training configuration used for the three RuleForge stages. Logical batch sizes are measured before gradient accumulation. Stage III samples one group of six candidate programs per policy update.
| Stage | Initialization and trainable components | Training budget | Learning rate | Batching | Sampling configuration |
|---|---|---|---|---|---|
| I | Base model; LM LoRA and multimodal projector | 2 epochs; 6,500 updates | LoRA; projector | Logical batch 8; accumulation 6; effective batch 48 | MCQ/Exp./Verify/Fact = 0.60/0.25/0.10/0.05 |
| II | Stage I checkpoint; LM LoRA only | 1 epoch; 7,313 updates | Understanding and program batches 8; accumulation 4 | Understanding:Program = 2:1 | |
| III | Stage II checkpoint; LM LoRA only | 1,000 policy updates | Six candidates per group; replay batch 8 | Three shared execution seeds; understanding replay at every update |
Table 7: Understanding Replay ablation on UniLIP-3B (%). The ablated Stage III model removes . Bold indicates the better result in each column.
(a) Visual Rule Understanding
| Configuration | Familiar | Held-Out | ||||
|---|---|---|---|---|---|---|
| MCQ | Exp. | Joint | MCQ | Exp. | Joint | |
| Full III | 85.01 | 24.63 | 21.75 | 66.00 | 16.46 | 7.00 |
| III w/o Replay | 84.91 | 25.30 | 22.35 | 67.29 | 13.09 | 5.60 |
(b) Rule-Conditioned Executable Generation
| Configuration | Familiar | Held-Out | ||
|---|---|---|---|---|
| Exec. | RuleSat | Exec. | RuleSat | |
| Full III | 87.44 | 70.99 | 54.17 | 38.40 |
| III w/o Replay | 83.95 | 65.97 | 45.83 | 30.35 |
form confidence intervals by resampling rule clusters with replacement, including all selected problems associated with each sampled cluster, and recomputing the paired Stage III-minus-Stage II difference. The reported 95% intervals are the 2.5th and 97.5th percentiles of the resulting cluster-bootstrap distribution. This procedure gives intervals of [0.99, 7.44] and [4.47, 12.04] percentage points for the familiar-rule and held-out RuleSat gains, respectively.
C Additional Stage-Wise and Ablation Results
C.1 Stage-Wise Trends
In Figure 5, we summarize how rule understanding and executable generation emerge across the three training stages. Stage I produces the main improvement in familiar-rule selection: MCQ accuracy rises from 64.08% to 82.10% for UniLIP, from 33.31% to 77.19% for InternVL3.5, from 42.32% to 84.88% for Qwen3-VL, and from 25.00% to 75.63% for Show-o2. These gains occur before program supervision, confirming that they arise from the understanding-focused instruction mixture rather than executable generation training.
Familiar-rule MCQ accuracy remains comparatively stable or improves further during Stages II and III. This behavior indicates that adding Program SFT and execution-grounded optimization does not erase the rule-selection ability acquired in Stage I. The smaller changes after Stage I also suggest that later training primarily changes how the model operationalizes a rule rather than

(a) Familiar-rule MCQ
(b) Held-Out RuleSat
Figure 5: Stage-wise performance. (a) Familiar-rule MCQ accuracy and (b) held-out RuleSat for the base model and Stages I–III. Stage III annotations show percentage-point gains over the corresponding base models.
whether it can select the corresponding description from a candidate set.
The generation trajectory is qualitatively different. Held-out RuleSat remains zero or near zero for the base and Stage I models because neither checkpoint has received scene-program supervision. Stage II establishes the executable-generation interface, reaching held-out RuleSat values of 23.33% for UniLIP, 25.00% for Qwen3-VL, 18.75% for InternVL3.5, and 10.42% for Show-o2. Stage III raises these scores to 38.40%, 34.51%, 25.21%, and 22.99%, respectively.
The consistent Stage II-to-III gains are particularly relevant because the exact held-out rule compositions do not occur in training. Execution feedback therefore improves more than the syntactic production of programs: it encourages programs whose behavior remains consistent with the target rule under multiple scene realizations. Together, the two panels show the intended division of labor across the curriculum: Stage I establishes visual rule understanding, Stage II introduces executable synthesis, and Stage III improves cross-seed rule satisfaction.
C.2 Complete Understanding Replay Ablation
We report the complete Understanding Replay ablation in Table 7. Replay is not a uniform accuracy booster. Removing it changes all familiar-rule understanding metrics by at most 0.67 percentage points and slightly improves familiar explanation and joint accuracy. On held-out compositions, however, explanation and joint accuracy decrease by 3.37 and 1.40 percentage points, despite a 1.29-percentage-point increase in MCQ accuracy.
This difference between multiple-choice selection and free-form explanation is informative. Candidate options provide explicit rule descriptions that can support recognition even when the model's ability to independently recover and verbalize the complete rule
has drifted. Explanation accuracy instead requires the model to express all relevant predicates and their bindings without access to candidate descriptions. Understanding Replay therefore has its clearest semantic effect on the more demanding free-form interface.
The effect is more consistent for executable generation. Removing replay reduces familiar Exec. and RuleSat by 3.49 and 5.02 points, respectively, and reduces held-out Exec. and RuleSat by 8.34 and 8.05 points. The larger held-out decreases indicate that replay is especially useful when program generation must preserve rule information under an unseen composition rather than reproduce a familiar rule interface.
These results support Understanding Replay as a cross-task regularizer. It does not maximize every individual understanding metric, but it limits semantic drift during policy optimization and preserves information that remains useful for rule-conditioned program generation. The replay objective therefore complements the KL reference: the latter constrains the policy relative to Stage II on program tokens, whereas replay continues to expose the model to the visual understanding tasks learned in Stage I.