passdrill
AI & LLM Engineering · How LLMs Work: Transformers & Training · Card 013/024 medium

In Section 3.4 of "Attention Is All You Need" (Vaswani et al., 2017), the authors describe sharing weights between two embedding layers and the pre-softmax linear transformation, then multiplying the embedding weights by the square root of the model dimension. What is the primary purpose of this weight-sharing scheme?

  1. It lets the encoder and decoder share the same set of self-attention weights, so a single set of query/key/value matrices is reused in every layer of the network
  2. It reduces the depth of the network by merging the final feed-forward sublayer directly into the output embedding matrix
  3. It ties the same learned matrix to both converting tokens into vectors and converting the decoder's final vectors back into vocabulary logits, reducing the total parameter count and linking the input and output token representations
  4. It guarantees that every possible output token receives an identical probability at initialization, which is later corrected during fine-tuning
Next card → Shuffle