Compare hidden_size, d_model, and embedding_dim, three names for the same thing or three different things?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Three names, one number. d_model (papers), hidden_size (HF config), embedding_dim (PyTorch nn.Embedding) all refer to the per-token residual-stream width.
Imagine three different stores selling the exact same product but with different labels: one calls it a 'large coffee', another 'a 16-ounce', the third 'one of the bigger sizes'. The drink is the same drink. d_model, hidden_size, and embedding_dim are like that, the same vector width, just named differently depending on whether you are reading a research paper, a Hugging Face config file, or PyTorch source code. The number behind all three labels is one quantity: how wide each token's vector is as it flows through the transformer.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
60s: state the three names refer to the same residual stream width, name where each is used (papers, HF config, PyTorch), explain why they must be equal (residual addition requires matching shapes), give a worked example (Llama-2 7B: 4096), distinguish from head_dim and intermediate_size which are different quantities.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating these as three different hyperparameters you can set independently. They are always the same value, the residual stream width must match the embedding output which must match every block's input.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.