๐Ÿ”ฅLimited Offer: Get 50% OFFon AI & Full Stack Courses๐Ÿ”ฅ
Back to Deep Learning Notes
Topic #264

Skip-Gram

Skip-Gram is Word2Vec's second architecture โ€” the mirror image of CBOW: instead of predicting a target word from its context, it predicts each surrounding context word individually, given the target word.

The Task, Concretely

Given the target word "brown" (from "the quick brown fox jumps," window size 2), skip-gram generates separate training examples predicting each of "the," "quick," "fox," and "jumps" individually โ€” one prediction task per context word, rather than CBOW's single averaged prediction.

Formula

\[ P(w_{t+j} \mid w_t) = \text{softmax}(\mathbf{W}_{\text{out}}\mathbf{e}_{w_t}) \qquad \text{for each } j \in \{-m,\ldots,-1,1,\ldots,m\} \]

The target word's own embedding \(\mathbf{e}_{w_t}\) is used directly (no averaging) to predict each surrounding context word's probability, one at a time.

Diagram

"brown" the quick fox jumps

The target word independently predicts each context word โ€” generating multiple separate training examples per window, unlike CBOW's single averaged one.

CBOW vs Skip-Gram โ€” Direct Comparison

CBOWSkip-Gram
PredictsTarget word from contextContext words from target
Training examples per windowOne (averaged)Multiple (one per context word)
Training speedFasterSlower
Performance on rare wordsWeaker โ€” rare words get "averaged out" alongside common onesStronger โ€” each rare word gets its own dedicated training examples as a target
Best suited toLarger datasets, faster iterationTasks where rare-word quality matters

Code

from gensim.models import Word2Vec

sentences = [["the", "quick", "brown", "fox", "jumps"],
             ["the", "lazy", "dog", "sleeps"]]

model = Word2Vec(sentences, vector_size=100, window=2, sg=1)   # sg=1 selects skip-gram specifically
print(model.wv.most_similar("fox"))

Common Mistakes

  • Assuming skip-gram is strictly "better" than CBOW in every case โ€” CBOW's speed advantage and reasonable performance on common words make it a genuinely sensible choice when training data is very large and rare-word quality matters less.
  • Confusing the direction of prediction between the two โ€” a quick way to remember: CBOW predicts one word from many (bag of context words); skip-gram predicts many words from one (skips outward from the target).

Interview Relevance

Q: "Why does skip-gram typically produce better embeddings for rare words than CBOW?" In CBOW, a rare word appearing as part of the averaged context gets its individual signal diluted/blended together with the other, often more common, context words in that same window. In skip-gram, a rare word used as the target word directly generates its own dedicated training examples for each surrounding context word, giving it more focused, individual training signal.

Practice Question

For the target word "guitar" in "she plays guitar well," with window size 1, how many separate training examples would skip-gram generate from this one window?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course โ€” live mentorship, real projects, and 100% placement support.

Enroll Now โ€” Free Demo Available

Skip-Gram โ€“ FAQs

Quick answers about learning Skip-Gram in Deep Learning.

This free note from CodingNow 2.0 explains Skip-Gram in Deep Learning โ€” concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including Skip-Gram, is 100% free with no signup required.
With focused practice, most students grasp Skip-Gram in 1โ€“3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) โ€” expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now