DL0138 Point-Informed Region VLM

Explain how Point-Informed or Region-Based Vision-Language Models incorporate bounding boxes or visual prompts directly into self-attention, as in Ferret and Molmo.

Answer

A region-based VLM has to turn a geometric object (a box, a point, a scribble) into something a transformer can consume, and there are only three places to put it: the token sequence, the positional encoding, or the attention logits. The cheapest route serializes the geometry as coordinate tokens, either quantized bins added to the vocabulary (Kosmos-2 uses 1024 location tokens over a 32×32 grid, written like <loc_0512>) or plain digit strings (Shikra), so the box reaches self-attention as ordinary keys and values with zero architecture change. The second route extracts region features with RoIAlign or a learned sampler and projects them into the language model’s embedding space as extra tokens interleaved into the prompt (GPT4RoI, Ferret), which every text token can attend to like a word. The third route never adds tokens at all: it adds a bias matrix B to QK^{\top} before the softmax, so patches inside the referred region get a boost and patches outside get suppressed or hard-masked to -\infty. A fourth, architecture-free trick draws the prompt in pixel space (ViP-LLaVA’s overlaid arrows and circles, Set-of-Mark’s numbered masks) and lets the vision encoder’s own self-attention pick it up, which is the only option when the model is a frozen API. The choice is a trade among spatial precision, sequence growth, and how much grounding supervision you can afford to train on.

(1) Three Injection Points: geometry enters as tokens, as positional/coordinate embeddings, or as an additive term inside the attention logits, and most systems combine at least two.
(2) Coordinate Tokens Are Free But Quantized: a 1000-bin normalized grid on a 1024 px image gives roughly 1 px resolution, but the same bins on a 4K crop after tiling lose fidelity and shift under aspect-ratio padding.
(3) Region Tokens Buy Content, Not Just Location: a pooled RoIAlign vector carries appearance of the referent, so the model can describe a region it could not have isolated from coordinates alone.
(4) Attention Bias Adds Zero Parameters: B_{ij} is added elementwise to the pre-softmax scores, leaving the O(N^2 d) cost and the KV cache unchanged, and a per-head \lambda_h can be learned.
(5) Hard Masks Destroy Context: setting B_{ij} = -\infty outside the region removes exactly the surrounding evidence that relational questions need, and a fully masked row produces a degenerate softmax.
(6) Points Are Cheaper Supervision Than Boxes: Molmo’s pointing data shows a single (x, y) pair is enough for counting and referring, and it avoids the box-regression ambiguity for deformable objects.
(7) Pixel-Space Prompts Work On Frozen Models: drawing the mark changes the image, not the architecture, but it occludes content and fails on thin or tiny structures.

Diagram of a vision-language model token sequence containing text tokens, quantized coordinate tokens, projected region-feature tokens and image patch tokens, all feeding a self-attention block whose pre-softmax logits receive an additive region bias matrix from the side, with a separate pixel-space visual prompt path feeding the patch tokens

Figure 1: Four ways a box reaches attention. Mechanisms (1) and (2) extend the token sequence so geometry becomes ordinary keys and values, mechanism (3) leaves the sequence untouched and edits the pre-softmax logits, and mechanism (4) modifies the pixels so the vision encoder does the work. Only (3) avoids sequence growth entirely.

The region-feature path is the one that most resembles classical detection heads: pool the backbone feature map over the box (RoIAlign → linear projector → language-model token), then concatenate a coordinate embedding so the model knows where the appearance came from, not only what it looks like. Ferret generalizes this with a spatial-aware visual sampler that samples and pools features inside an arbitrary free-form shape, so a point, a box, and a scribble all reduce to the same fixed-size token, and Groma pushes localization into the tokenizer itself by proposing regions up front and giving each one a referable ID token. The attention-bias path is complementary and is the literal reading of the question: because the softmax is invariant to nothing but its own inputs, a single additive term reweights how much probability mass a text query spends on patches inside versus outside the referent, and a moderate \lambda_h concentrates mass without deleting surrounding context. In practice, training matters more than the plumbing: none of these mechanisms produces reliable grounding without a large corpus of region-text pairs, which is why grounded VLMs are trained on visual genome, RefCOCO-style referring expressions, and synthetically generated region captions.

Mathematical Formulation:
e_r = W_v\, \mathrm{RoIAlign}(F, b) + W_c\, \psi(b)
\psi(b) = [\, x_1,\, y_1,\, x_2,\, y_2 \,] / S
Z^{(0)} = [\, E_{txt};\; e_r;\; E_{img} \,]
A = \mathrm{softmax}\!\left( \frac{QK^{\top}}{\sqrt{d_h}} + B \right)
B_{ij} = \lambda_h \, \mathbf{1}[\, j \in \mathcal{R}(i) \,]
\mathrm{cost} = O\big( (N + M)^2 d \big)

Where:

  • e_r is the region token appended to the prompt, and Z^{(0)} is the full input sequence of text, region, and image-patch embeddings.
  • F is the vision-encoder feature map, b = (x_1, y_1, x_2, y_2) the box in pixels, S the image side used for normalization, and \psi(b) the normalized coordinate vector.
  • W_v projects the pooled region feature into the language-model width and W_c embeds the coordinates; both are the only new parameters this path needs.
  • Q, K are the query and key projections of Z, d_h the per-head dimension, and A the attention matrix over all N + M positions.
  • B is the additive region bias, \mathcal{R}(i) the set of positions that query i is encouraged to attend to (the patches overlapping the referred box), and \lambda_h \geq 0 the per-head bias strength; \lambda_h = 0 recovers plain attention and \lambda_h \to \infty gives a hard mask.
  • N is the number of visual plus text tokens, M the number of added region or coordinate tokens, and d the model width, so token-based injection is quadratic in M while the bias term is free.
Three grayscale heatmaps of a text query's attention over an eight by eight patch grid, with a blue rectangle marking the referred region: the first with no bias shows diffuse mass spread across the image, the second with a soft additive bias concentrates mass inside the rectangle while keeping some outside, and the third with hard masking puts all mass inside the rectangle and exactly zero outside

Figure 2: The same query, the same keys, three values of \lambda_h. A soft bias raises in-region mass from a small baseline to the majority while preserving outside context, which is what relational questions need; hard masking reaches 100% in-region mass and throws that context away.

PropertyCoordinate tokensRegion-feature tokensAttention bias / maskPixel-space prompt
Path into attentionNew vocabulary or digit tokens as keys/valuesPooled RoI feature projected to an embeddingAdded to pre-softmax logitsAltered patch embeddings
New parametersEmbedding rows onlySampler plus two projectionsNone, or one scalar per headNone
Sequence growth4 to 8 tokens per box1 to 49 tokens per regionZeroZero
Precision limitBin width and tiling frameRoIAlign grid and patch stridePatch stride (14 or 16 px)Stroke width and image resolution
Main failure modeCoordinate frame drift after padding or cropsToken blowup with many regionsLoses outside context; needs a region per queryOccludes the referent; fails on small objects
Representative systemsPix2Seq, Kosmos-2, Shikra, Qwen2.5-VLGPT4RoI, Ferret, GromaRegion-conditioned decoders, SAM-style promptingViP-LLaVA, Set-of-Mark

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *