N Neurarch Architectures Checks Docs Open the app

Architectures / Recommendation

๐Ÿ—ผ Two-Tower

User+Item dual encoder for retrieval โ€” embeddings โ†’ MLP per side โ†’ dot product score

Layers
12
Parameters
70.43M
Input
1
Output
1 ร— 64
Verifier
Clean

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

Open Two-Tower on the canvas Free, no account needed

When to pick it

Pick for retrieval at scale (billions of items) where item embeddings can be precomputed and indexed. Not suitable for re-ranking โ€” no cross-features.

Structure

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

LayerTypeParametersOutput shape
1User InputInputshape=[1]1
2User EmbedEmbeddingvocabSize=1000001 ร— 64
3User FC 1LinearoutFeatures=128, inFeatures=641 ร— 128
4User ReLUReLU1 ร— 128
5User Tower OutLinearoutFeatures=64, inFeatures=1281 ร— 64
6Item InputInputshape=[1]1
7Item EmbedEmbeddingvocabSize=10000001 ร— 64
8Item FC 1LinearoutFeatures=128, inFeatures=641 ร— 128
9Item ReLUReLU1 ร— 128
10Item Tower OutLinearoutFeatures=64, inFeatures=1281 ร— 64
11Dot ScoreMatMul1 ร— 64
12ScoreOutput1 ร— 64

What the verifier says

The same 41 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)
#
# WARNING: 1 layer(s) below are not yet supported by the PyTorch
# exporter and pass their input through UNCHANGED in forward():
#   - Dot Score (matmul)

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

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

        self.embedding_1 = nn.Embedding(100000, 64)
        self.linear_1 = nn.Linear(64, 128)
        self.linear_2 = nn.Linear(128, 64)
        self.embedding_2 = nn.Embedding(1000000, 64)
        self.linear_3 = nn.Linear(64, 128)
        self.linear_4 = nn.Linear(128, 64)

    def forward(self, src, tgt=None):
        # User Input shape: [1]
        # Item Input shape: [1]
        embedding_er_emb = self.embedding_1(src)
        linear_er_fc1 = self.linear_1(embedding_er_emb)
        relu_r_relu = F.relu(linear_er_fc1)
        linear_er_fc2 = self.linear_2(relu_r_relu)
        embedding_em_emb = self.embedding_2(tgt)
        linear_em_fc1 = self.linear_3(embedding_em_emb)
        relu_m_relu = F.relu(linear_em_fc1)
        linear_em_fc2 = self.linear_4(relu_m_relu)
        # TODO: layer 'Dot Score' (matmul) is not yet supported by the exporter; passing through unchanged
        # Output
        return linear_er_fc2


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

    src = torch.randint(0, 1, (1))  # (batch, src_seq_len)
    tgt = torch.randint(0, 1, (1))  # (batch, tgt_seq_len)

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 Recommendation

๐Ÿ“ Wide & Deep
Memorization
13 layers ยท 3.65M
๐Ÿ›’ DLRM
Meta's Deep Learning Recommendation Model โ€” bottom MLP for dense, embedding for sparse, feature interaction, top MLP
14 layers ยท 32.35M
๐Ÿค Neural Collaborative Filtering
He et al
16 layers ยท 105.61M
๐Ÿ•ธ GraphSAGE Recommender
Inductive node embeddings via neighbor sampling + aggregation โ€” for graph-based recommenders
10 layers ยท 263.0K