Repository navigation
fix: initialize Gemma embeddings with std 0.02 - #206
Merged
Merged
Conversation
✅ Deploy Preview for trainite canceled.
|
aaishwarymishra
force-pushed
the
fix/gemma4-embedding-init
branch
from
October 24, 2026 17:30
4a68eab to
f215cd6
Compare
PyTorch's default N(0, 1) initialization becomes too large after Gemma's sqrt(hidden_size) embedding scale. With tied output weights, untrained models assign almost all probability to the input token. Use Gemma's initializer_range (0.02) and keep the padding row zeroed.
aaishwarymishra
force-pushed
the
fix/gemma4-embedding-init
branch
from
October 24, 2026 17:35
f215cd6 to
773b33d
Compare
TahaZahid05
approved these changes
Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gemma scales embeddings by
sqrt(hidden_size). PyTorch's defaultN(0, 1)initialization then makes tied logits predict the input token with near-100% probability in an untrained model.Initialize embeddings with
N(0, 0.02), matching Gemma'sinitializer_range, and keep the padding row zeroed.