Attention Warm-Start: Initializing Q/K from Bigram Co-occurrence SVD#678
Open
SPThole wants to merge 7 commits intoopenai:mainfrom
Open
Attention Warm-Start: Initializing Q/K from Bigram Co-occurrence SVD#678SPThole wants to merge 7 commits intoopenai:mainfrom
SPThole wants to merge 7 commits intoopenai:mainfrom
Conversation
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.
[NON RECORD] Only 1H100 Used: Summary
Initializes W_Q and W_K in layer 0 from bigram co-occurrence statistics via SVD, so the model's initial attention patterns reflect real token relationships rather than random noise. Zero extra parameters — only changes initialization.
Motivation
In a 600-second training window (~1100 steps), the model spends its first hundreds of steps learning basic token co-occurrence patterns that are trivially available from corpus statistics. By encoding this structure into the Q/K matrices at initialization, we give the model a head start on learning "which tokens should attend to which."
Method
C ← log(C+1), subtract row/column meansC_proj = P^T C P∈ R^{512×512}C_proj = UΣV^T, setW_Q ← (U · √Σ)^T,W_K ← (V^T · √Σ)so thatW_Q^T · W_K ≈ C_projTotal overhead: <3 seconds. Applied to layer 0 only (where hidden states ≈ embeddings).
Results
Built upon PR #623.
Observation
Slightly worse than the baseline without it (1.3345). The random projection P introduces noise that dilutes the co-occurrence signal. A tighter approach — using the actual embedding matrix E as the projection basis — could better preserve the structure. The principle of "warm-starting attention from corpus statistics" remains promising for short training regimes.
Test plan