TL;DR
When a Vision–Language Model (VLM) writes a bounding box like [x1, y1, x2, y2] as plain text, it isn't reading off a mental blueprint it built before speaking. Instead, it enters decoding with only a rough draft and looks up each coordinate on the fly during the exact decoding steps that write its digits—using attention keys to find the visual edge and values to read its position directly from the vision encoder.
What Problem Does This Paper Address?
VLMs can localize objects—say, "second elephant from the left"—by simply predicting coordinate numbers one token after another. But how do they actually know what numbers to write?
Two assumptions have dominated the field:
- When: The model determines the entire bounding box before it starts writing, and decoding is just printing out that pre-computed answer.
- Where: The model reconstructs a spatial grid of the image inside the language model using its own sequence position IDs, and reads coordinates off that internal layout.
Prior studies supported these ideas by observing attention before decoding or by disrupting signals across the entire forward pass. Those setups can't tell whether an edge is locked in before writing or fetched mid-sentence, nor which position signal the model actually uses.
Methods
To separate these hypotheses, the authors designed surgical, window-confined interventions across 15 VLMs from four families (Qwen3-VL, InternVL3.5, Gemma-4, and Kimi-VL, spanning 2B to 38B parameters).
Instead of altering the whole forward pass, they swapped out only the visual keys and values in the model's attention mechanism solely during the decoding steps of a single coordinate (e.g., while writing x2), leaving everything before and after untouched:
- Testing when: They resampled a strip of pixels to move an object's edge by 15% of its size, showing the edited image only during that coordinate's decoding steps, or only before them (restoring the original image while the coordinate is written).
- Testing where: Keeping pixels completely fixed, they shifted either the vision encoder's positional encoding (which marks where each image patch lies) or the language model's position IDs (which order tokens in the text sequence).
- Testing how: They swapped only the keys or only the values from the moved-edge image to see which part of attention locates the edge and which part supplies the number.
Datasets
- RefCOCO (21,586 referring expressions across
val,testA, andtestB) served as the primary evaluation benchmark. - RefCOCOg, RefCOCO+, and GUI screenshots were used as replications.
- Ref-L4 (reviewed RefCOCO test annotations) was used to evaluate how well decoding-step attention flags failed boxes at test time.
Key Insights and Ideas
- Coordinates are read as they are written: Across all 15 models, a written coordinate follows a median 93% of an edge move shown only during its own decoding steps, and just 1% of a move shown before writing and restored during it. Before writing, the model holds only a coarse "draft" (which can be exposed by hiding the image during decoding), but the live visual lookup overrides it.
- The vision encoder supplies the ruler, not the language model: With pixels fixed, shifting the vision encoder's positional encoding moves the written coordinate as predicted (median slope 0.93). Shifting the language model's position IDs leaves it virtually unchanged (all slopes within ±0.04). Even though spatial layout can be decoded from the language model, the model doesn't actually use it to write coordinates.
- Keys search; values report: Swapping only keys from a moved-edge image pulls attention toward the new edge, while swapping only values leaves attention in place yet still shifts the coordinate. In short, keys find the edge token by its visual features, and values return its position (along with fine, sub-token pixel details).
- You can catch bad boxes without ground truth: Because attention decides the number, many bad edges happen simply because attention landed on the wrong visual token. Comparing where attention lands against the coordinate the model actually wrote creates a training-free "suspicion score" that flags failed boxes at test time.
Key Results
- Pre-decoding attention misses edges: Boxes extracted from attention before decoding find the right object in 91–99% of cases, but miss its edges by 8–17× the error of the written box.
- Redirecting attention fixes wrong-token edges: Shifting decoding-step attention weights toward the true edge token brings misplaced edges back to the correct token in 8 of 9 core models (by 14–56 percentage points).
- Flagging failures: The attention-based suspicion score outperforms digit confidence at flagging failed boxes (
IoU < 0.5) by +0.09 to +0.12 AUROC on Ref-L4-reviewed RefCOCO samples. - Selective re-encoding: Re-encoding only the 30% most suspicious boxes on a finer visual grid recovers 42–50% of the full
[email protected]gain (compared to 29–31% for a random 30% selection).
Limitations and Future Work
- Refinement limits: Roughly half of the boxes that miss
IoU ≥ 0.9already have every edge in the correct visual token; these "failed refinements" often happen on thin objects where the attended pixels show the edge poorly, which attention redirection alone cannot fix. - Test-time steering: Redirecting attention requires knowing where the true edge is. Without ground truth at test time, simply supervising or steering attention doesn't improve boxes—making selective re-encoding of suspicious boxes the more practical path forward.
Summary updated