SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2204.14198 · NeurIPS · 2022

Flamingo: a Visual Language Model for Few-Shot Learning

Andrew Zisserman, Jeff Donahue, Karen Simonyan, Oriol Vinyals, Jean-Baptiste Alayrac, Andrew Brock, Sebastian Borgeaud, Sina Samangooei, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, and 15 more

arXiv · PDF · Open in the Atlas

Code that ran

18 of 24 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (6 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 10 have no contract verdict; 7 failures of our instrument; 6 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2204.14198.json · badge: /api/ran/2204.14198.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
doc-doc/NExT-OE community
Papers with Code archive
6 ran · 2 no recorded run
happen2me/cross-gnn community
Papers with Code archive
5 ran · 2 no recorded run
lucidrains/flamingo-pytorch community (classifier label)
classifier basis not recorded on the link
4 ran · 0 no recorded run
mlfoundations/open_flamingo community
Papers with Code archive
3 ran · 2 no recorded run
FunctionStatusWhere it lives
FeedForward Ran
ran; our contract draft was wrong, not the code
happen2me/cross-gnn/models/flamingo.py
pointer only (licence: NONE) · get_code("d2cbfbdf5d175293")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, happen2me/cross-gnn when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

FeedForward Ran
ran; our contract draft was wrong, not the code
mlfoundations/open_flamingo/open_flamingo/src/flamingo.py
code served (permissive licence) · get_code("169a4ac97467ef76")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Sequential. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn

torch.manual_seed(0)

ARGS = {
    "dim": 8,
    "mult": 4
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
FeedForward Ran
ran; our contract draft was wrong, not the code
lucidrains/flamingo-pytorch/flamingo_pytorch/flamingo_pytorch.py
code served (permissive licence) · get_code("a89330150e46391d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Sequential. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn

torch.manual_seed(0)

ARGS = {
    'dim': 64,
    'mult': 4
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
FlamingoCausalLMOutputWithCrossAttentions Ran
ran on a synthesized input · constructed an object; no result was computed
happen2me/cross-gnn/models/flamingo.py
pointer only (licence: NONE) · get_code("98b69f6a47879974")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, happen2me/cross-gnn when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

FlamingoConfig Ran
ran on a synthesized input · constructed an object; no result was computed
happen2me/cross-gnn/models/flamingo.py
pointer only (licence: NONE) · get_code("51f18d348dec5cf5")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, happen2me/cross-gnn when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

GatedCrossAttentionBlock Ran
ran on a synthesized input · constructed an object; no result was computed
happen2me/cross-gnn/models/flamingo.py
pointer only (licence: NONE) · get_code("c8218f7ce578b5de")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, happen2me/cross-gnn when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MaskedCrossAttention Ran
ran on a synthesized input · constructed an object; no result was computed
happen2me/cross-gnn/models/flamingo.py
pointer only (licence: NONE) · get_code("00768fd117651888")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, happen2me/cross-gnn when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MaskedMultiHeadAttention Ran
ran on a synthesized input
doc-doc/NExT-OE/networks/q_v_transformer.py
code served (permissive licence) · get_code("cba160ad51d9b9c4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

class MaskedScaledDotProductAttention(nn.Module):
    """Scaled dot-product attention mechanism."""

    def __init__(self, attention_dropout=0.0):
        super().__init__()
        self.dropout = nn.Dropout(attention_dropout)
        self.softmax = nn.Softmax(dim=-1)

    def forward(self, q, k, v, scale=None, attn_mask=None, softmax_mask=None):
        """
        Args:
            q: [B, L_q, D_q]
            k: [B, L_k, D_k]
            v: [B, L_v, D_v]
        """
        attention = torch.matmul(q, k.transpose(-2, -1))
        if scale is not None:
            attention = attention * scale
        if attn_mask is not None:
            attention = attention.masked_fill(attn_mask, -np.inf)
        attention = self.softmax(attention)
        attention = attention.masked_fill(softmax_mask, 0.0)
        attention = self.dropout(attention)
        output = torch.matmul(attention, v)
        return (output, attention)

class MaskedMultiHeadAttention(nn.Module):

    def __init__(self, model_dim=512, num_heads=8, dropout=0.0):
        super().__init__()
        self.dim_per_head = model_dim // num_heads
        self.num_heads = num_heads
        self.linear_k = nn.Linear(model_dim, self.dim_per_head * num_heads, bias=False)
        self.linear_v = nn.Linear(model_dim, self.dim_per_head * num_heads, bias=False)
        self.linear_q = nn.Linear(model_dim, self.dim_per_head * num_heads, bias=False)
        self.dot_product_attention = MaskedScaledDotProductAttention(dropout)
        self.linear_final = nn.Linear(model_dim, model_dim, bias=False)
        self.dropout = nn.Dropout(dropout)
        self.layer_norm = nn.LayerNorm(model_dim, elementwise_affine=False)

    def forward(self, query, key, value, attn_mask=None, softmax_mask=None):
        residual = query
        dim_per_head = self.dim_per_head
        num_heads = self.num_heads
        batch_size = key.size(0)
        key = self.linear_k(key)
        value = self.linear_v(value)
        query = self.linear_q(query)
        key = key.view(batch_size, -1, num_heads, dim_per_head).transpose(1, 2)
        value = value.view(batch_size, -1, num_heads, dim_per_head).transpose(1, 2)
        query = query.view(batch_size, -1, num_heads, dim_per_head).transpose(1, 2)
        if attn_mask is not None:
            attn_mask = attn_mask.unsqueeze(1).repeat(1, num_heads, 1, 1)
        if softmax_mask is not None:
            softmax_mask = softmax_mask.unsqueeze(1).repeat(1, num_heads, 1, 1)
        scale = key.size(-1) ** (-0.5)
        context, attention = self.dot_product_attention(query, key, value, scale, attn_mask, softmax_mask)
        context = context.transpose(1, 2).contiguous().view(batch_size, -1, dim_per_head * num_heads)
        output = self.linear_final(context)
        output = self.dropout(output)
        output = self.layer_norm(residual + output)
        return (output, attention)


INIT_ARGS = {
    'model_dim': 8,
    'num_heads': 2,
    'dropout': 0.1,
}

ARGS = {
    'query': torch.randn(2, 3, 8),
    'key': torch.randn(2, 5, 8),
    'value': torch.randn(2, 5, 8),
    'attn_mask': torch.zeros(2, 3, 5, dtype=torch.bool),
    'softmax_mask': torch.zeros(2, 3, 5, dtype=torch.bool),
}

if __name__ == '__main__':
    model = MaskedMultiHeadAttention(**INIT_ARGS)
    output, attention = model(**ARGS)
    print("Output shape:", output.shape)
    print("Attention shape:", attention.shape)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
MaskedPositionalWiseFeedForward Ran
ran on a synthesized input · constructed an object; no result was computed
doc-doc/NExT-OE/networks/q_v_transformer.py
code served (permissive licence) · get_code("d09369fe81f54586")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, MaskedPositionalWiseFeedForward: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Construct a small input tensor for testing
# Shape: (batch_size=2, sequence_length=3, model_dim=4)
x = torch.randn(2, 3, 4)

# Define ARGS dictionary with all parameters for MaskedPositionalWiseFeedForward
ARGS = {
    "model_dim": 4,
    "ffn_dim": 8,
    "dropout": 0.1,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MaskedPositionalWiseFeedForward — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MaskedPositionalWiseFeedForward output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
MaskedScaledDotProductAttention Ran
ran on a synthesized input
doc-doc/NExT-OE/networks/q_v_transformer.py
code served (permissive licence) · get_code("3de90c17165b445d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

class MaskedScaledDotProductAttention(nn.Module):
    """Scaled dot-product attention mechanism."""

    def __init__(self, attention_dropout=0.0):
        super().__init__()
        self.dropout = nn.Dropout(attention_dropout)
        self.softmax = nn.Softmax(dim=-1)

    def forward(self, q, k, v, scale=None, attn_mask=None, softmax_mask=None):
        """
        Args:
            q: [B, L_q, D_q]
            k: [B, L_k, D_k]
            v: [B, L_v, D_v]
        """
        attention = torch.matmul(q, k.transpose(-2, -1))
        if scale is not None:
            attention = attention * scale
        if attn_mask is not None:
            attention = attention.masked_fill(attn_mask, -np.inf)
        attention = self.softmax(attention)
        attention = attention.masked_fill(softmax_mask, 0.0)
        attention = self.dropout(attention)
        output = torch.matmul(attention, v)
        return (output, attention)


INIT_ARGS = {
    'attention_dropout': 0.1
}

ARGS = {
    'q': torch.randn(2, 3, 4),
    'k': torch.randn(2, 3, 4),
    'v': torch.randn(2, 3, 5),
    'scale': 0.5,
    'attn_mask': torch.zeros(2, 3, 3, dtype=torch.bool),
    'softmax_mask': torch.zeros(2, 3, 3, dtype=torch.bool)
}

if __name__ == '__main__':
    model = MaskedScaledDotProductAttention(**INIT_ARGS)
    output, attention = model(**ARGS)
    print("Output shape:", output.shape)
    print("Attention shape:", attention.shape)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
PerceiverAttention Ran
ran on a synthesized input
mlfoundations/open_flamingo/open_flamingo/src/flamingo.py
code served (permissive licence) · get_code("65ec29626e592e07")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from einops import rearrange
from torch import nn, einsum
from einops_exts import rearrange_many

class PerceiverAttention(nn.Module):

    def __init__(self, *, dim, dim_head=64, heads=8):
        super().__init__()
        self.scale = dim_head ** (-0.5)
        self.heads = heads
        inner_dim = dim_head * heads
        self.norm_media = nn.LayerNorm(dim)
        self.norm_latents = nn.LayerNorm(dim)
        self.to_q = nn.Linear(dim, inner_dim, bias=False)
        self.to_kv = nn.Linear(dim, inner_dim * 2, bias=False)
        self.to_out = nn.Linear(inner_dim, dim, bias=False)

    def forward(self, x, latents):
        """
        Args:
            x (torch.Tensor): image features
                shape (b, T, n1, D)
            latent (torch.Tensor): latent features
                shape (b, T, n2, D)
        """
        x = self.norm_media(x)
        latents = self.norm_latents(latents)
        h = self.heads
        q = self.to_q(latents)
        kv_input = torch.cat((x, latents), dim=-2)
        k, v = self.to_kv(kv_input).chunk(2, dim=-1)
        q, k, v = rearrange_many((q, k, v), 'b t n (h d) -> b h t n d', h=h)
        q = q * self.scale
        sim = einsum('... i d, ... j d  -> ... i j', q, k)
        sim = sim - sim.amax(dim=-1, keepdim=True).detach()
        attn = sim.softmax(dim=-1)
        out = einsum('... i j, ... j d -> ... i d', attn, v)
        out = rearrange(out, 'b h t n d -> b t n (h d)', h=h)
        return self.to_out(out)


INIT_ARGS = {
    'dim': 4,
    'dim_head': 2,
    'heads': 2,
}

ARGS = {
    'x': torch.randn(2, 3, 5, 4),
    'latents': torch.randn(2, 3, 7, 4),
}

if __name__ == '__main__':
    model = PerceiverAttention(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: (2, 3, 7, 4)")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, einops_exts, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
PerceiverResampler Ran
ran on a synthesized input · constructed an object; no result was computed
mlfoundations/open_flamingo/open_flamingo/src/flamingo.py
code served (permissive licence) · get_code("d7676545407e647c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, PerceiverResampler: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from einops import rearrange, repeat
from einops_exts import rearrange_many

torch.manual_seed(0)

# Define ARGS dictionary with all parameters for PerceiverResampler
ARGS = {
    "dim": 4,
    "depth": 2,
    "dim_head": 2,
    "heads": 2,
    "num_latents": 3,
    "max_num_media": 5,
    "max_num_frames": 3,
    "ff_mult": 4
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, einops_exts, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PerceiverResampler — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a PerceiverResampler output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
PositionalEncoding Ran
ran on a synthesized input
doc-doc/NExT-OE/networks/q_v_transformer.py
code served (permissive licence) · get_code("07f824c36726e2e6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

class PositionalEncoding(nn.Module):

    def __init__(self, d_model, max_seq_len):
        super(PositionalEncoding, self).__init__()
        self.max_seq_len = max_seq_len
        position_encoding = np.array([[pos / np.power(10000, 2.0 * (j // 2) / d_model) for j in range(d_model)] for pos in range(max_seq_len)])
        position_encoding[:, 0::2] = np.sin(position_encoding[:, 0::2])
        position_encoding[:, 1::2] = np.cos(position_encoding[:, 1::2])
        pad_row = torch.zeros([1, d_model])
        position_encoding = torch.cat((pad_row, torch.from_numpy(position_encoding).float()))
        self.position_encoding = nn.Embedding(max_seq_len + 1, d_model)
        self.position_encoding.weight = nn.Parameter(position_encoding, requires_grad=False)

    def forward(self, input_len):
        max_len = self.max_seq_len
        tensor = torch.cuda.LongTensor if input_len.is_cuda else torch.LongTensor
        input_pos = [list(range(1, l + 1)) + [0] * (max_len - l.item()) for l in input_len]
        input_pos = tensor(input_pos)
        return self.position_encoding(input_pos)


INIT_ARGS = {
    'd_model': 8,
    'max_seq_len': 6
}

ARGS = {
    'input_len': torch.LongTensor([3, 5])
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
apply_rotary_pos_emb Ran
ran; our contract draft was wrong, not the code
lucidrains/flamingo-pytorch/flamingo_pytorch/flamingo_palm.py
code served (permissive licence) · get_code("fd592af960c2230e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from einops import rearrange

torch.manual_seed(0)

# Analyze the function signature and usage:
# - apply_rotary_pos_emb(pos, t)
# - pos: used with .cos() and .sin() methods, so it's a tensor
# - t: used in multiplication with pos.cos() and rotate_half(t)
# - rotate_half expects shape '... (j d) -> ... j d' with j=2
#   So the last dimension must be even

# Create pos tensor with shape allowing cos/sin and proper broadcasting
# Shape: (2, 4) - batch 2, embedding dim 4
pos = torch.randn(2, 4)

# Create t tensor with compatible shape
# Should have last dimension divisible by 2 for rotate_half
# Shape: (2, 4) - batch 2, embedding dim 4
t = torch.randn(2, 4)

ARGS = {
    "pos": pos,
    "t": t,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
exists Ran
ran, violated the contract we drafted
lucidrains/flamingo-pytorch/flamingo_pytorch/flamingo_palm.py
pointer only (licence: MIT); the stored copy get_code serves, from ThomasMrY/VCT, is pointer only (licence: NONE) · get_code("aa5486a3650902d8")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from ThomasMrY/VCT, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

padding_mask_k Ran
ran; our contract draft was wrong, not the code
doc-doc/NExT-OE/networks/q_v_transformer.py
code served (permissive licence) · get_code("784d83b86ef3420a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 5) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create seq_q with shape (batch=2, q_len=3, q_feat=4)
# Some values are 0 (padding), some are non-zero
seq_q = torch.tensor([
    [[1.0, 2.0, 3.0, 4.0],
     [1.0, 2.0, 3.0, 4.0],
     [0.0, 0.0, 0.0, 0.0]],
    [[1.0, 2.0, 3.0, 4.0],
     [0.0, 0.0, 0.0, 0.0],
     [0.0, 0.0, 0.0, 0.0]]
])

# Create seq_k with shape (batch=2, k_len=5, k_feat=4)
# Some values are 0 (padding), some are non-zero
seq_k = torch.tensor([
    [[1.0, 2.0, 3.0, 4.0],
     [1.0, 2.0, 3.0, 4.0],
     [1.0, 2.0, 3.0, 4.0],
     [0.0, 0.0, 0.0, 0.0],
     [0.0, 0.0, 0.0, 0.0]],
    [[1.0, 2.0, 3.0, 4.0],
     [1.0, 2.0, 3.0, 4.0],
     [0.0, 0.0, 0.0, 0.0],
     [0.0, 0.0, 0.0, 0.0],
     [0.0, 0.0, 0.0, 0.0]]
])

ARGS = {
    "seq_q": seq_q,
    "seq_k": seq_k
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 5) — shape (2, 3, 5) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
padding_mask_q Ran
ran; our contract draft was wrong, not the code
doc-doc/NExT-OE/networks/q_v_transformer.py
code served (permissive licence) · get_code("1d75807b764af41c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 5) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small tensors with distinct dimensions
# seq_q: (batch=2, q_len=3, q_feat=4)
# seq_k: (batch=2, k_len=5, k_feat=4)

seq_q = torch.randn(2, 3, 4)
seq_k = torch.randn(2, 5, 4)

# Set some rows to zero to create padding
seq_q[0, 2, :] = 0
seq_q[1, 1:, :] = 0
seq_k[0, 3:, :] = 0
seq_k[1, 4, :] = 0

ARGS = {
    "seq_q": seq_q,
    "seq_k": seq_k,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 5) — shape (2, 3, 5) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
rotate_half Ran
ran; our contract draft was wrong, not the code
lucidrains/flamingo-pytorch/flamingo_pytorch/flamingo_palm.py
code served (permissive licence) · get_code("fdd93453f92f9167")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from einops import rearrange, repeat

torch.manual_seed(0)

# The function rotate_half takes a single parameter 'x' which is a tensor
# It uses rearrange to reshape x into shape '... (j d) -> ... j d' with j=2
# This means the last dimension must be even (divisible by 2)
# Then it unbinds along dim=-2 and concatenates
# Let's create a small tensor with an even last dimension

x = torch.randn(2, 4)  # batch=2, last_dim=4 (even, so can be split into j=2, d=2)

ARGS = {
    'x': x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Flamingo Not yet run
unverified (harvested, no recorded run)
mlfoundations/open_flamingo/open_flamingo/src/flamingo.py
code served (permissive licence) · get_code("f908fc9abf51351f")
How it ran

no invocation recorded.

FlamingoDecoderBaseModel Not yet run
unverified (harvested, no recorded run)
happen2me/cross-gnn/models/flamingo.py
pointer only (licence: NONE) · get_code("ff5084867dff89f3")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, happen2me/cross-gnn when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

HijackedLMBlock Not yet run
unverified (harvested, no recorded run)
happen2me/cross-gnn/models/flamingo.py
pointer only (licence: NONE) · get_code("458a3153261db764")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, happen2me/cross-gnn when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

MaskedCrossoverTransformer Not yet run
unverified (harvested, no recorded run)
doc-doc/NExT-OE/networks/q_v_transformer.py
code served (permissive licence) · get_code("5dfb80e194f33d12")
How it ran

no invocation recorded.

MaskedCrossoverTransformerLayer Not yet run
unverified (harvested, no recorded run)
doc-doc/NExT-OE/networks/q_v_transformer.py
code served (permissive licence) · get_code("e75370a7c51938e8")
How it ran

no invocation recorded.

apply_with_stopping_condition Not yet run
unverified (harvested, no recorded run)
mlfoundations/open_flamingo/open_flamingo/src/flamingo.py
code served (permissive licence) · get_code("7709ecb3e78084fd")
How it ran

no invocation recorded.

Also present in other papers' code

Of 24 samples lifted from this paper's linked repositories, 24 carry a function identity and 0 do not. Of the 22 distinct functions with an identity, 13 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 3 the same month, 13 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
exists
brick of this paper's assembly: helper
486 other papers
90 dated earlier, 3 the same month, 390 later, 1 same year, order not determinable, 2 undated · 78 only as an assembly brick
1603.08155 (2016-03)
Perceptual Losses for Real-Time Style Transfer and Super-Resolution
1611.07004 (2016-11)
Image-to-Image Translation with Conditional Adversarial Networks
1804.04637 (2018-04)
EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models
and 483 more not named here
FeedForward
brick of this paper's assembly: helper
47 other papers
47 later · 4 only as an assembly brick
2308.02463 (2023-08)
Towards Generalist Foundation Model for Radiology by Leveraging Web-scale 2D&3D Medical Data
2308.06721 (2023-08)
IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models
2308.09905 (2023-08)
DiffusionTrack: Diffusion Model For Multi-Object Tracking
and 44 more not named here
rotate_half 13 other papers
3 dated earlier, 1 the same month, 9 later · 2 only as an assembly brick
2112.04426 (2021-12)
Improving language models by retrieving from trillions of tokens
2202.07765 (2022-02)
General-purpose, long-context autoregressive modeling with Perceiver AR
2203.07852 (2022-03)
Block-Recurrent Transformers
and 10 more not named here
padding_mask_k
brick of this paper's assembly: helper
4 other papers
1 dated earlier, 3 later · 1 only as an assembly brick
2105.08276 (2021-05)
NExT-QA: Next Phase of Question-Answering to Explaining Temporal Actions
2205.14895 (2022-05)
From Representation to Reasoning: Towards both Evidence and Commonsense Reasoning for Video Question-Answering
2206.02349 (2022-06)
Invariant Grounding for Video Question Answering
and 1 more not named here
padding_mask_q
brick of this paper's assembly: helper
4 other papers
1 dated earlier, 3 later · 1 only as an assembly brick
2105.08276 (2021-05)
NExT-QA: Next Phase of Question-Answering to Explaining Temporal Actions
2205.14895 (2022-05)
From Representation to Reasoning: Towards both Evidence and Commonsense Reasoning for Video Question-Answering
2206.02349 (2022-06)
Invariant Grounding for Video Question Answering
and 1 more not named here
PerceiverAttention
brick of this paper's assembly: helper
3 other papers
3 later · 1 only as an assembly brick
2402.10805 (2024-02)
Generative Cross-Modal Retrieval: Memorizing Images in Multimodal Language Models for Retrieval and Beyond
2503.02597 (2025-03)
Seeing is Understanding: Unlocking Causal Attention into Modality-Mutual Attention for Multimodal LLMs
2505.15816 (2025-05)
Streamline Without Sacrifice -Squeeze out Computation Redundancy in LMM
MaskedMultiHeadAttention
brick of this paper's assembly: model
2 other papers
2 later · 2 only as an assembly brick
2206.02349 (2022-06)
Invariant Grounding for Video Question Answering
2307.05222 (2023-07)
EMU: GENERATIVE PRETRAINING IN MULTIMODALITY
MaskedPositionalWiseFeedForward
brick of this paper's assembly: helper
2 other papers
2 later · 2 only as an assembly brick
2206.02349 (2022-06)
Invariant Grounding for Video Question Answering
2307.05222 (2023-07)
EMU: GENERATIVE PRETRAINING IN MULTIMODALITY
MaskedScaledDotProductAttention
brick of this paper's assembly: helper
2 other papers
2 later · 2 only as an assembly brick
2206.02349 (2022-06)
Invariant Grounding for Video Question Answering
2307.05222 (2023-07)
EMU: GENERATIVE PRETRAINING IN MULTIMODALITY
PositionalEncoding
brick of this paper's assembly: helper
2 other papers
2 later · 2 only as an assembly brick
2206.02349 (2022-06)
Invariant Grounding for Video Question Answering
2307.05222 (2023-07)
EMU: GENERATIVE PRETRAINING IN MULTIMODALITY
apply_rotary_pos_emb 2 other papers
1 the same month, 1 later
2204.02311 (2022-04)
PaLM: Scaling Language Modeling with Pathways
2302.04761 (2023-02)
Toolformer: Language Models Can Teach Themselves to Use Tools
MaskedCrossoverTransformer
brick of this paper's assembly: entry
1 other paper
1 later
2206.02349 (2022-06)
Invariant Grounding for Video Question Answering
MaskedCrossoverTransformerLayer
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2206.02349 (2022-06)
Invariant Grounding for Video Question Answering

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Building models that can be rapidly adapted to novel tasks using only a handful of annotated examples is an open challenge for multimodal machine learning research. We introduce Flamingo, a family of Visual Language Models (VLM) with this ability. We propose key architectural innovations to: (i) bridge powerful pretrained vision-only and language-only models, (ii) handle sequences of arbitrarily interleaved visual and textual data, and (iii) seamlessly ingest images or videos as inputs. Thanks to their flexibility, Flamingo models can be trained on large-scale multimodal web corpora containing arbitrarily interleaved text and images, which is key to endow them with in-context few-shot learning capabilities. We perform a thorough evaluation of our models, exploring and measuring their ability to rapidly adapt to a variety of image and video tasks. These include open-ended tasks such as visual question-answering, where the model is prompted with a question which it has to answer; captioning tasks, which evaluate the ability to describe a scene or an event; and close-ended tasks such as multiple-choice visual question-answering. For tasks lying anywhere on this spectrum, a single Flamingo model can achieve a new state of the art with few-shot learning, simply by prompting the model with task-specific examples. On numerous benchmarks, Flamingo outperforms models fine-tuned on thousands of times more task-specific data.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2204.14198")
get_code_for_paper("2204.14198")
have("2204.14198")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2204.14198.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2204.14198.svg)](https://syntology.ai/paper/2204.14198)

Connect an agent — have() is free.