Weight Tying › Key Parameters
Language AI HandbookAll chapters Weight Tying › Key ParametersOne section · Sections in this chapter13 / 15 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
When implementing weight tying in your models, these are the key configuration choices:
-
tie_weights(bool): Whether to share the embedding matrix between input and output. Set toTruefor most language models; set toFalsewhen input and output vocabularies differ or when fine-tuning models trained without tying. -
vocab_size(int): Size of the vocabulary. Larger vocabularies increase the parameter savings from tying. With 50K tokens, embedding matrices can dominate smaller models. With 128K tokens, the embedding fraction rises significantly even for medium-depth models. -
hidden_dimord_model(int): The embedding and hidden dimension. This determines both the embedding matrix size () and the scale factor () used for input scaling. -
embedding_scale(float): Scaling factor applied to input embeddings, typically . Apply this at forward time rather than modifying the weight matrix, in order to preserve unscaled embeddings for the output projection path. -
bias(bool): Whether to include a bias term in the output projection. Most implementations set this toFalsewhen using tied weights. A bias vector would add parameters and would not be shared, partially defeating the purpose of tying. -
tie_encoder_decoder(bool, encoder-decoder models only): Whether to also tie the encoder input embedding with the decoder embeddings. Recommended when source and target vocabularies are identical, as in T5 and other monolingual sequence-to-sequence models.