RI-SAM3: Turning Few-Shot References into Reusable Text Tokens
The paper's core claim is that under severe domain shift a reference set is worth more inverted once into a reusable textual condition than compared against every target image at inference time.
On this page
Your team holds 4 unseen target domains and only 1 to 5 annotated references per class, but the segmentation demo you were shown ran on datasets none of those domains resemble. Do you sign off on the pilot? The usual advice is to run reference-target visual matching: compare the few annotated images against each new target image and transfer the correspondences, a pipeline recent SAM-based work has made cheap. That advice quietly assumes the match measures the category. It measures appearance. A paper on arXiv argues the reference set should be spent once, inverted into a reusable textual condition, and then discarded before inference, so every target image of a class shares one conditioning signal [1]. The method is called RI-SAM3, it keeps SAM3 frozen, and it optimizes roughly 12K parameters per category.
Four benchmarks, and two numbers that contradict the usual story
The evaluation covers four CD-FSS benchmarks that sit far from any natural-image source domain: ISIC for dermoscopy, Chest X-Ray for radiographs, DeepGlobe for satellite imagery, and SUIM for underwater scenes. Each is reported at 1-shot and 5-shot and scored by mIoU, the mean over images of the intersection-over-union between predicted and ground-truth masks. The table below reproduces the 1-shot columns of the paper's comparison table, restricted to rows that report a number on all four benchmarks. RI-SAM3's own row sits at the end of that table in the paper, and the excerpt available to me is truncated inside the baseline block, so no numbers are invented for it here.
| Method | Venue | ISIC | Chest X-Ray | DeepGlobe | SUIM |
|---|---|---|---|---|---|
| PerSAM | ICLR 2024 | 23.9 | – | 31.4 | – |
| Matcher | ICLR 2024 | 38.6 | 66.8 | 48.1 | 37.9 |
| APSeg | CVPR 2024 | 45.4 | 84.1 | 35.9 | – |
| GF-SAM | NeurIPS 2024 Spotlight | 48.7 | 47.6 | 49.5 | 38.3 |
| ISA | ICCV 2025 | 37.2 | 83.4 | 44.3 | 44.1 |
| LoEC | CVPR 2025 | 52.9 | 83.9 | 42.1 | – |
| IFA | CVPR 2024 | 66.3 | 74.0 | 50.6 | – |
| DATO | CVPR 2025 | 68.8 | 79.6 | 51.1 | – |
| ABCDFSS | CVPR 2024 | 45.7 | 79.8 | 42.6 | 35.1 |
Two readings matter for anyone choosing a model. First, visual-matching pipelines collapse on Chest X-Ray: GF-SAM scores 47.6 at 1-shot, while APSeg reaches 84.1, LoEC 83.9 and ISA 83.4 on the same benchmark, a gap of more than thirty points. Second, SAM-based does not mean better: on ISIC, IFA scores 66.3 and DATO 68.8 against GF-SAM's 48.7. The paper's claim is not that SAM variants dominate every cell; it is that replacing matching with textual conditioning beats these baselines consistently across the four benchmarks [1].
Why visual matching drifts: it scores appearance, not the category
The motivation figure shows one reference image applied to a set of same-class target images, and GF-SAM's per-image IoU swings widely across them. That is the mechanism rather than an accident, because the score is a similarity between two images, so it tracks how the target looks rather than what the category is. Adding references does not reliably fix it. Between 1-shot and 5-shot, GF-SAM moves from 47.6 to 47.4 on Chest X-Ray, while LoEC moves from 52.9 to 62.4 on ISIC. More references give more things to compare; they do not by themselves yield a more stable class representation.
There is a deployment cost as well. Matching requires the annotated references to stay available at inference, and the matching is recomputed for every target image, so that overhead scales with the number of images rather than being shared across a class.
Turning references into text once, then discarding them
The paper borrows textual inversion from text-to-image personalization, where a few images of a subject are used to learn a new token that can later regenerate that subject in fresh scenes. Here the subject becomes the target category and generation becomes segmentation. A naive alternative is worth ruling out first: use the class name as SAM3's text prompt. The paper tries exactly that, with lung for Chest X-Ray and forest land for the forest class in DeepGlobe, and reports low average accuracy with wide variation across target images of the same class. A class name says what the thing is, not what it looks like in this domain.
RI-SAM3 therefore inverts K annotated reference pairs, image plus mask, into soft tokens, meaning learned vectors that correspond to no real word. Formally the change is small. The old form conditions every prediction on the reference set; the new form learns a condition once, discards the references, and segments each target with that condition alone. The reference-target construction is untouched, and only its role at inference changes [1].
Three components, three distinct failure modes
- Bi-level Reference Inversion learns a reference word embedding before the frozen text encoder, so the tokens coming out of that encoder stay anchored in SAM3's pretrained text space and cannot drift arbitrarily; separately it learns reference concept tokens directly after the encoder, which are free to represent the category as it actually appears under domain shift. Both are supervised with the annotated references and together form the inverted reference tokens.
- Layer-adaptive Textual Conditioning combines the two token sets per decoder layer rather than with one fixed ratio, because SAM3's DETR-style decoder refines object queries progressively and shallow and deep layers need different semantics.
- Presence-aware Confidence Supervision jointly supervises query-level classification and the global presence score, since SAM3's mask confidence depends on both a presence token that asks whether the prompted concept occurs in the image and the per-query classification score, and both are fragile under domain shift.
None of these touch SAM3's weights. The method adapts the input prompt and a set of layer-wise coefficients, which is why the trainable budget stays near 12K parameters per category.
Cost: roughly 12K parameters per class, references used once
With SAM3 frozen, each category optimizes about 12K parameters, covering the two token sets and the per-layer fusion coefficients. The post-inversion state is what matters commercially: references are no longer needed, all target images of a class share one textual condition, and each target costs a single forward pass with no per-sample reference-target matching. The paper backs this with three additional studies, on robustness to reference image selection, efficiency, and generalization to related few-shot tasks.
When this does not apply
The paper reports consistent gains across its benchmarks, but the boundary belongs next to that claim, otherwise buyers over-generalize it.
- Scale with category count. The 12K figure is per category, and I will not multiply it here, but by construction the stored tokens and coefficients grow linearly with the number of classes. That linear-growth statement is my inference, not a number from the paper.
- The inversion is supervised by annotated masks, so mask quality enters the tokens directly. Bad references produce a bad condition, and that error is not corrected later at inference time.
- The method pushes what a category looks like into SAM3's text space. It fails when a category has no usable landing point in that pretrained space, because the word-level tokens are anchored there by design. That is my reading of the anchoring constraint rather than an ablation the paper reports.
- Do not read consistent-superiority as uniform superiority. Individual cells still favor conventional methods, for instance DATO at 68.8 and IFA at 66.3 on ISIC, while the visual-matching route via GF-SAM sits at 48.7. If your target domain resembles one cell, negotiate against that cell, not an average [1].
In short: it does not apply when categories are long-tailed and constantly added, or when the reference masks themselves are untrustworthy. Fix the data first; invert afterwards.
