Image-language and multimodal models · Image-language and multimodal models · MM012 · Model
Flamingo
Connects pretrained vision and language models to process interleaved visual/text sequences and learn from demonstrations placed in context.
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran here in one language.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Connects pretrained vision and language models to process interleaved visual/text sequences and learn from demonstrations placed in context. It includes images and video inputs, but this entry focuses on the multimodal bridging and few-shot mechanism rather than duplicating video backbones.
Question / objective
Can interleaved multimodal pretraining enable new visual-language tasks from a few examples in the prompt without task-specific gradient updates? The learning target replaces a null/alternative hypothesis formulation; benchmark evaluation is a separate statistical task.
Method type and supervision
Model/system family. Image-language or broader multimodal learning using the paired, generated or task-specific supervision described below. This is not a classical significance test.
Architecture / computational structure
A visual encoder supplies features to a Perceiver-style resampler; gated cross-attention layers inserted into a frozen language model expose visual information while retaining the pretrained text pathway.
Assumptions
In-context examples consume context and can leak answers or benchmark templates. Few-shot prompting is not gradient fine-tuning. Image ordering and attention masking determine which visual evidence an answer can use.
Formula / computational definition
illustrates gated visual cross-attention, with learned gate . Autoregressive text likelihood conditions on the preceding interleaved images/text under a declared visual-attention mask. This captures the central mechanism; consult the primary source for all masks, stages, normalizations and loss terms.
Parameters and notation
Learned/estimated quantities: Resampler, inserted cross-attention and gate parameters are learned; the original recipe freezes major pretrained encoders. Demonstration content/order are inference inputs, not updated model weights. Hyperparameters and design choices: Resampler token budget, insertion frequency, interleaving rules, context length, image count and demonstration selection influence results.
Fitting, fine-tuning, and adaptation
Evaluate genuine in-context adaptation before training. A custom domain adaptation can tune inserted modules or supported adapters, retaining text-only validation to detect forgetting; this is distinct from the paper’s few-shot evaluation protocol. Save the exact trainable-module selection, data split, loss, optimizer and processor configuration; distinguish parameter adaptation from inference-time prompt tuning.
How to use and calibrate
Choose a specific model/processor and task protocol, validate preprocessing on known examples, tune only on a held-out development set and freeze the final evaluation. Report zero-shot and few-shot scores separately, demonstration selection policy, ordering sensitivity and grounding/hallucination controls.
Example application
Provide several image/question/answer demonstrations and ask the system to answer for a new image.
Interpretation / pitfalls
Watch out
Reported capability is conditional on available visual evidence, data coverage and the chosen task. Report zero-shot and few-shot scores separately, demonstration selection policy, ordering sensitivity and grounding/hallucination controls. A successful numeric component example is not evidence that a complete system achieves a published benchmark score.
Python and R code examples
Component: Show the effect of a gated visual residual initialized at zero. Dependencies: shared NumPy/base-R setup above. Python: executed successfully. R: unexecuted. Complete model training/inference: not run.
Full implementation routes: Python: reproduce the disclosed architecture or use a clearly identified open reproduction; original Flamingo is not assumed fully downloadable. R: bridge an available implementation and evaluate prompt-order sensitivity, without claiming architectural identity for every reproduction.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Show the effect of a gated visual residual initialized at zero.
Shared setup for this chapter
import numpy as np
def softmax(x):
z = np.asarray(x, dtype=float)
e = np.exp(z-z.max())
return e/e.sum()
language=np.array([.4,.6]); visual_update=np.array([.3,-.2])
for gate in [0.,.5,1.]:
fused=language+np.tanh(gate)*visual_update
print(gate,fused)
# A zero gate preserves the original language representation.
Component demo, not a trained model — Show the effect of a gated visual residual initialized at zero.
language <- c(.4,.6); visual_update <- c(.3,-.2)
for(gate in c(0,.5,1)) print(language+tanh(gate)*visual_update)
Sources
- Primary source 1arxiv.org
From the CodeSplash reference, entry MM012.