Multimodal Foundation Models

Compare batchwise image–text alignment with token-level cross-attention and design an evaluation that separates retrieval from visual grounding.

Source
Anbloq
Language
English
Created
Updated
Chapters
3
Reading time
2 min
In this article3 chapters
  1. Contrastive alignment trains a shared retrieval space
  2. Cross-attention retains access to visual locations
  3. Test retrieval and grounding with different outputs

Contrastive alignment trains a shared retrieval space

Let \(v_i\) be a normalized image embedding and \(t_j\) a normalized text embedding. With positive temperature \(\tau>0\), a paired batch produces logits and an image-to-text probability

\[ \ell_{ij}=\frac{v_i^\top t_j}{\tau}, \qquad P(j\mid i)=\frac{\exp(\ell_{ij})}{\sum_k\exp(\ell_{ik})}. \]

A CLIP-style objective takes the cross-entropy in both directions against corresponding pairs. Semantically compatible but unmatched captions can act as false negatives. Once the encoders are trained, image embeddings can be indexed and compared to a new text query. Approximate neighbor search describes the retrieval costs when that index is large.

Embedding similarity gives a ranking rule for vectors already in a common space. Dot-product attention also explains how one text query can read different weighted visual values instead of comparing only aggregate image embeddings.

Cross-attention retains access to visual locations

A generative model can condition text states on a sequence of visual tokens. Queries from text attend over keys and values derived from the image. Different tokens can then read different image regions as generation progresses. The resulting conditional distribution also depends on language priors, so a fluent description may reflect typical co-occurrence instead of observed evidence. Attention weights alone do not identify which visual information was causally necessary. Intervention controls from mechanistic interpretability can test suitably specific hypotheses.

Test retrieval and grounding with different outputs

For an image with a red cup left of a blue plate, compare a correct caption to distractors that swap the objects, the colors or the relation. A retrieval score can remain high because vocabulary and overall content match. Grounding can ask for a region, a relation or a counted set and verify it with explicit annotations. Report retrieval recall and grounded performance separately. This tests whether alignment carries the compositional information needed by the downstream task.[1][2]

References

  1. Alec Radford et al., Learning Transferable Visual Models From Natural Language Supervision ↩
  2. Jean-Baptiste Alayrac et al., Flamingo: A Visual Language Model for Few-Shot Learning ↩