Weight Tying Reuses the Token Embedding Matrix

Weight tying uses one parameter table for input row lookup and transposed vocabulary readout. Trace both directions, distinguish sharing from copied equality, and compare 368 tied with 400 untied parameters.

The token embedding maps vocabulary IDs to model-width records. Unembedding maps model-width records back to vocabulary logits. Because their shapes are transposes, one parameter table can serve both roles:

E:(V,dmodel),WU=E:(dmodel,V).E:(V,d_{model}),\qquad W_U=E^\top:(d_{model},V).

This is weight tying. The two operations use the same learned entries, not two matrices that merely happened to start equal.

Trace Both Directions

For token C, ID 3 selects row

EC=[0,0,0,1].E_C=[0,0,0,1].

At output, the same row acts as the vocabulary classifier vector for C:

zC=hEC.z_C=hE_C^\top.

An update to this shared row affects both future token lookups for C and the readout score assigned to C. Tying constrains parameterization; it does not force an input occurrence and an output score to have the same value.

Compare Parameter Counts

The embedding already contributes Vdmodel=32Vd_{model}=32 entries. An independent unembedding would add another dmodelV=32d_{model}V=32. Tying adds no second matrix.

For the frozen model:

  • tied total: 368 entries;
  • untied total: 368+32=400368+32=400 entries.

If an output bias were included, tying would not remove that separate vector. This model declares no output bias.

Equality Is Not Sharing

A useful audit changes one embedding entry and checks both lookup and output logits. If only one side changes, the implementation copied values instead of sharing the parameter. Serialization and optimizer state must also refer to one shared parameter rather than two independently updated arrays.

Weight tying was studied before Transformer language models. The mechanism transfers cleanly; empirical improvements remain tied to the models and tasks that were evaluated.

Q1. Count an untied readout

With V=8V=8 and dmodel=4d_{model}=4, how many additional entries does an untied unembedding matrix add?

Compute it first, then check your number.

Hint
Multiply model width by vocabulary size.
Solution
4×8=324\times8=32 additional entries.
Not attempted
Review

Not marked done.

References

Pause and reflect

In your own words, note what you understood, what remains unclear, or what you want to revisit. The note stays with this lesson.

0 of 1 exercises marked done

Review

Not marked done.

LLM PrimerWeight Tying Reuses the Token Embedding Matrixhttps://llmprimer.com/transformers/decoder-only-language-models/weight-tying-reuses-the-token-embedding-matrix© 2026 LLM Primer