N Neurarch Architectures Checks Docs Open the app

Architectures / NLP/LLM

๐Ÿ“– BERT Base

BERT-Base encoder โ€” bidirectional MHA (12 heads, 768D), no causal mask, 30K vocab

Layers
11
Parameters
31.12M
Input
1 ร— 512
Output
1 ร— 512 ร— 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 BERT Base on the canvas Free, no account needed

When to pick it

Pick for text classification / NLU with limited labels โ€” pretrained encoder + small head fine-tunes reliably. 512-token cap.

Structure

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

LayerTypeParametersOutput shape
1input_idsInputshape=[1, 512]1 ร— 512
2word_embedEmbedding1 ร— 512 ร— 768
3pos_embedPositional EncodingembedDim=768, maxLen=5121 ร— 512 ร— 768
4embed_normLayerNormnormalizedShape=7681 ร— 512 ร— 768
5embed_dropDropoutp=0.11 ร— 512 ร— 768
6self_attnMulti-Head AttentionembedDim=768, numHeads=121 ร— 512 ร— 768
7normLayerNormnormalizedShape=7681 ร— 512 ร— 768
8denseFeed ForwardembedDim=768, ffDim=30721 ร— 512 ร— 768
9normLayerNormnormalizedShape=7681 ร— 512 ร— 768
10denseLinearoutFeatures=768, inFeatures=7681 ร— 512 ร— 768
11cls_embeddingOutput1 ร— 512 ร— 768

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)

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

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

        self.embedding_1 = nn.Embedding(30522, 768)
        self.layerNorm_1 = nn.LayerNorm(768)
        self.dropout_1 = nn.Dropout(p=0.1)
        self.multiHeadAttention_1 = nn.MultiheadAttention(embed_dim=768, num_heads=12, batch_first=True)
        self.layerNorm_2 = nn.LayerNorm(768)
        self.feedForward_1 = nn.Sequential(
            nn.Linear(768, 3072),
            nn.ReLU(),
            nn.Linear(3072, 768)
        )
        self.layerNorm_3 = nn.LayerNorm(768)
        self.linear_1 = nn.Linear(768, 768)

    def forward(self, x):
        # input_ids shape: [1,512]
        embedding_ng_tok = self.embedding_1(x)
        # positionalEncoding: add positional encoding externally (e.g. sinusoidal or learned PE)
        layer_norm_rm_emb = self.layerNorm_1(embedding_ng_tok)
        dropout_ut_emb = self.dropout_1(layer_norm_rm_emb)
        multi_head_attention_mha_1 = self.multiHeadAttention_1(dropout_ut_emb, dropout_ut_emb, dropout_ut_emb)[0]
        layer_norm_Norm_1 = self.layerNorm_2(multi_head_attention_mha_1)
        feed_forward_ward_1 = self.feedForward_1(layer_norm_Norm_1)
        layer_norm_Norm_2 = self.layerNorm_3(feed_forward_ward_1)
        linear_r_pool = self.linear_1(layer_norm_Norm_2)
        # Output
        return linear_r_pool


if __name__ == '__main__':
    model = BERTBase()
    model.eval()

    x = torch.randint(0, 50000, (1, 512))  # (batch, features)

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 NLP/LLM

๐Ÿค– Transformer Block
Transformer encoder block
8 layers ยท 7.09M
๐Ÿง  GPT-2
GPT-2 Small โ€” causal transformer block
12 layers ยท 84.33M
๐Ÿฆ™ LLaMA-3 Block
LLaMA-3 decoder block โ€” GQA
10 layers ยท 702.55M
๐Ÿ”€ Mixtral MoE Block
Mixtral decoder block โ€” GQA + Sparse MoE
9 layers ยท 1.45B