N Neurarch Architectures Checks Docs Open the app

Architectures / NLP/LLM

๐Ÿ” T5 Small

T5 encoder-decoder โ€” bidirectional encoder + masked decoder with cross-attention (512D, 8 heads)

Layers
23
Parameters
56.73M
Input
1 ร— 512
Output
1 ร— 128 ร— 32128
Verifier
1 advisory

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

Open T5 Small on the canvas Free, no account needed

When to pick it

Pick for seq2seq tasks (summarization, translation, QA) where you need both bidirectional understanding and generation in one model.

Structure

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

LayerTypeParametersOutput shape
1encoder_idsInputshape=[1, 512]1 ร— 512
2shared_embedEmbedding1 ร— 512 ร— 512
3enc_normRMSNormnormalizedShape=5121 ร— 512 ร— 512
4enc_self_attnMulti-Head AttentionembedDim=512, numHeads=81 ร— 512 ร— 512
5enc_residualAdd1 ร— 512 ร— 512
6enc_ffn_normRMSNormnormalizedShape=5121 ร— 512 ร— 512
7enc_ffnFeed ForwardembedDim=512, ffDim=20481 ร— 512 ร— 512
8enc_ffn_residualAdd1 ร— 512 ร— 512
9enc_out_normLayerNormnormalizedShape=5121 ร— 512 ร— 512
10decoder_idsInputshape=[1, 128]1 ร— 128
11dec_embedEmbedding1 ร— 128 ร— 512
12dec_sa_normRMSNormnormalizedShape=5121 ร— 128 ร— 512
13dec_self_attnCausal AttentionembedDim=512, numHeads=81 ร— 128 ร— 512
14dec_sa_residualAdd1 ร— 128 ร— 512
15dec_ca_normRMSNormnormalizedShape=5121 ร— 128 ร— 512
16cross_attnMulti-Head AttentionembedDim=512, numHeads=81 ร— 128 ร— 512
17dec_ca_residualAdd1 ร— 128 ร— 512
18dec_ffn_normRMSNormnormalizedShape=5121 ร— 128 ร— 512
19dec_ffnFeed ForwardembedDim=512, ffDim=20481 ร— 128 ร— 512
20dec_ffn_residualAdd1 ร— 128 ร— 512
21dec_out_normLayerNormnormalizedShape=5121 ร— 128 ร— 512
22lm_headLinearoutFeatures=321281 ร— 128 ร— 32128
23logitsOutput1 ร— 128 ร— 32128

What the verifier says

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

warn3 attention layer(s) present but no positional encoding found. Attention is permutation-invariant, without position information the model cannot distinguish token order. Fix: Add a PositionalEncoding (sinusoidal) or RoPE layer before the first attention layer. (enc_self_attn)
attention-no-pe

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 T5Small(nn.Module):
    def __init__(self):
        super().__init__()

        self.embedding_1 = nn.Embedding(32128, 512)
        self.rmsNorm_1 = nn.RMSNorm(512)
        self.multiHeadAttention_1 = nn.MultiheadAttention(embed_dim=512, num_heads=8, batch_first=True)
        self.rmsNorm_2 = nn.RMSNorm(512)
        self.feedForward_1 = nn.Sequential(
            nn.Linear(512, 2048),
            nn.ReLU(),
            nn.Linear(2048, 512)
        )
        self.layerNorm_1 = nn.LayerNorm(512)
        self.embedding_2 = nn.Embedding(32128, 512)
        self.rmsNorm_3 = nn.RMSNorm(512)
        self.causalAttention_1 = nn.MultiheadAttention(embed_dim=512, num_heads=8, batch_first=True)
        self.rmsNorm_4 = nn.RMSNorm(512)
        self.multiHeadAttention_2 = nn.MultiheadAttention(embed_dim=512, num_heads=8, batch_first=True)
        self.rmsNorm_5 = nn.RMSNorm(512)
        self.feedForward_2 = nn.Sequential(
            nn.Linear(512, 2048),
            nn.ReLU(),
            nn.Linear(2048, 512)
        )
        self.layerNorm_2 = nn.LayerNorm(512)
        self.linear_1 = nn.Linear(512, 32128)

    def forward(self, src, tgt=None):
        # encoder_ids shape: [1,512]
        # decoder_ids shape: [1,128]
        embedding_ng_enc = self.embedding_1(src)
        rms_norm_rm_enc = self.rmsNorm_1(embedding_ng_enc)
        multi_head_attention_ha_enc = self.multiHeadAttention_1(rms_norm_rm_enc, rms_norm_rm_enc, rms_norm_rm_enc)[0]
        add_dd_enc = multi_head_attention_ha_enc
        rms_norm_m_enc2 = self.rmsNorm_2(add_dd_enc)
        feed_forward_rd_enc = self.feedForward_1(rms_norm_m_enc2)

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
๐Ÿ“– BERT Base
BERT-Base encoder โ€” bidirectional MHA
11 layers ยท 31.12M
๐Ÿง  GPT-2
GPT-2 Small โ€” causal transformer block
12 layers ยท 84.33M
๐Ÿฆ™ LLaMA-3 Block
LLaMA-3 decoder block โ€” GQA
10 layers ยท 702.55M