eSAM: Editing SAM3 Attention for Training-Free Referring Segmentation

Yaoting Wang, Yun Zhou, Hengrui Hu, Chang Liu, Henghui DingNeurIPS 2026

TL;DR

SAM 3 can natively segment objects from text prompts, yet it stumbles on complex descriptions because a single <start_of_text> token acts like a gravitational sink, swallowing over half of the model’s cross-attention budget. Rather than retraining the network or bolting on a heavy Large Language Model, eSAM fixes this at inference time by surgically editing SAM 3's internal attention maps and value tensors. The result is a fast, completely training-free upgrade that unlocks state-of-the-art referring segmentation across images and videos.

What Problem Does This Paper Address?

Imagine asking an AI to outline "the clear bottle between the candles without a yellow cap." This task—Referring Expression Segmentation (RES)—requires tight, pixel-level coordination between vision and free-form language. Training models specifically for RES requires mountains of expensive pixel-mask and text pairs. To dodge this annotation tax, researchers often stitch together Rube Goldberg pipelines—say, using CLIP or a massive Multimodal LLM to guess a bounding box, then feeding that box into SAM. Errors inevitably cascade down the line.

SAM 3 promised a cleaner path by building text-prompted segmentation natively into a single foundation model. Yet out of the box, its RES performance is underwhelming. Why? When the authors looked inside SAM 3’s multimodal fusion encoder, they found a severe attention sink: image patches route an average of 54.8% of their cross-attention mass straight to the <start_of_text> (SOT) token, starving the actual descriptive words (like "bottle" or "yellow") of influence.

Figure 2: Attention sink in SAM 3 fusion encoder. (a) Per-patch SOT mass on four examples from the RefCOCO val split; high mass is observed at both referent and background patches. (b) The same patches after sink suppression. (c) Per-patch distribution of SOT mass over 500 samples from the RefCOCO val split. (d) Per-layer mean SOT mass shows that the sink happens at each layer.

Methods

The authors keep SAM 3 completely frozen and view its cross-attention layer through two distinct stages: routing (the softmax probabilities deciding which words each image patch listens to) and readout (the value vectors determining how loudly those words speak). eSAM intervenes in both stages at a single fusion layer during inference:

Figure 1: Overview of eSAM. We keep SAM 3 frozen and edit its multimodal fusion encoder’s cross-attention through two inference-time interventions guided by a CLIPSeg-derived spatial prior h. Attention Mask Editing (AME) edits the attention map by suppressing the SOT logit and injecting h as an additive bias on content tokens. Value Tensor Editing (VTE) rescales the value tensor, amplifying content tokens’ readout magnitude. The fused features pass through SAM 3’s native decoders without modification.
  • Spatial Prior Generation (Standard): First, a lightweight, off-the-shelf open-vocabulary segmenter (CLIPSeg) generates a coarse heatmap from the image and text, normalized to $[0, 1]$. This serves as a rough "warm/cold" map of where the target likely lives.
  • Attention Mask Editing – AME (Novel): Simply suppressing the SOT token everywhere causes freed-up attention to scatter randomly across the background. Instead, AME uses the spatial prior $h$ to modulate pre-softmax logits selectively. Where $h$ is high, AME simultaneously suppresses the SOT logit ($-\beta h_i$) and boosts content-token logits ($+\alpha h_i$). Where $h$ is near zero, SAM 3's native routing is left untouched.
  • Value Tensor Editing – VTE (Novel): Fixing routing probabilities isn't the whole story if the content tokens' value vectors have small magnitudes. VTE scales up the value vectors of all content tokens by $(1 + \gamma)$, amplifying their contribution to the final fused visual features without altering vector directions.

Datasets

Because eSAM is completely training-free, no training datasets are used (hyperparameters are selected on the RefCOCO validation split and held fixed everywhere else). Evaluation spans seven standard benchmarks, with no new datasets introduced:

  • Referring Image Segmentation (RIS): RefCOCO, RefCOCO+, RefCOCOg, and gRefCOCO (which tests multi-target and complex expressions).
  • Referring Video Object Segmentation (RVOS): Ref-DAVIS17, Ref-YouTube-VOS, and MeViS (which focuses on challenging motion-centric descriptions).

Key Insights and Ideas

  • Plug-and-play prompting fails where internal surgery succeeds: What if you just converted CLIPSeg’s heatmap into boxes, points, or masks and fed them into SAM 3 as standard prompts? The authors tried this, and performance dropped by 16–19 IoU points below vanilla SAM 3. Injecting that exact same noisy prior inside cross-attention yields a +6.39 IoU jump—proving SAM 3's internal text-visual fusion is far more resilient than external prompt conversion.
  • Unconditional sink-plugging backfires: Uniformly suppressing the SOT token across every patch actually degrades accuracy slightly compared to just boosting content words. Freed attention needs directional guidance; otherwise, background patches latch onto foreground descriptions.
  • The "Goldilocks" layer:SAM 3 has six fusion layers (L0–L5), and editing only Layer 1 (L1) consistently beats editing any other layer—or even editing multiple layers at once. L1 sits right after initial image-text contact, giving the remaining four layers enough depth to organically propagate and refine the edited features.

Key Results

Across non-LLM training-free baselines, eSAM sweeps the board:

  • Images (RIS): Averaged across all 11 dataset splits, eSAM boosts overall IoU (oIoU) by +8.51 over vanilla SAM 3 and +12.20 over RefAM (the strongest prior training-free method). On RefCOCO val, it hits 53.62 oIoU—even beating zero-shot methods that require auxiliary training like VLM-VG (+8.22 oIoU).
  • Videos (RVOS): Averaged across all three video benchmarks, eSAM improves the combined region and contour score ($\mathcal{J}\&\mathcal{F}$) by +13.64 over SAM 3 and +8.09 over RefAM (e.g., jumping from 42.43 to 57.50 $\mathcal{J}\&\mathcal{F}$ on Ref-YouTube-VOS).
  • Negligible Overhead: eSAM adds just 1.5% extra FLOPs (entirely from tiny CLIPSeg) and 24 milliseconds of latency per image (0.146s $\rightarrow$ 0.170s on an A6000 GPU). By comparison, diffusion-based RefAM takes 3.97s, and MLLM-driven pipelines take 12–23s per image.
  • Tough Linguistic Edge Cases: On complex subsets, eSAM leaps ahead of SAM 3 on lexical negation (+6.22 oIoU) and multi-target queries (+18.88 oIoU).

Limitations and Future Work

  • Mystery of Layer 1: While empirical feature-change ratios confirm L1 is special in SAM 3, the authors note that why L1 dominates—and whether this sweet spot generalizes to other vision-language architectures—remains an open theoretical question.
  • Reliance on External Priors: Routing guidance still leans on an external model (CLIPSeg). Stronger or task-adaptive spatial priors could push accuracy further.
  • Symptom vs. Cure: eSAM patches an attention sink in a frozen network at test time. A natural next step is monitoring routing and readout distributions during pre-training, designing auxiliary loss terms that prevent foundation models from forming attention sinks in the first place.

Summary updated

Abstract

Referring expression segmentation (RES) aims to segment objects described by natural language in images (RIS) or videos (RVOS). Existing zero-shot methods reduce reliance on mask-language annotations but still require auxiliary training or multi-model pipelines. SAM 3 enables native text-prompted segmentation within a single foundation model, yet performs poorly when directly applied to RES. We trace this gap to an attention sink in its multimodal fusion encoder, where the start-of-text token absorbs a substantial portion of each image patch's cross-attention mass, limiting the influence of content tokens. Suppressing the sink alone redistributes attention indiscriminately, making spatial guidance necessary. We therefore introduce eSAM, a fully training-free framework that addresses this issue by editing SAM 3's cross-attention. Attention Mask Editing (AME) suppresses the sink and uses a CLIPSeg-derived, patch-dependent spatial prior to redirect attention toward relevant content tokens. Value Tensor Editing (VTE) rescales value tensors to amplify content-token contributions to the fused visual features. On RIS (RefCOCO/+/g) and RVOS (Ref-DAVIS17, Ref-YouTube-VOS, MeViS) benchmarks, eSAM achieves state-of-the-art performance among training-free methods without auxiliary LLMs.
BibTeX
@inproceedings{wang2026esam,
  author = {Yaoting Wang and Yun Zhou and Hengrui Hu and Chang Liu and Henghui Ding},
  title = {{eSAM: Editing SAM3 Attention for Training-Free Referring Segmentation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=If1BheAYFE},
}
Figure