Executable Perception Records for Grounded, Short Multimodal Reasoning

Vision-language models, which are language models with an image encoder attached, tend to lean on what their language training makes plausible rather than on what is in the picture. This gets worse the longer they "think": as a written chain of reasoning grows, the model's attention moves away from the image and toward its own text, and hallucinations increase (More Thinking, Less Seeing?). The usual fixes pull against each other. Asking the model to first describe what it sees and then reason, as MoCA does (Bad Seeing or Bad Thinking?), improves grounding but adds many tokens. Shortening reasoning cuts cost, but nothing in that approach makes the model look at the image again.

We propose that the model write down what it sees as a short instance of a typed Python object: a scene record with objects, counts, boxes, attributes, relations and read text, declared as dataclasses whose docstrings carry annotation guidelines. It then answers by writing a small program over that record, and an ordinary interpreter runs the program. The interpreter has no access to the image. If it reaches the correct answer from the record alone, the perception was sufficient, and we can give that credit to the perception tokens during reinforcement learning without the 14-billion-parameter "blindfolded" judge model MoCA uses. A second deterministic check, re-running the program after deleting or editing the cited record entries, detects programs that hard-code the answer instead of reading the record. The bet is that one mechanism (a compact, checkable perception record followed by execution instead of long prose) improves grounding and reduces generated tokens together.

Core Claim

The text a vision-language model conditions on when it answers drives both its latency and its drift away from the image. Replacing a free-form description and a long chain of thought with a typed record plus a short executed program should shrink that text and make the perception step verifiable by machine. We claim three things. First, at matched generated-token budgets, a model trained this way hallucinates less on POPE, CHAIR and RH-Bench than models trained to describe and reason in natural language. Second, it does so with one forward pass per token, unlike contrastive decoding. Third, the interpreter-based credit signal matches or exceeds the gains MoCA attributes to its language-model perception verifier, at a small fraction of the cost.

The novelty is not "use code for vision." CoReTab already couples reasoning with executable Python for image-embedded tables. That work verifies whole trajectories against ground truth, is restricted to tables, and its authors report that the added text (annotations averaging 529 tokens) is a major latency cost. What is new here is using execution as a perception-sufficiency test for open-world images, and pairing it with a counterfactual-edit check so that test cannot be gamed.

How the pieces fit, and what each prior line contributes

The code-schema literature supplies the representation. CodeIE and Code4Struct show that casting extraction as filling in Python classes cuts format errors. GoLLIE shows that annotation guidelines placed in docstrings make models follow definitions rather than surface labels, reaching 58.4 average zero-shot F1 at 7B against 42.6 for Instruct-UIE 11B. FACT shows, for text only, that mapping facts into class instances checked by an interpreter reduces input-conflicting and context-conflicting hallucinations by 2.7% to 8.0%. None of these works sees an image. We reuse their schema-as-code and docstring-guideline design for visual scenes. GoLLIE's warning that long schema definitions consume context also constrains us: our scene schema must stay small and fixed. It is placed in the prompt, which is prefilled once and cacheable, and is not regenerated per query.

The modality-bias literature supplies the motivation and the yardsticks. The finding that long reasoning causes attention drift (Xu et al.), together with MoCA's seesaw between perception and reasoning, motivates a short, verifiable perception stage. MoCA's authors themselves name its free-text recognition block a "textual bottleneck" for relational and spatial content, and that is exactly what typed relation and box fields target. MIRAGE is a supporting constraint. Manually correcting reasoning chains recovers the right answer about 70% of the time, so perception is often fine and reasoning is what breaks. Executing a program instead of verbalizing deductions addresses that half directly. Decoding-time fixes such as RBD and RVD work but need extra forward passes. Steering methods such as MoReS are cheap but do not touch multi-step reasoning. These are baselines, not components.

The latency literature supplies the training recipe and a framing. Afzal et al. report that hidden states often already encode whether reasoning will succeed before any explanation is written, which suggests much verbalized reasoning is external scratch space. We swap that scratch space for a structured one rather than compressing it into vectors as CoLaR does, because latent vectors cannot be audited and our record can. Sonata decides at prefill whether to think and cannot stop mid-stream. Execution offers a natural mid-stream decision: if the program runs and type-checks, the model stops; if it raises an exception, the model falls back to free-form reasoning.

Research Program

The base model is Qwen2.5-VL-7B, which CoReTab and AutoTool both build on.

We first write a single general scene schema. It contains an Obj class with name, count, box, colour, material and state fields, a Rel class for subject–predicate–object triples, a TextSpan class for read text with location, and a Scene container. Docstrings state guidelines, for example "list an object only if it is visible; do not infer occluded items." We keep the schema under a fixed token cap and measure that cap.

A short supervised stage teaches the output format: a Scene(...) literal, then def solve(s: Scene) -> Answer. It uses training splits of public question-answering sets with verifiable answers, such as VQAv2 and GQA. Records are bootstrapped from region annotations where they exist and filtered by execution correctness.

Training then continues with group-relative policy optimization (reinforcement learning that scores each sample against others drawn for the same prompt). The reward has three parts:

  1. An answer reward for the final output.
  2. A perception reward routed only to record tokens. It is granted when the interpreter, running solve on the record, returns the correct answer and the counterfactual check passes. The check passes if deleting or perturbing the record entries that solve reads changes the output.
  3. A validity term for parsing and type-checking.

Credit routing follows MoCA in protecting perception tokens when reasoning fails. The verifier is the interpreter rather than a second language model.

The analysis has two parts. We measure attention mass on visual tokens at answer time as a function of the length of text between the image and the answer, using the attention-drift measurement of Xu et al. We also check whether the code format moves the trade-off curve or merely moves models along it.

Baselines

The naive reference is Qwen2.5-VL-7B answering directly, and also with free chain-of-thought, with no further training. It anchors both hallucination and token counts.

The strongest competitor on our exact question is MoCA, which separates <recognition> and <think> blocks and rewards perception through a blindfolded Qwen2.5-14B. It is the closest method in spirit and the one whose limitation (free-text perception, an expensive verifier) we claim to fix. Its reported reference point is V = 86.6 for VL-Scaler-7B (Wang et al.), where removing perception verification costs nearly 7 points. We re-run MoCA from the same base model, on the same training questions, with the same number of policy-optimization steps and rollouts. We report verifier compute separately. Beating it means equal or better V, POPE and RH-AUC with fewer generated tokens and no verifier model. Matching it at a much lower verifier cost is a partial win, and we would report it as such.

For pure hallucination, the strongest numbers in the file are POPE accuracy of 88.0% for LLaVA-1.5-7B with RBD (Liang et al.) and 88.2 for MoReS (Bi et al.), plus RBD lowering CHAIR_S from 20.8% to 17.8%. Those results are on LLaVA-1.5, so we re-apply RBD and MoReS to our Qwen2.5-VL-7B base for a like-for-like comparison. We report forward passes and wall-clock per query alongside accuracy.

For reasoning grounding, the reference is Ocean-R1-7B's RH-AUC of 0.63 on RH-Bench (Xu et al.). For decoupled reasoning hallucination, it is Logos-7B at 37.1% on MIRAGE (MIRAGE).

Two ablations isolate the key ingredient. The first keeps the identical record content and identical execution but serializes the record as JSON parsed into Python, and as natural-language sentences given to a language-model verifier. This separates "typed code format" from "structured, executed perception." The second removes the counterfactual-edit check, to measure how much reward hacking it prevents.

Why not just…?

Why not just use JSON instead of Python classes? This is a real threat, and the design absorbs it. Execution and counterfactual checking work equally well on a parsed JSON record, so the core mechanism does not depend on Python syntax. What code adds is docstring guidelines and type hints that the model already knows from pretraining. GoLLIE's gains suggest these matter, for example MultiNERD "Media" F1 rising from 13.6 to 69.1 with guidelines in code. The JSON ablation settles the question. If JSON matches the dataclass record, we will report the contribution as executable perception verification, format-agnostic, and drop the code-format claim.

Why not just add a length penalty to ordinary reasoning? ConciseRL and DLER shorten text-only reasoning sharply, and if drift is purely a length effect, shorter free text might suffice. Xu et al. find that training recipes producing long imitative chains hurt grounding, but nobody has tested length-matched free text. We therefore train a conciseness-penalized free-reasoning model to the same mean token count as our method. If it matches us on POPE and RH-Bench, the gain is length and not structure, which would be a clean negative result.

Why not just use contrastive decoding? RBD and RVD need no training and work on POPE and multi-turn snowballing. They need an additional forward pass with a degraded or vision-only input at each step, and they adjust next-token scores without checking any multi-step deduction, which is the failure MIRAGE isolates. We compare at matched wall-clock time. Contrastive decoding remains a valid choice wherever retraining is impossible.

Why not just steer visual representations with a tiny adapter? MoReS reaches 88.2 on POPE with about 0.16M parameters, and on single-step existence questions it may well tie us. Our claim is restricted to multi-step and relational questions (RH-Bench reasoning half, MIRAGE, V*). There we expect steering alone to leave reasoning errors intact. We also test MoReS combined with our method to see whether the two gains add.

Proposed Experiments

Evaluation covers four kinds of benchmark. Hallucination is measured on POPE in its random, popular and adversarial splits, where the "yes" rate is reported because POPE documents near-99% yes-rates in some settings, and on CHAIR. Grounding under reasoning is measured on RH-Bench with RH-AUC across token budgets. Decoupled reasoning hallucination is measured on MIRAGE. Fine-grained perception is measured on V*. MMHalSnowball serves as a stress test, with the record carried across turns in place of dialogue history to see whether a re-checked record resists snowballing. Every result reports generated tokens, forward passes per query and wall-clock time.

The decisive checks are three.

  1. Length-matched comparison. At equal mean generated tokens, the scene-record model must beat the conciseness-penalized free-text model on RH-AUC and POPE adversarial. Otherwise the structure claim fails.
  2. Verifier substitution. Replacing MoCA's language-model verifier with our interpreter-plus-counterfactual check must recover most of MoCA's roughly 7-point V* benefit from perception verification. Otherwise execution is too weak a signal for open-world perception.
  3. Attention measurement. Visual attention mass at answer time should stay flat as task difficulty grows for our model, while it falls for free-reasoning models, the way Xu et al. describe. If it falls equally, any gains come from execution correcting deductions rather than from better seeing, and we would say so.

We also report the rate at which solve hard-codes answers with and without the counterfactual check, and the fraction of queries that fall back to free reasoning, which shows how often the schema fails to cover a scene.

References

  1. More Thinking, Less Seeing? Assessing Amplified Hallucination in Multimodal Reasoning Models
  2. Bad Seeing or Bad Thinking? Rewarding Perception for Multimodal Reasoning
  3. CoReTab: Improving Multimodal Table Understanding with Code-driven Reasoning
  4. CodeIE: Large Code Generation Models are Better Few-Shot Information Extractors
  5. Code4Struct: Code Generation for Few-Shot Event Structure Prediction
  6. GoLLIE: Annotation Guidelines improve Zero-Shot Information-Extraction
  7. FACT: Mitigating Inconsistent Hallucinations in LLMs via Fact-Driven Alternating Code-Text Training
  8. MIRAGE: Assessing Hallucination in Multimodal Reasoning Chains of MLLM
  9. Mitigating Hallucination in Visual-Language Models via Re-balancing Contrastive Decoding
  10. Investigating and Mitigating the Multimodal Hallucination Snowballing in Large Vision-Language Models
  11. LLaVA Steering: Visual Instruction Tuning with 500x Fewer Parameters through Modality Linear Representation-Steering
  12. Knowing Before Saying: LLM Representations Encode Information About Chain-of-Thought Success Before Completion
  13. Think Silently, Think Fast: Dynamic Latent Compression of LLM Reasoning Chains
  14. Adaptive Thinking: Large Language Models Know When to Think in Latent Space
  15. Are Tools Always Beneficial? Learning to Invoke Tools Adaptively for Dual-Mode Multimodal LLM Reasoning
  16. ConciseRL: Conciseness-Guided Reinforcement Learning for Efficient Reasoning Models
  17. DLER: Doing Length pEnalty Right — Incentivizing More Intelligence per Token via Reinforcement Learning
  18. Evaluating Object Hallucination in Large Vision-Language Models