Sub topic 20
Limitations: polysemy, unknown words and bias
Static word embeddings from word2vec and GloVe are useful, but they have structural limits. This chapter covers three of them: one vector per word form (polysemy), no vector for unseen words, and bias absorbed from the training text. It assumes you have read the earlier chapters on training and querying embeddings, and that you are comfortable with Python, NumPy and cosine similarity.
One vector per word: polysemy
Polysemy means one word has several meanings. "Bank" can be a riverbank or a financial institution. "Apple" can be a fruit or a company.
word2vec and GloVe are static models. Each word type in the vocabulary gets exactly one vector, whatever sentence it appears in. Training pushes that single vector toward the contexts of every sense. The result is roughly a frequency-weighted blend of the senses.
What this looks like in practice
- The dominant sense in the corpus usually controls the neighbours. A rare sense is often invisible in a nearest-neighbour list.
- A minority sense can still pull the vector slightly off-center, which blurs similarity scores.
- Two unrelated words that both share a sense with a polysemous word can look closer than they should. "Bank" can bridge "river" and "loan" in the vector space.
You can inspect this directly with the pretrained vectors from the earlier chapter.
import gensim.downloader as api
wv = api.load("glove-wiki-gigaword-50")
for word in ["bank", "apple", "bat"]:
print(word, [w for w, _ in wv.most_similar(word, topn=8)])Read the lists critically. Ask which senses appear and which are missing. Exact output depends on the vectors you load.
Common mitigations
- Context-dependent models such as ELMo and BERT give each token occurrence its own vector, so the sense is resolved by the surrounding sentence. This is the standard solution today.
- Sense-specific embeddings cluster the contexts of a word and train one vector per cluster. This is rarely used now because the number of senses is hard to choose.
- Preprocessing can split senses by hand, for example by tagging part of speech (
bank_NOUN,bank_VERB). This only separates senses that differ in grammatical category.
Unknown words: out-of-vocabulary tokens
A word2vec or GloVe model is a lookup table. A word that was not in the training vocabulary has no row, so there is nothing to return.
import gensim.downloader as api
wv = api.load("glove-wiki-gigaword-50")
word = "blorptastic"
if word in wv.key_to_index:
print(wv[word].shape)
else:
print(f"{word!r} is out of vocabulary")
try:
wv[word]
except KeyError as e:
print("KeyError:", e)Why words are missing
- Words below the
min_countfrequency cutoff are dropped during training. - Rare words, new words, names, typos and slang are not in the training text.
- Inflected forms and compounds are separate entries. In a language with rich morphology, such as Finnish or Turkish, a large share of word forms may never be seen, even if the stem was.
- The tokenizer used at query time must match the one used in training. GloVe 6B is lowercased, so
"King"is missing but"king"is present.
Handling out-of-vocabulary words
- Normalize first. Apply the same lowercasing and tokenization the vectors were trained with.
- Fall back to a default. Use a zero vector or a shared
<unk>vector, and keep track of how often it happens. - Skip the token when averaging vectors for a sentence, but check that something is left.
- Use subword models. fastText represents a word as the sum of its character n-gram vectors, so it can build a vector for a word it never saw. Misspellings and related word forms then land near the correct word.
A safe averaging function shows the second and third options together:
import numpy as np
def sentence_vector(tokens, wv):
vectors = [wv[t] for t in tokens if t in wv.key_to_index]
missing = [t for t in tokens if t not in wv.key_to_index]
if not vectors:
return np.zeros(wv.vector_size, dtype=np.float32), missing
return np.mean(vectors, axis=0), missingLogging missing tells you how well the vocabulary fits your data. If many domain terms are missing, pretrained vectors are a poor match. Consider training on your own corpus or fine-tuning.
Bias encoded in the vectors
Embeddings are trained to predict or reconstruct word co-occurrence. They learn whatever regularities the text contains, including stereotypes and imbalances. They have no notion of whether a pattern is fair or true.
Evidence
- Bolukbasi et al. (2016) showed that word2vec vectors trained on news text place "man" closer to "programmer" and "woman" closer to "homemaker", and that analogy queries can reproduce gender stereotypes.
- Caliskan et al. (2017) adapted the Implicit Association Test to embeddings (WEAT). They found that GloVe vectors reproduce human-like associations, such as names common among some groups being closer to pleasant or unpleasant words.
You can probe this with a simple comparison:
import gensim.downloader as api
wv = api.load("glove-wiki-gigaword-50")
for occupation in ["nurse", "engineer", "teacher", "programmer"]:
he = wv.similarity(occupation, "he")
she = wv.similarity(occupation, "she")
print(f"{occupation:12s} he={he:.3f} she={she:.3f} diff={he - she:+.3f}")A positive difference means the occupation sits closer to "he". The gaps are small and depend on the vectors. Treat this as a probe, not a measurement. Valid bias studies use word sets chosen in advance and test for statistical significance.
Where bias comes from
- The corpus. Web text, news and books reflect the society that wrote them.
- Frequency. Associations that appear more often get stronger vectors.
- The objective. Neither word2vec nor GloVe has any term that discourages biased associations.
Debiasing and its limits
Projection methods identify a "gender direction" in the space and remove it from words that should be neutral. Gonen and Goldberg (2019) showed that this mostly hides the bias. Words that were biased are still clustered together, so the information can be recovered.
Practical steps include auditing with word sets relevant to your task, choosing or curating training data deliberately, documenting known issues, and testing downstream outputs across groups. Do not assume that a debiasing step removes the problem.
Other limits worth knowing
- Antonyms often get high similarity, because "hot" and "cold" appear in the same contexts. Similarity in the space does not mean "means the same".
- Embeddings reflect the time and domain of the corpus. Vectors trained on 2014 Wikipedia and newswire know little about newer terms and may encode outdated usage.
- Analogy results are sensitive to how the search is done. Standard implementations exclude the query words from the answer, which flatters the results.
- Frequent words and rare words behave differently. Vectors for rare words are noisy because they have few training examples.
Summary table
| Limitation | Cause | Mitigation |
|---|---|---|
| Polysemy | One vector per word type | Contextual models, POS tags |
| Out-of-vocabulary words | Fixed lookup table | Normalization, `<unk>`, fastText |
| Bias | Biased text, no fairness term | Audits, curated data, downstream testing |
| Antonym confusion | Shared contexts | Task-specific fine-tuning |
Exercise
A teammate averages GloVe vectors to represent product reviews. Many reviews contain brand names and misspellings, and the classifier performs worse on those reviews. Give two causes related to this chapter and one fix for each.
Show answer
Cause 1: out-of-vocabulary tokens. Brand names and misspellings are not in the vocabulary, so they are dropped or replaced with zeros, and the average loses information. Fix: use fastText, which builds vectors from character n-grams, or train embeddings on in-domain reviews. Cause 2: polysemy, where a word such as "apple" has a single blended vector that mixes the fruit and the company, so the review's meaning is distorted. Fix: use a contextual model such as BERT, or tag the sense or part of speech before lookup.
Exercise
Why does removing a "gender direction" from word vectors not fully remove gender bias?
Show answer
Bias is spread across many dimensions and shows up in the neighbourhood structure. After projection, words that were gender-biased still cluster together and can be separated by a classifier, so the information is hidden rather than removed.