N Neurarch Architectures Models Checks Data Docs Open the app

Architectures / Recommendation

๐Ÿฏ TIGER (Semantic ID Generative Retrieval)

NeurIPS 2023 - retrieval as sequence generation: the model DECODES the next item id code by code, so the catalogue never appears as a softmax over millions of rows.

From Rajput et al. (2023). Recommender Systems with Generative Retrieval. NeurIPS 2023. This page is the graph, not the PDF: open it, edit it, verify it, export it.

Layers
14
Parameters
1.05M
Input
1 ร— 200
Output
1 ร— 4 ร— 1024
Verifier
Clean

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

Open TIGER (Semantic ID Generative Retrieval) on the canvas Free, no account needed

When to pick it

Pick when the catalogue is too large for a dot-product retrieval head, or when cold-start items need to be reachable through their content. Pair with the RQ-VAE tokenizer.

Structure

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

LayerTypeParametersOutput shape
1History semantic IDs (50 items x 4 codes)Inputshape=[1, 200]1 ร— 200
2Code Embed (4 x 256 codebooks)EmbeddingvocabSize=10241 ร— 200 ร— 128
3Pos EncodingPositional EncodingmaxLen=2561 ร— 200 ร— 128
4Encoder Block 1Transformer BlocknumHeads=4, numLayers=11 ร— 200 ร— 128
5Encoder Block 2Transformer BlocknumHeads=4, numLayers=11 ร— 200 ร— 128
6Decoded codes so farInputshape=[1, 4]1 ร— 4
7Code Embed (shared)EmbeddingvocabSize=10241 ร— 4 ร— 128
8Pos EncodingPositional EncodingmaxLen=81 ร— 4 ร— 128
9Masked Self-AttentionCausal AttentionembedDim=128, numHeads=41 ร— 4 ร— 128
10Cross-Attention to historyCross-AttentionembedDim=128, numHeads=41 ร— 4 ร— 128
11Decoder FFNFeed ForwardembedDim=128, ffDim=5121 ร— 4 ร— 128
12LayerNormLayerNormnormalizedShape=1281 ร— 4 ร— 128
13Codebook Head (1024 codes)LM HeadhiddenSize=128, vocabSize=10241 ร— 4 ร— 1024
14next code logitsOutput1 ร— 4 ร— 1024

What the verifier says

The same 43 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 TIGERSemanticIDGenerativeRetrieval(nn.Module):
    def __init__(self):
        super().__init__()

        self.embedding_1 = nn.Embedding(1024, 128)
        self.transformerBlock_1 = nn.TransformerEncoderLayer(d_model=128, nhead=4, dim_feedforward=512, batch_first=True)
        self.transformerBlock_2 = nn.TransformerEncoderLayer(d_model=128, nhead=4, dim_feedforward=512, batch_first=True)
        self.embedding_2 = nn.Embedding(1024, 128)
        self.causalAttention_1 = nn.MultiheadAttention(embed_dim=128, num_heads=4, batch_first=True)
        self.crossAttention_1 = nn.MultiheadAttention(embed_dim=128, num_heads=4, batch_first=True)
        self.feedForward_1 = nn.Sequential(
            nn.Linear(128, 512),
            nn.ReLU(),
            nn.Linear(512, 128)
        )
        self.layerNorm_1 = nn.LayerNorm(128)
        self.lmHead_1 = nn.Linear(128, 1024, bias=False)

    def forward(self, src, tgt=None):
        # History semantic IDs (50 items x 4 codes) shape: [1,200]
        # Decoded codes so far shape: [1,4]
        embedding_nc_emb = self.embedding_1(src)
        # positionalEncoding: add positional encoding externally (e.g. sinusoidal or learned PE)
        transformer_block_enc1 = self.transformerBlock_1(embedding_nc_emb)
        transformer_block_enc2 = self.transformerBlock_2(transformer_block_enc1)
        embedding_ec_emb = self.embedding_2(tgt)
        # positionalEncoding: add positional encoding externally (e.g. sinusoidal or learned PE)
        causal_attention_c_self = self.causalAttention_1(embedding_ec_emb, embedding_ec_emb, embedding_ec_emb)[0]
        cross_attention_xattn = self.crossAttention_1(causal_attention_c_self, transformer_block_enc2, transformer_block_enc2)[0]
        feed_forward_dec_ff = self.feedForward_1(cross_attention_xattn)
        layer_norm_c_norm = self.layerNorm_1(feed_forward_dec_ff)
        lm_head_head = self.lmHead_1(layer_norm_c_norm)
        # Output
        return lm_head_head


if __name__ == '__main__':

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

๐Ÿ—ผ Two-Tower
User+Item dual encoder for retrieval โ€” embeddings โ†’ MLP per side โ†’ dot product score
15 layers ยท 70.44M
๐Ÿ“ 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 ยท 64.35M
๐Ÿค NeuMF (Fused GMF + MLP)
He et al
16 layers ยท 105.61M