What is the skip-gram model?
Skip-gram is the word2vec architecture that predicts the surrounding words from a single center word. Each (center, context) pair inside a sliding window is one training example, and the model adjusts the center word's vector until it scores its real neighbors highly. In practice it is trained with negative sampling, a cheap stand-in for the full softmax.
Skip-gram with negative sampling (SGNS) is the most widely used word2vec setup and produces strong vectors for rare words. The same recipe works on any sequence of tokens: DeepWalk and node2vec apply it to random walks on graphs, and recommender systems apply it to sequences of products or songs to learn item embeddings. Its training tricks, negative sampling and frequent-word subsampling, show up again in later contrastive learning methods.
Key ideas
- Skip-gram predicts each context word separately from the center word.
- Every word has an input vector and an output vector; the input vectors are kept as embeddings.
- A full softmax costs one dot product per vocabulary word for every training pair.
- Negative sampling turns each prediction into k + 1 binary logistic decisions.
- Subsampling discards frequent words with probability 1 − √(t / f(w)).
- Skip-gram is slower than CBOW but learns better vectors for rare words.
Common questions
Why is it called skip-gram?
The name comes from skip-grams in language modeling: n-grams that allow gaps, so "the mat" counts as a pair in "the cat sat on the mat" even with words between them. Pairing a center word with every word in its window, near or far, is the same idea.
What does SGNS mean?
SGNS stands for skip-gram with negative sampling, the combination that most word2vec implementations use by default when skip-gram is selected. The term is common in research papers that compare word2vec with count-based methods.
Can skip-gram learn vectors for phrases?
Yes. The second 2013 paper first finds word pairs that occur together far more often than chance, such as "New York" or "Air Canada", and merges them into single tokens. Skip-gram then learns one vector per phrase, which helps where the phrase means more than its parts.
Is skip-gram used outside of text?
Yes. Any data that comes as sequences of discrete items works. DeepWalk and node2vec generate random walks on a graph and train skip-gram on them to embed nodes, and music and e-commerce recommenders train it on listening or browsing sessions to embed songs and products.
Related explainers
- Word2Vec & Word Embeddings — Learn dense vector representations where similar words live near each other in space
- CBOW (Continuous Bag of Words) — Predict the center word from its context — the averaging architecture behind Word2Vec
- Embeddings — Turning words and categories into vectors
- Softmax, Logits & Temperature — Turning raw scores into probabilities
- Probability & Distributions — Spam, densities, and the math of uncertainty
- Learning Rate Scheduling — Step decay, cosine annealing, warmup, and the LR range test
References
- Mikolov et al. (2013), "Distributed Representations of Words and Phrases and their Compositionality", NeurIPS
- Mikolov et al. (2013), "Efficient Estimation of Word Representations in Vector Space"
- Goldberg & Levy (2014), "word2vec Explained: Deriving Mikolov et al.'s Negative-Sampling Word-Embedding Method"
- Rong (2014), "word2vec Parameter Learning Explained"
Last updated