Segment Where You Look

Attention as the Interface Between Language Models and Segmenters

Three interfaces between a VLM and a segmenter: (a) the mask as text, (b) a [SEG] embedding prompting SAM, (c) the [SEG] attention map prompting SAM.
Three ways a vision-language model can hand a segmenter its spatial intent. (a) The mask is serialized into the token stream. (b) The dominant design: one d-dimensional [SEG] embedding, with no spatial index, prompts SAM. (c) AttnSeg: the [SEG] token's attention is already a distribution on the patch grid, so we forward it to the decoder instead of the embedding.

Abstract

Vision-language models (VLMs) that segment from language must pass the location of the referent to a pixel decoder. The dominant interface compresses it into the hidden state of a single [SEG] token, a d-dimensional vector with no spatial index, and leaves the decoder, which never sees the expression, to recover the referent's extent. We show that the VLM already computes a better signal: the [SEG] token's attention over the image tokens, which is defined on the patch grid by construction. Probing a frozen segmentation VLM, we find that this attention yields 18 to 22 more gIoU than the [SEG] hidden state when read by the same probe, that it gains nothing from the image where the hidden state does, and that it is concentrated in the late layers. Building on these findings, we introduce AttnSeg, which replaces the [SEG] embedding with this attention as the decoder's prompt. A learned, signed combination of the attention heads forms a dense spatial prompt, and an attention-guidance objective supervises it directly. A two-stage recipe first trains the VLM to localize without the decoder and then trains the decoder to refine, within the budget of standard finetuning. Applied to Sa2VA, AttnSeg improves ReasonSeg by 6.4 gIoU and GS-Eval by 10.2 at 4B (4.2 and 9.6 over the same model finetuned on the same data), and by 8.8 and 11.3 at 14B. The gains reach 13 to 18 gIoU on object parts, multiple objects and single objects, where the referent must be singled out, and are negligible on stuff regions, which the decoder already recovers unaided.

AttnSeg in Action

Each demo follows one query through AttnSeg. The VLM answers with a [SEG] token; the [SEG] row of every layer and head is read over the image tokens; a learned 1×1 convolution emphasizes the heads on the target and subtracts those on distractors, sinks or diffuse regions; and SAM refines the resulting map into the mask.

Motivation

Segmenting an object from a natural-language expression requires deciding which region the expression refers to and where exactly its boundary lies. Promptable segmenters such as SAM have made the second the easier half of the problem: given a prompt that points at the right region, they return a high-quality mask. The first requires understanding the expression, which is the role of the VLM.

The VLM should be the load-bearing localizer, and the decoder should only refine.

Whether this holds depends on the interface through which the VLM passes the referent's location to the decoder. The dominant one, introduced by LISA and adopted by most later systems, prompts the decoder with the final hidden state of a [SEG] token: a single vector with no spatial index, handed to a decoder that never sees the expression.

The problem

A pointer cannot specify granularity

For “the left ear of the dog”, a vector that points at the dog leaves the decoder to guess whether the dog, its head or its ear is meant.

The symptom

The decoder absorbs the localization

The vector is supervised only through the mask loss after the decoder. On GS-Eval, Sa2VA-4B reaches 90.8 gIoU on stuff regions but 49.8 on single objects and 17.8 on object parts.

The question

Does the VLM already know where to look?

And if so, can the decoder be prompted with that signal directly, instead of with a vector that re-encodes it?

What the VLM Already Knows

We freeze Sa2VA-4B entirely, discard its decoder, and train only a lightweight probe to predict the mask from a single internal signal: the [SEG] hidden state, which the dominant interface transmits, or the [SEG] token's attention over the image tokens, which lies on the patch grid by construction. Because the model is frozen, whatever the probe recovers is information the signal already carries. Each signal is read at two capacities: a single 3×3 convolution (≈5K parameters) and a U-Net (≈3.86M).

Probe gIoU for the attention and the [SEG] embedding, with a convolution, a U-Net, and a U-Net with the RGB image, on GS-Eval and ReasonSeg.
(a) Which signal, and what it carries
Probe gIoU for five-layer windows across the LLM layers on RefCOCO+ val, GS-Eval and ReasonSeg.
(b) Where in the network it resides
Probes trained on a frozen Sa2VA-4B. (a) Read by the same U-Net, the [SEG] attention beats the [SEG] embedding by 18.2 and 21.5 gIoU, and adding the RGB image helps the embedding (+4.4, +7.3) but not the attention (−0.3, +0.2). (b) Probes restricted to a five-layer window: the early layers carry almost no localization, and a single late window matches the whole stack (dashed).
Finding 1

The attention carries more localization than the hidden state

Read by the same U-Net, the [SEG] token's attention yields 18.2 and 21.5 more gIoU than its hidden state on GS-Eval and ReasonSeg. With a single convolution, the two score within a few points of each other, so the advantage appears only once the probe can combine the head maps nonlinearly. The vector the dominant interface transmits is the weaker of the two spatial representations the model computes.

Finding 2

The image helps the embedding, not the attention

Giving the U-Net the RGB image as well improves the probe of the hidden state by 4 to 7 gIoU and leaves the probe of the attention unchanged. This is consistent with the attention already encoding the referent's extent at patch resolution, which the hidden state lacks and must recover from the pixels.

Finding 3

The signal occupies a narrow late band

Roughly the first 40% of the layers carry almost no localization, and a single late window of five layers matches a probe given every layer, at both probe capacities. A uniform average over layers and heads would spend most of its weight where there is nothing to read, which motivates a learned, selective aggregation.

Method

AttnSeg overview: the [SEG] row of the attention tensor is restricted to image tokens, folded onto the patch grid per layer and head, combined by a signed 1x1 convolution, and supervised by the attention-guidance loss against the downsampled ground-truth mask.
How AttnSeg reads and shapes the spatial channel. The [SEG] token's query row of the attention tensor, restricted to image columns and folded onto the patch grid, gives one map per layer and head; a 1×1 convolution with signed weights combines them, and \(\mathcal{L}_{\mathrm{att}}\) supervises the result.

Attention as the spatial interface

AttnSeg replaces the [SEG] embedding with the [SEG] token's attention as the interface between the VLM and the decoder. For each layer \(l\) and head \(k\), the attention row queried by the [SEG] token and restricted to the image tokens assigns a weight to every patch; each map \(\boldsymbol{a}^{(l,k)}\) is rescaled to spatial mean one, so a head is characterized by where it attends rather than by how much. A learned combination turns the \(LH\) maps into one map, and that map alone prompts the decoder:

\[ \hat{\boldsymbol{Y}} = \mathcal{D}\big(\boldsymbol{I}, \hat{\boldsymbol{a}}\big), \qquad \hat{\boldsymbol{a}} = \sum_{l=1}^{L}\sum_{k=1}^{H} w_{l,k}\, \boldsymbol{a}^{(l,k)}, \qquad w_{l,k}^{(0)} = \tfrac{1}{LH}. \]
  • Dense. The map enters the decoder's mask-prompt channel and is never thresholded or sampled, so the decoder receives its graded confidence rather than a binary mask or a handful of points.
  • Selective. The weights amount to a 1×1 convolution with only \(LH\) parameters, initialized at the uniform average and learned rather than fixed to the band the probes found.
  • Signed. A softmax gate can only suppress a misleading head; a negative weight can subtract it. The learned weights emphasize heads on the referent and subtract heads locked onto distractors, attention sinks or diffuse regions.

Attention-guidance objective

We supervise the map directly against the ground-truth mask, area-pooled onto the patch grid as \(\boldsymbol{m}\). The map should delineate the referent as fully as a patch-level map allows, while recovering the boundary at full resolution remains the decoder's task. We adopt a weighted cosine, with foreground patches weighted \(\lambda_{\mathrm{fg}} = 3\) and background patches \(\lambda_{\mathrm{bg}} = 1\), and combine it across targets as

\[ \mathcal{L}_{\mathrm{att}} = \frac{\sum_i g_i\, s_i\, \ell^{\cos}(\hat{\boldsymbol{a}}_i, \boldsymbol{m}_i)}{\sum_i g_i\, s_i}, \qquad s_i = \mathrm{clamp}\big(\bar{m}_i^{-\rho},\, 0.25,\, 12\big), \quad \rho = 0.3, \]

where \(\bar{m}_i\) is the fraction of the grid that target \(i\) covers and the gate \(g_i\) is zero once the peak of its map already falls inside the target.

Why cosine

It spreads misplaced attention out

Dice penalizes the total mass placed off the target, however it is distributed. The cosine's gradient on a background patch grows with the response there, so a concentrated response locked onto a distractor costs more than diffuse background activity. A concentrated response is exactly what misleads the decoder.

Why not a peak loss

Pointing is not enough

A peak ratio corrects only the strongest patches, so it teaches the map where to point but not how far the referent extends, which reduces the attention back to a pointer.

Why scale-aware

Small targets need the map most

The decoder can recover a large region from almost any prompt but not a small one, so \(s_i\) favors small targets, and the gate \(g_i\) keeps the extra weight from displacing peaks that are already correct.

Decoupled two-stage training

We train the two components separately, so that the VLM carries the localization at the granularity the expression demands and the decoder only refines it. Under joint training, the decoder's gradient into the map is roughly 49 times that of \(\mathcal{L}_{\mathrm{att}}\) and roughly orthogonal to it, so the map would be shaped mostly by the decoder.

Stage 1

The VLM learns to localize

The VLM (with LoRA) and the aggregation weights are trained with \(\mathcal{L}_{\mathrm{att}}\) and the next-token loss. The decoder takes no part, so no mask loss reaches the map.

Stage 2

The decoder learns to refine

The VLM and the aggregation weights are frozen, and only the decoder is trained to read the resulting map, which confines it to refining the localization the VLM provides.

Each stage takes half of one epoch of the Sa2VA training mixture, the same budget as finetuning the base model for one epoch.

Results

Main results

We build AttnSeg on two Sa2VA models, with InternVL2.5-4B and InternVL3-14B as their VLMs, and evaluate on ReasonSeg (test), which names the target by its function or role rather than its appearance, and on GS-Eval, which varies the granularity of the target. Neither benchmark's training data is part of our training mixture.

Comparison with prior work, in gIoU. Highlighted rows are AttnSeg on the base model directly above; bold marks the best value in each column.
Method ReasonSeg GS-Eval
SentencePhraseOverall StuffObject partsMulti obj.Single obj.Overall
LISA-7B47.4939.0845.4780.3421.2571.9542.6256.34
GLaMM51.6842.9449.5891.3824.3778.5054.1165.66
Sa2VA-Qwen3-4B-SAM259.4256.2858.6791.4122.7976.9154.7765.41
Sa2VA-Qwen3-4B-SAM365.4661.4764.5089.0917.0670.2348.7460.29
VISA-7B50.7343.5049.0085.3025.3975.7050.4862.10
SAMTok-Qwen3VL-4B59.4158.0359.0887.6431.0156.7756.2861.82
VideoLISA-3.8B45.5933.6142.7286.9923.4073.5442.5258.70
GSVA-13B38.7336.7538.2677.3422.8455.4638.3050.58
PixelLM-7B46.1237.0243.9441.2911.1249.9630.0834.93
Sa2VA-InternVL2.5-4B59.5152.0457.7090.8017.8073.3349.8061.91
  + AttnSeg (ours)64.8061.9364.1191.2035.2986.3762.9772.11
Sa2VA-InternVL3-14B61.4459.1160.8889.4526.9769.6652.6763.05
  + AttnSeg (ours)69.5570.2369.7190.8545.0185.0866.4374.31

Both benchmarks, both scales. At 4B, ReasonSeg rises from 57.70 to 64.11 and GS-Eval from 61.91 to 72.11; against the base model finetuned on the same data for the same budget, the gains are still 4.19 and 9.56. At 14B, the gains are 8.83 and 11.26, reaching 69.71 on ReasonSeg without any ReasonSeg training data.

The gain concentrates where the referent must be singled out. At 4B, object parts gain 17.49, multiple objects 13.04 and single objects 13.17 gIoU, while stuff regions, which the decoder already recovers from almost any prompt, gain 0.40. The same pattern holds at 14B.

Where the gain comes from

Starting from the released Sa2VA-InternVL2.5-4B, we add one component at a time. The attention-guidance objective accounts for 61% of the total gain on ReasonSeg and 83% on GS-Eval.

Isolating the source of the gain on Sa2VA-InternVL2.5-4B (gIoU).
ModelReasonSegGS-Eval
Baseline57.7061.91
  + Finetuning59.9262.55
  + Attention interface60.1863.64
  + \(\mathcal{L}_{\mathrm{att}}\) (AttnSeg)64.1172.11

Choice of the objective

The three objectives fail differently. The peak ratio points best but specifies almost no extent, which is the pointer of the [SEG] embedding, measured directly. Dice specifies extent but points worst. The weighted cosine is the only one with no severe weakness, and it yields the best masks.

Attention-map quality and final mask gIoU for three stage-one objectives on Sa2VA-InternVL2.5-4B, each followed by the same stage two. Pointing: share of queries whose strongest map patch lies inside the target. Extent: gIoU of the map thresholded at 0.5.
Stage-one objective Map pointing Map extent Mask gIoU
ReasonSegGS-EvalReasonSegGS-EvalReasonSegGS-Eval
Peak ratio74.3278.823.264.3460.1365.99
Soft Dice63.8965.6552.6456.0361.9169.56
Weighted cosine (ours)69.2475.7749.6059.0964.1172.11

Training makes the attention easier to read

We repeat the probing on the trained model, adding a gate with one weight per attention map (560 parameters) that can only select among the maps the model has already drawn. The gate gains 18.04 and 17.86 gIoU and now recovers close to four fifths of what a U-Net nearly seven thousand times larger recovers, against about half before training. The objective mainly reorganizes the attention so that a trivial readout can take the localization directly.

The probes, in gIoU, on the released Sa2VA-InternVL2.5-4B (baseline) and on AttnSeg built from it. The gain is largest for the smallest probe.
Model Gate (560) Conv (5K) U-Net (3.86M) U-Net + image
ReasonSegGS-EvalReasonSegGS-EvalReasonSegGS-EvalReasonSegGS-Eval
Baseline24.0026.8225.8429.8952.0553.1852.2152.89
  + AttnSeg42.0444.6831.2734.6753.9657.1354.1057.43

Qualitative Results

Because the map is the decoder's only prompt, the map and the mask can be read against each other directly: the attention map is the prediction, not a diagnostic. Click any figure to enlarge it.

Seven queries, each with the image, the aggregated [SEG] attention map and the final mask.
For each query, the aggregated [SEG] attention and the mask the decoder refines from it.

BibTeX

@article{abdelrahman2026segment,
  title   = {Segment Where You Look: Attention as the Interface
             Between Language Models and Segmenters},
  author  = {Abdelrahman, Eslam and Alkaf, Hamza Omar and Li, Yuheng and
             Iyer, Siddharth Srinivasan and Zhao, Nanxuan and
             Shechtman, Eli and Singh, Krishna Kumar and Elhoseiny, Mohamed},
  journal = {arXiv preprint},
  year    = {2026}
}