N Neurarch Architectures Models Checks Data Docs Open the app

Architectures / Multimodal

๐Ÿ”— ColBERT (Late Interaction Retrieval)

Khattab and Zaharia 2020 - the document keeps its tokens until scoring time. Each query token takes its best-matching document token and those maxima are summed.

From Khattab and Zaharia (2020). ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT. SIGIR 2020. This page is the graph, not the PDF: open it, edit it, verify it, export it.

Layers
14
Parameters
75.43M
Input
1 ร— 32
Output
1
Verifier
Clean

Every number on this page is computed from the graph by the same functions the app runs, not written by hand.

Open ColBERT (Late Interaction Retrieval) on the canvas Free, no account needed

When to pick it

Pick when one vector per document loses too much and a cross-encoder is too slow. Costs a query-by-document matrix per candidate and an index many times larger, so pair it with a cheap first stage.

Structure

14 layers. Output shapes are propagated from the input shape, batch dimension excluded.

LayerTypeParametersOutput shape
1Query tokensInputshape=[1, 32]1 ร— 32
2Token EmbedEmbeddingvocabSize=305221 ร— 32 ร— 768
3Pos EncodingPositional EncodingmaxLen=5121 ร— 32 ร— 768
4Query Encoder 1Transformer BlockembedDim=768, numHeads=12, ffDim=30721 ร— 32 ร— 768
5Query Encoder 2Transformer BlockembedDim=768, numHeads=12, ffDim=30721 ร— 32 ร— 768
6Down-project to 128LinearoutFeatures=128, inFeatures=7681 ร— 32 ร— 128
7Document tokensInputshape=[1, 180]1 ร— 180
8Token Embed (shared)EmbeddingvocabSize=305221 ร— 180 ร— 768
9Pos EncodingPositional EncodingmaxLen=5121 ร— 180 ร— 768
10Doc Encoder 1Transformer BlockembedDim=768, numHeads=12, ffDim=30721 ร— 180 ร— 768
11Doc Encoder 2Transformer BlockembedDim=768, numHeads=12, ffDim=30721 ร— 180 ร— 768
12Down-project to 128LinearoutFeatures=128, inFeatures=7681 ร— 180 ร— 128
13MaxSimLate Interaction (ColBERT MaxSim)embedDim=1281
14relevance scoreOutput1

What the verifier says

The same 43 structural checks that run on every edit in the app, on this graph.

info11 layers with no BatchNorm, LayerNorm, or GroupNorm. Without normalization, activations can explode or vanish across layers, causing slow or unstable training. Fix: Add BatchNorm after Conv2d (CV tasks), LayerNorm after attention/FFN (NLP/LLM), or GroupNorm for small batch sizes.
deep-no-norm

The PyTorch it exports

Generated from the graph above. First 46 lines; the app exports the whole file, plus the training loop, the data contract and a deploy bundle.

# Architecture designed with Neurarch: https://neurarch.com
# PyTorch: compatible with Python 3.8+ and torch>=1.12
# Colab: pip install torch torchvision  (usually pre-installed)

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple

class LateInteraction(nn.Module):
    """ColBERT MaxSim: the best-matching document token for each query token,
    summed. Both sequence axes are consumed and one score comes out. The
    document keeps its tokens until scoring time, which is the whole difference
    from a single-vector retriever, and also the whole cost."""

    def __init__(self, embed_dim: int = 128, similarity: str = "cosine"):
        super().__init__()
        self.embed_dim = embed_dim
        self.similarity = similarity

    def forward(self, query: torch.Tensor, doc=None) -> torch.Tensor:
        if doc is None:
            doc = query
        q, d = query, doc
        if self.similarity == "cosine":
            q, d = F.normalize(q, dim=-1), F.normalize(d, dim=-1)
        sim = q @ d.transpose(-1, -2)          # [.., Lq, Ld]
        return sim.max(dim=-1).values.sum(dim=-1, keepdim=True)


class ColBERTLateInteractionRetrieval(nn.Module):
    def __init__(self):
        super().__init__()

        self.embedding_1 = nn.Embedding(30522, 768)
        self.transformerBlock_1 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_2 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.linear_1 = nn.Linear(768, 128)
        self.embedding_2 = nn.Embedding(30522, 768)
        self.transformerBlock_3 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_4 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.linear_2 = nn.Linear(768, 128)
        self.lateInteraction_1 = LateInteraction(embed_dim=128, similarity="cosine")

    def forward(self, src, tgt=None):
        # Query tokens shape: [1,32]

For agents

This architecture is machine-readable end to end. An agent can list the set, fetch this graph, edit it, and have the edit verified before any GPU time is spent.

Also in Multimodal

๐Ÿ”— CLIP ViT-B/32
Dual-encoder contrastive model โ€” a ViT image tower and a Transformer text tower projected into a shared embedding space
40 layers ยท 151.20M
๐Ÿ‘๏ธ LLaVA-1.5
Vision-language model โ€” CLIP image encoder + MLP projector feed visual tokens into a LLaMA decoder
229 layers ยท 7.06B
๐Ÿงฑ Qwen2-VL (Native-Resolution VLM)
Wang et al
15 layers ยท 1.55B
๐Ÿช† Matryoshka Text Embedder
Kusupati et al
11 layers ยท 54.74M