Skip-gram Model › Architecture: Two Embedding Matrices
Language AI HandbookAll chapters Skip-gram Model › Architecture: Two Embedding MatricesOne section · Sections in this chapter3 / 14 ↓
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
The Skip-gram architecture is a shallow neural network with one hidden layer and no nonlinear activation function. Its apparent simplicity is misleading, because all the meaningful computation happens in the weight matrices, not in any deep stacking of transformations.
The network contains three components:
- Input layer: A one-hot vector of dimension (vocabulary size), with a 1 at the index of the center word and 0 everywhere else.
- Hidden layer: A weight matrix of shape , where is the embedding dimension. Multiplying the one-hot input by selects the -dimensional row corresponding to the center word.
- Output layer: A second weight matrix of shape that projects the hidden vector back to vocabulary size, producing a score for every word.
After training, we discard the output matrix and use as our embedding lookup table. Each row of is the embedding for the corresponding word.
The absence of a nonlinear activation function between the input embedding lookup and the output scoring is intentional. Adding nonlinearities would make the model harder to optimize and would not obviously improve the quality of the learned representations. The linear structure means the model is essentially learning a bilinear scoring function between center word embeddings and context word embeddings, and the geometry of that scoring function is what creates the useful structure in the embedding space.
Input and Output Representations
One-hot encoding gives each word a unique, orthogonal representation. Word with vocabulary index is represented as a vector of length where and all other entries are 0. This is not a meaningful representation on its own; its purpose is purely to select a row from the embedding matrix.
Multiplying a one-hot vector by the embedding matrix is equivalent to selecting row :
where:
- : the hidden layer vector of dimension , which is the center word embedding
- : the input embedding matrix of shape
- : the one-hot input vector with a 1 at position
- : the -th row of , the embedding for input word
This selection operation is the key to Skip-gram's efficiency. We never multiply a full one-hot vector through a large matrix in practice. We simply look up a row. Because the one-hot vector is all zeros except at one position, the matrix multiplication collapses to a single row retrieval. Modern implementations store word embeddings in a dedicated Embedding lookup table, which is exactly this: a parameterized table where each row is a learnable vector, and integer indexing is used to retrieve the relevant row.
The output matrix of shape computes a score for each vocabulary word. For context word with vocabulary index , the score is:
where:
- : the unnormalized score (logit) for vocabulary word being a context word of
- : the -th column of , the context embedding of word
- : the center word embedding from the hidden layer
So every word has two vector representations: an input embedding (a row of ) used when the word is the center, and a context embedding (a column of ) used when it appears in someone else's context window. This dual representation is a fundamental design feature of Word2Vec. After training, you typically use the input embeddings () as the final word vectors, though some practitioners average both matrices, or use the context embeddings for specific downstream tasks.
Why Two Matrices?
The use of separate input and context matrices deserves explanation, because it might seem redundant at first. Why should the embedding for "fox" as a center word differ from its embedding as a context word?
The reason is flexibility and symmetry breaking. If we used the same matrix for both roles, the model would be constrained to treat each word as both predictor and predicted in a symmetric way. With separate matrices, the model can learn that "fox" as a center word needs to be good at pointing toward animal-related words in context space, while "fox" as a context word needs to be pointed to by sentences that often contain fox-relevant contexts. These are related but not identical requirements, and separate matrices allow the model to satisfy them independently.
This also has an interesting geometric consequence. If you compute the dot product , you are measuring how well word as center predicts word as context, which is not the same as asking whether as center predicts as context (that would be ). The model naturally handles asymmetric co-occurrence statistics this way.