N Neurarch Architectures Models Checks Data Docs Open the app

Architectures / Multimodal

๐Ÿช† Matryoshka Text Embedder

Kusupati et al. 2022 - one embedding model whose prefixes are independently usable, trained with InfoNCE on every prefix at once.

From Kusupati et al. (2022). Matryoshka Representation Learning. NeurIPS 2022. This page is the graph, not the PDF: open it, edit it, verify it, export it.

Layers
11
Parameters
54.74M
Input
1 ร— 512
Output
1 ร— 768
Verifier
Clean

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

Open Matryoshka Text Embedder on the canvas Free, no account needed

When to pick it

Pick when callers have different index budgets: truncate to 96 dimensions instead of training and serving a second, smaller model. Adds no parameters and no inference cost.

Structure

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

LayerTypeParametersOutput shape
1Text tokensInputshape=[1, 512]1 ร— 512
2Token EmbedEmbeddingvocabSize=305221 ร— 512 ร— 768
3Pos EncodingPositional EncodingmaxLen=5121 ร— 512 ร— 768
4Encoder Block 1Transformer BlockembedDim=768, numHeads=12, ffDim=30721 ร— 512 ร— 768
5Encoder Block 2Transformer BlockembedDim=768, numHeads=12, ffDim=30721 ร— 512 ร— 768
6Encoder Block 3Transformer BlockembedDim=768, numHeads=12, ffDim=30721 ร— 512 ร— 768
7Encoder Block 4Transformer BlockembedDim=768, numHeads=12, ffDim=30721 ร— 512 ร— 768
8PoolingAttention Pooling (PMA)numHeads=121 ร— 768
9Contrastive Head (InfoNCE)Contrastive Head (InfoNCE / CLIP)1 ร— 768
10Matryoshka (768/384/192/96/48)Matryoshka Head (MRL)embedDim=7681 ร— 768
11embedding (truncatable)Output1 ร— 768

What the verifier says

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

info9 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 AttentionPooling(nn.Module):
    """Pooling by Multihead Attention (Set Transformer's PMA). Learned seed
    vectors attend over the sequence, so the sequence axis is consumed and the
    pooling is learned rather than an unweighted mean."""

    def __init__(self, dim: int = 512, num_heads: int = 8, num_seeds: int = 1):
        super().__init__()
        self.seeds = nn.Parameter(torch.randn(num_seeds, dim) * 0.02)
        heads = num_heads if dim % num_heads == 0 else 1
        self.attn = nn.MultiheadAttention(dim, heads, batch_first=True)
        self.num_seeds = num_seeds

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        q = self.seeds.unsqueeze(0).expand(x.size(0), -1, -1)
        out = self.attn(q, x, x, need_weights=False)[0]
        return out.squeeze(-2) if self.num_seeds == 1 else out


class ContrastiveHead(nn.Module):
    """CLIP-style projection into the shared space: bias-free, L2-normalised,
    with the temperature as a learned parameter. After the normalisation a dot
    product is a cosine and is bounded, which is what makes the temperature
    mean anything."""

    def __init__(self, d_in: int, proj_dim: int = 512,
                 temperature: float = 0.07, learnable_temp: bool = True,
                 normalize: bool = True):
        super().__init__()
        self.proj = nn.Linear(d_in, proj_dim, bias=False)
        self.normalize = normalize
        scale = torch.tensor(float(1.0 / max(temperature, 1e-6))).log()
        self.logit_scale = nn.Parameter(scale) if learnable_temp else scale

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        z = self.proj(x)
        return F.normalize(z, dim=-1) if self.normalize else z

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
๐Ÿ”— ColBERT (Late Interaction Retrieval)
Khattab and Zaharia 2020 - the document keeps its tokens until scoring time
14 layers ยท 75.43M