↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading… Image encoder once per image · text, fusion and decoder once per concept · image mode, no video tracker ·
Loading recorded inference…

Segmenting by concept

SAM segments the object a click or a box points at. SAM 3 answers a different question: given a short noun phrase such as “dog” or “ear”, find and segment every instance of that concept in the image, however many there are, possibly none. Its paper calls this Promptable Concept Segmentation. The model pairs a DETR-style detector with a video tracker that shares its backbone; the page records the detector in image mode.

The recording uses facebook/sam3 (840,376,374 parameters in the image detector) on the SAM tab's beagle photo, with three concepts: “dog” (one instance), “ear” (a part; both ears are visible) and “bicycle” (not in the photo). The image encoder runs once; text encoding, fusion and decoding run once per concept. The SAM vs SAM 3 button sets the two models side by side on this photo.

The image encoder and the feature pyramid

The Image Encoder row is a larger ViT: 32 blocks of width 1024 with 16 heads and an MLP of 4736. The photo is stretched to 1008 × 1008 (SAM padded instead) and cut into 14-pixel patches, a 72 × 72 grid of 5,184. Most blocks attend within 24 × 24 windows, 9 of them; blocks 8, 16, 24 and 32 attend globally. The learned 24 × 24 position table is tiled 3 × 3 rather than interpolated, and every attention rotates queries and keys with 2-D RoPE instead of SAM's relative-position tables:

Here the angles come from the patch's column and row. In a global block positions are squeezed by 24/72 into the 0–24 range of a single window, the size the encoder was pre-trained at. The paper builds this encoder, and the text encoder, from Meta's Perception Encoder, a vision–language model trained contrastively.

The Neck turns the single 72 × 72 output into a Feature pyramid of four 256-channel maps, at 288², 144², 72² and 36². The 72² map feeds the fusion encoder and the decoder; the 288² and 144² maps feed the mask decoder. SAM had a single 64 × 64 map.

The concept meets the image

The concept goes through a causal CLIP-style text encoder of 24 blocks, padded to 32 tokens. SAM 3 keeps every token's output, not one pooled vector, and projects each from 1024 to 256. The Concept & Fusion Encoder row then runs 6 pre-norm layers on the 72 × 72 image features. In each, the image attends to itself (Image Self Attention), then to the concept's tokens (Image → Text, padding masked), then passes through a ReLU MLP:

where . The output is the image fused with “dog”: every position now carries what it has in common with the phrase. SAM had no such step; its prompt tokens met the image only inside the small mask decoder.

Object queries and the presence token

The DETR Decoder row follows DETR. It starts from 200 learned object queries, each a slot that may claim one instance, plus one presence token. Each of its 6 post-norm layers runs query self-attention, so that two queries can avoid claiming the same instance, then attention to the text, then attention to the image with a bias built from the query's current box, then an MLP. After every layer a box head refines each query's box, .

Two heads score the result. Each query's logit compares its state with the mean of the concept's text tokens, , and asks whether this box is an instance. The presence token's logit asks once, for the whole image, whether the concept is there at all. A query is kept when the product passes the threshold:

The paper separates recognition (is it here?) from localisation (which boxes?) because the first needs the whole image while the second is a local job, and reports that the split improves detection accuracy. It trains the queries by one-to-one Hungarian matching to the true instances, as DETR does. Finally a mask head adapted from MaskFormer computes each kept query's 288 × 288 mask as the dot product of a query embedding with per-pixel features, as SAM computed its masks from 4 tokens.

What the recording shows

For “dog” the presence probability is 0.992 and one query, q144, scores 0.982. Its box, (266.7, 100.9)–(1001.9, 748.9), is almost the box the SAM tab prompts with. The next query scores 0.116. Query q11 has almost the same box and mask as q144 but scores only 0.055, so only one of the two is kept; one-to-one matching in training rewards a single query per instance.

For “ear” the presence is 0.9993 and two queries pass, q104 at 0.925 and q121 at 0.882, one for each ear. For “bicycle” the presence is 0.0009. One query passes 0.5 on its own, at over the hose, but multiplied by the presence its score is 4.4 × 10⁻⁴, and the Detections card reports no instance. That is the presence token's job: without it, one query would have passed as a bicycle.

Where it came from

DETR (Carion et al., 2020) recast detection as set prediction: a fixed set of learned queries, a transformer decoder, and Hungarian matching instead of anchors and non-maximum suppression. MaskFormer added a mask for every query. SAM (2023) made segmentation promptable with points and boxes, and SAM 2 added a memory for video. SAM 3 (Carion et al., 2025) joins the two lines. Its paper reports that it doubles the accuracy of existing systems on concept segmentation in images and video, trained on a data engine with 4 million unique concept labels, hard negatives included.

The SAM tab shows the click-and-box model this one extends, and the CLIP tab the contrastive training behind its encoders.

Papers

  1. SAM 3: Segment Anything with Concepts Nicolas Carion et al. · arXiv 2025 SAM 3, the model this page records: promptable concept segmentation with a DETR-style detector, a presence head and the SA-Co benchmark.
  2. End-to-End Object Detection with Transformers Nicolas Carion et al. · ECCV 2020 DETR: object queries, a transformer decoder and Hungarian matching, the design of SAM 3's decoder.
  3. Segment Anything Alexander Kirillov et al. · ICCV 2023 SAM, the click-and-box model this page compares with.
  4. Perception Encoder: The best visual embeddings are not at the output of the network Daniel Bolya et al. · arXiv 2025 The contrastively trained vision–language encoder SAM 3 adapts for its image and text encoders.
  5. Per-Pixel Classification is Not All You Need for Semantic Segmentation Bowen Cheng, Alexander G. Schwing, Alexander Kirillov · NeurIPS 2021 MaskFormer: a mask per query from per-pixel embeddings, the origin of SAM 3's segmentation head.
  6. SAM 2: Segment Anything in Images and Videos Nikhila Ravi et al. · ICLR 2025 Promptable video segmentation with memory, the basis of SAM 3's tracker (not recorded here).
  7. Learning Transferable Visual Models From Natural Language Supervision Alec Radford et al. · ICML 2021 CLIP, whose text-encoder architecture SAM 3 uses to read its concepts.

See also