N Neurarch Architectures Checks Docs Open the app

Architectures / Multimodal

๐Ÿ”— CLIP ViT-B/32

Dual-encoder contrastive model โ€” a ViT image tower and a Transformer text tower projected into a shared embedding space (OpenAI 2021)

Layers
38
Parameters
151.20M
Input
3 ร— 224 ร— 224
Output
512
Verifier
Clean

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

Open CLIP ViT-B/32 on the canvas Free, no account needed

When to pick it

Pick to study cross-modal retrieval / zero-shot classification. Two parallel encoders meet at a contrastive similarity head.

Structure

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

LayerTypeParametersOutput shape
1imageInputshape=[3, 224, 224]3 ร— 224 ร— 224
2patch_embedPatch EmbedembedDim=768, patchSize=3249 ร— 768
3vis_posPositional EncodingembedDim=768, maxLen=5049 ร— 768
4vis_block_1Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
5vis_block_2Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
6vis_block_3Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
7vis_block_4Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
8vis_block_5Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
9vis_block_6Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
10vis_block_7Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
11vis_block_8Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
12vis_block_9Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
13vis_block_10Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
14vis_block_11Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
15vis_block_12Transformer BlockembedDim=768, numHeads=12, ffDim=307249 ร— 768
16vis_normLayerNormnormalizedShape=76849 ร— 768
17vis_poolGlobalAvgPool1D49
18img_projLinearoutFeatures=512, inFeatures=768512
19tokensInputshape=[1, 77]1 ร— 77
20tok_embedEmbedding1 ร— 77 ร— 512
21txt_posPositional EncodingembedDim=512, maxLen=771 ร— 77 ร— 512
22txt_block_1Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
23txt_block_2Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
24txt_block_3Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
25txt_block_4Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
26txt_block_5Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
27txt_block_6Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
28txt_block_7Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
29txt_block_8Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
30txt_block_9Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
31txt_block_10Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
32txt_block_11Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
33txt_block_12Transformer BlockembedDim=512, numHeads=8, ffDim=20481 ร— 77 ร— 512
34txt_normLayerNormnormalizedShape=5121 ร— 77 ร— 512
35txt_poolGlobalAvgPool1D1
36txt_projLinearoutFeatures=512, inFeatures=512512
37similarityMatMul512
38logitsOutput512

What the verifier says

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

No finding. Shapes propagate end to end, every divisibility condition holds, and no advisory rule fires. See the checks.

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)
#
# WARNING: 3 layer(s) below are not yet supported by the PyTorch
# exporter and pass their input through UNCHANGED in forward():
#   - vis_pool (globalAvgPool1d)
#   - txt_pool (globalAvgPool1d)
#   - similarity (matmul)

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

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

        self.patchEmbed_1 = nn.Conv2d(3, 768, kernel_size=32, stride=32)  # Patch embedding (ViT-style)
        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.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.transformerBlock_5 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_6 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_7 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_8 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_9 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_10 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_11 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.transformerBlock_12 = nn.TransformerEncoderLayer(d_model=768, nhead=12, dim_feedforward=3072, batch_first=True)
        self.layerNorm_1 = nn.LayerNorm(768)
        self.linear_1 = nn.Linear(768, 512)
        self.embedding_1 = nn.Embedding(49408, 512)
        self.transformerBlock_13 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_14 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_15 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_16 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_17 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_18 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_19 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_20 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_21 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_22 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)
        self.transformerBlock_23 = nn.TransformerEncoderLayer(d_model=512, nhead=8, dim_feedforward=2048, batch_first=True)

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

๐Ÿ‘๏ธ LLaVA-1.5
Vision-language model โ€” CLIP image encoder + MLP projector feed visual tokens into a LLaMA decoder
229 layers ยท 7.06B