Negative Sampling › The Sampling Distribution: Why
Language AI HandbookAll chapters Negative Sampling › The Sampling Distribution: WhyOne section · Sections in this chapter5 / 15 ↓
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 choice of how to sample negative words turns out to be surprisingly consequential. A naive approach might sample words uniformly at random. But consider what happens: "the" appears in nearly every sentence, yet with uniform sampling it would be drawn as a negative in only of cases. Meanwhile, "aardvark" appears rarely in real text but would be sampled just as often as "the."
This mismatch creates problems. Common function words occur near almost every word in the corpus, so sampling them as negatives is confusing because they are often legitimate context words too. Rare words sampled too often as negatives cause the model to push everything away from them, hurting their embedding quality.
The Word2Vec authors discovered that a modified unigram distribution works best:
where:
- : probability of sampling word as a negative sample
- : frequency (count) of word in the corpus
- : the frequency raised to the power 0.75, which compresses the range
- : normalizing constant summing over all vocabulary words
- : smoothing exponent determined empirically by the Word2Vec authors
The key insight is that raising to a power less than 1 compresses the range of values. If word A appears 10,000 times and word B appears 10 times, their raw frequency ratio is 1000:1. After applying the 0.75 exponent, . The ratio shrinks from 1000:1 to about 178:1, boosting the representation of rare words without ignoring frequency entirely.
def create_sampling_distribution(word_counts, alpha=0.75):
"""
Create the negative sampling distribution using smoothed unigram frequencies.
Args:
word_counts: Dictionary mapping words to their corpus frequencies
alpha: Exponent to smooth the distribution (default 0.75)
Returns:
words: List of words
probs: Sampling probabilities
"""
words = list(word_counts.keys())
freqs = np.array([word_counts[w] for w in words], dtype=np.float64)
smoothed = freqs**alpha
probs = smoothed / smoothed.sum()
return words, probs
# Example corpus frequencies
word_frequencies = {
"the": 100000,
"a": 80000,
"is": 50000,
"word": 1000,
"embedding": 500,
"neural": 400,
"semantic": 200,
"vector": 800,
"aardvark": 5,
"quixotic": 2,
}
words, probs = create_sampling_distribution(word_frequencies, alpha=0.75)Comparison of Sampling Distributions: ----------------------------------------------------------------- Word Raw Freq Uniform Freq Prob Smoothed ----------------------------------------------------------------- the 100,000 0.1000 0.429356 0.393092 a 80,000 0.1000 0.343485 0.332516 is 50,000 0.1000 0.214678 0.233734 word 1,000 0.1000 0.004294 0.012431 embedding 500 0.1000 0.002147 0.007391 neural 400 0.1000 0.001717 0.006252 semantic 200 0.1000 0.000859 0.003718 vector 800 0.1000 0.003435 0.010515 aardvark 5 0.1000 0.000021 0.000234 quixotic 2 0.1000 0.000009 0.000118 Sum of smoothed probs: 1.0000
The comparison shows how smoothing redistributes probability mass. Common words like "the" drop from dominating the distribution (raw frequency ~43%) to a more moderate share. Rare words like "aardvark" and "quixotic" see their sampling probability increase relative to their raw frequency. This ensures they receive adequate training signal.



Why 0.75? Intuition and Alternatives
The exponent 0.75 was found empirically by the Word2Vec authors. Consider the intuition by looking at the extremes. An exponent of 1.0 (raw frequency) means frequent words dominate: "the" might account for 7% of samples, wasting computation on a word the model has already learned to handle. An exponent of 0.0 (uniform) treats rare words as often as frequent ones, but rare words share contexts with fewer other words, making them less informative negatives. The value 0.75 strikes a balance: common words still appear often enough to learn good embeddings, while rare words get meaningful representation in the negative samples.
