AI State of the Art
Fundamentals/NLP: From Classical to Modern/27 min
Section 40

GloVe and FastText: Two Extensions of Word2Vec

Listen as a podcast β†’

The Story: Two Problems, Two Revolutions

Word2Vec was brilliant, but incomplete. Two teams identified its flaws and proposed complementary solutions. Both, like Word2Vec, produce static embeddings: a word gets one vector, the same one no matter what context it appears in. That is the limitation all three share, and we come back to it at the end of the lesson.

GloVe (Global Vectors for Word Representation, 2014, Stanford): "Word2Vec looks locally, just a window of 5-10 words around. Yet the whole corpus holds global statistics that contain enormous amounts of information. Why ignore them?"

FastText (Facebook; the subword paper appeared in 2016 and was published in a journal in 2017): "Word2Vec and GloVe give one vector per word. But a word never seen before? They don't know what to do with it. Why not decompose words into small pieces to handle the unknown?"

Two flaws, two elegant solutions. Let's look at them in detail.

GloVe: The Big Picture Against Myopia

The Word2Vec Problem That GloVe Fixes

Word2Vec slides a window (5-10 words) over the corpus and learns local contexts. It's effective, but it poses a subtle problem: the model forgets what it saw a few sentences ago. It only retains the current window.

Yet the global structure of the corpus contains valuable information. Here is the opening example of the GloVe paper, with "ice" and "steam": take a probe word, and divide the probability that it appears near "ice" by the probability that it appears near "steam".

  • For "solid", the ratio the authors measure is about 8.6: the word leans clearly toward ice
  • For "gas", it is about 0.08: this time steam wins, and by a wide margin
  • For "water", related to both, and "fashion", related to neither, the ratio stays close to 1 and tells you nothing

This ratio contains powerful semantic information: it directly encodes that ice is a solid and steam is a gas. And it is the ratio that carries the information, not the raw counts, a very frequent word appears often near both, and that cancels out in the division. This observation is what gives GloVe its training target.

Word2Vec doesn't exploit them, because it never looks at the corpus as a whole. It just sees the local window, sentence by sentence.

Bar chart of the ratio between the probability that a word appears near ice and near steam, for four probe words: solid is 8.64, gas is 0.08, water is 1.36 and fashion is 0.94. A horizontal line marks the neutral ratio of 1.
The original example from the GloVe paper. Divide the probability that a probe word appears near ice by the probability that it appears near steam. For solid the ratio is 8.64 (ice is a solid); for gas it is 0.08 (steam is the gas). For water and fashion the ratio stays close to 1: the first is related to both, the second to neither, so the ratio tells us nothing. These ratios, not the raw counts, are what GloVe asks its vectors to reproduce.Source : Adapted from the GloVe paper (Pennington et al., 2014), via Marcel Brenndoerfer

The Strategy: Build and Factorize a Matrix

GloVe proceeds in two steps.

Step 1: Count. You build a gigantic co-occurrence matrix. The cell (i, j) contains the number of times word i and word j appear near each other across the entire corpus. For a vocabulary of 400,000 words, it's a 400k x 400k matrix. Huge, but you don't store it entirely: it's sparse (most word pairs never appear together).

Step 2: Compress. Instead of using this raw matrix (far too large to be directly useful), GloVe looks for dense vectors of small dimension (typically 300) that reproduce the co-occurrence statistics:

wβƒ—iβ‹…wβƒ—jβ‰ˆlog⁑(co-occurrence(i,j))\vec{w}_i \cdot \vec{w}_j \approx \log\bigl(\text{co-occurrence}(i, j)\bigr)

The symbols: wβƒ—i\vec{w}_i and wβƒ—j\vec{w}_j are the vectors being sought for words ii and jj; the dot between them is the dot product (multiply the coordinates pairwise and add them up, giving a single number that is large when the two vectors point the same way); co-occurrence(i,j)\text{co-occurrence}(i, j) is how many times the two words were seen near each other in the corpus; log⁑\log is the logarithm. Why a logarithm? Because raw counts span enormous ranges (a handful for rare words, millions for "the") and the logarithm brings that onto a scale a dot product can plausibly match. The second, decisive virtue: a difference of logarithms is the logarithm of a ratio, so working on log-counts is exactly working on the co-occurrence ratios from the ice/steam example.

In one sentence: find vectors whose dot product reproduces, for each pair of words, the logarithm of how often they sit next to each other. It's a form of matrix factorization (decomposing the large word-by-word co-occurrence matrix into two small matrices, whose rows become the embedding vectors): you look for low-dimensional vectors that best approximate the true corpus statistics. You optimize these vectors by gradient descent, like a classic neural network.

The Result: The Best of Both Worlds

Old methods like LSA (Latent Semantic Analysis) used the entire co-occurrence matrix, but required singular value decomposition (SVD, see the dedicated lesson), which is extremely slow on large vocabularies. Word2Vec was fast thanks to gradient-based training, but only looked locally. GloVe combines both: fast gradient-based training (like Word2Vec) + use of global statistics from the entire corpus (like LSA).

GloVe embeddings in numbers

The authors released several vector sets, including one trained on Wikipedia plus the Gigaword news corpus (6 billion tokens in total, a 400,000-word vocabulary) and one on Common Crawl, a web archive (840 billion tokens). The 300-dimensional vectors long dominated word similarity benchmarks.

Concrete Results

Pre-trained GloVe embeddings were the standard in natural language processing (NLP) from roughly 2014 to 2018. They rivalled Word2Vec on analogies such as "king - man + woman = queen" and often outperformed it on word similarity, precisely because global statistics better capture fine semantic relationships. On how much weight those analogies can bear, see the caveats in the Word2Vec lesson.

Four points in a three-axis frame: King and Man in blue, Queen and Woman in purple. A dashed arrow connects King to Queen and another connects Man to Woman; both arrows share the same direction and length.
What king minus man plus woman equals queen actually means. The shift that takes you from King to Queen is the same vector as the one from Man to Woman: gender has become a direction in the space. The same holds for other relations, such as country to capital or singular to plural. This is precisely the kind of regularity GloVe tries to capture better than Word2Vec by using whole-corpus statistics.Source : Zilliz, Word2Vec glossary

FastText: Solving the Infinite Vocabulary Problem

The Problem That Kills Word2Vec and GloVe

Imagine you've trained Word2Vec or GloVe on a standard English corpus. Both models have 300,000 words in their vocabulary. Now, the model encounters a word it has never seen: "antidisestablishmentarianism", a technical term like "geolocation", or even a simple typo "aple" instead of "apple".

The model's answer: "I don't know this word. No embedding." Such a word is called out-of-vocabulary, usually abbreviated OOV.

This is a fatal problem in several contexts:

  • Morphologically rich languages: in Turkish, a single verb can have 20+ conjugated forms. In Finnish, it's virtually infinite. Storing every form is impossible.
  • Specialized corpora: medical terms, legal jargon, molecule names. Rare but crucial words.
  • Social media: typos, abbreviations, neologisms that appear and disappear every day.
  • Proper nouns: names of people, regional places, brands.

Word2Vec and GloVe crack under the unknown. And in the real world, the unknown is everywhere.

The Genius Solution: Decomposing Words into Pieces

FastText (Facebook, 2017) flips the paradigm. Instead of having one vector per whole word, you have:

  • Vectors for word pieces: character n-grams, meaning every run of n consecutive letters the word contains, with n typically between 3 and 6
  • The final embedding of a word = the sum of all its pieces' vectors

For "apples" (with n-grams of size 3-6), the pieces are:

<ap, app, appl, apple, pples, ples, les, es> (the < and > markers indicate the start/end of the word)

embedding("apples")=βˆ‘piece∈n-gramsvβƒ—piece\text{embedding}(\text{"apples"}) = \sum_{\text{piece} \in \text{n-grams}} \vec{v}_{\text{piece}}

Reading the formula: the big βˆ‘\sum means "add up", ∈\in reads "among", and vβƒ—piece\vec{v}_{\text{piece}} is the learned vector for one piece. So: to get the vector for "apples", add up the vectors of all its pieces, coordinate by coordinate. The pieces' vectors are the learned parameters stored in the table; the word's vector is never stored at all, it is recomputed by this sum whenever it is needed. That is exactly what makes it possible to build a vector for a word never seen before.

It's simple but powerful: each word is the sum of its parts. And these parts are shared across thousands of words.

Two-column comparison. On the left, Word2Vec: the word grey points to a single row of a lookup table, which directly gives its vector. On the right, FastText: the word grey is broken into the whole word grey plus the n-grams gr, gre, rey and ey, each with its own row in the table, and their vectors are summed into the final vector.
The whole difference is one operation. On the left, Word2Vec fetches a row from a table indexed by whole words: if the word is missing, there is nothing to fetch. On the right, FastText stores a vector for the whole word and one for each of its character n-grams, then adds them up. The vocabulary is made of pieces rather than words, and that is what lets it build a vector for a word it has never seen.Source : Lena Voita, NLP Course For You

Why It Works for Unknown Words

New word never seen, "applesauce"? Let's decompose it into pieces:

<ap, app, appl, pple, ples, lesa, esau, sauc, auce, uce>

The pieces "ap", "app", "appl" are shared with "apples", "application", "appetite". Even if "applesauce" was never seen in the training corpus, its pieces exist in other words and have already-learned vectors. The resulting embedding is a combination of known pieces, giving a reasonably relevant vector.

It's like encountering an unknown word but recognizing its Latin roots: you don't know the exact word, but you can guess its meaning thanks to the familiar pieces.

The Hidden Talent: Spelling Mistakes

"apples" vs "appls" (a common typo):

WordN-grams
apples<ap, app, appl, pples, ples>
appls (typo)<ap, app, appl, ppls, pls>

Three pieces out of five are identical. Since a word's vector is the sum of its pieces' vectors, the two words land close together in the space. Result: a semantic search with FastText doesn't miss results because of a typo. For a search engine or a conversational agent, that is a considerable practical advantage.

FastText excels where morphologies explode

In Finnish or Turkish, a single verb can take dozens of conjugated forms. Word2Vec would need to have seen each of these forms during training. FastText? A single stem decomposed into pieces is enough, because the conjugated forms share most of their pieces. This is also why FastText stayed popular for low-resource languages.

All Three in One Table

CriterionWord2VecGloVeFastText
Looks atLocally (window)Globally (entire corpus)Locally (window)
Unknown words?NoNoYes (via subwords)
MorphologyWeakWeakExcellent
Training speedFastModerateModerate
Frequent wordsGoodVery goodGood
Rare wordsWeakWeakGood
Typo resistanceNoneNoneGood

The Gap That Will Remain: Static vs Contextual Embeddings

Here, we need to mention a fundamental limitation that Word2Vec, GloVe, and FastText all share: they produce a single vector per word, regardless of the context in which that word appears.

"Bank" (the financial institution) and "bank" (the riverbank) = same embedding. The model blends both meanings into a single vector, a kind of "average" of the two meanings. This is a major problem for all tasks where polysemy matters (that is, almost all of them).

The Contextual Revolution

From 2018 onward, NLP shifted toward contextual embeddings, which give a different vector for each occurrence of a word based on its context:

  • ELMo (Embeddings from Language Models, 2018): uses the hidden layers of an LSTM network (long short-term memory, see LSTM and GRU) read in both directions. Each occurrence of a word produces a slightly different embedding depending on the surrounding words. First step toward contextual.
  • BERT (Bidirectional Encoder Representations from Transformers, 2018): uses the transformer's bidirectional attention. "The bank lends money" and "The river bank is muddy" generate completely different vectors for "bank". See the BERT lesson.
  • GPT (Generative Pre-trained Transformer, 2018 onward): same idea with causal attention, each word sees only the ones before it, which is what generation requires.

The result: massively better performance on almost all language tasks (classification, entity extraction, similarity, question answering). As of 2026, representing the meaning of a word or a text goes through a contextual model: see text embeddings. Static embeddings belong to the field's history.

What's left of static embeddings

A word's vector is read from a table, with no computation at all: that is their entire remaining virtue. Where you still meet them:

  • Very tight latency or cost budgets: a table lookup is a trivial operation, whereas pushing a sentence through a contextual model takes millions of multiplications. When the budget per request is tiny, the gap matters.
  • Very low-resource languages: for Bambara or Lao, there isn't enough text to train a good contextual model. A pre-trained static embedding, even one shared across languages, beats nothing.
  • Quick corpus exploration: projecting tens of thousands of words onto a plane to eyeball the structure of a vocabulary. Fast, readable, no infrastructure.

Note that the memory argument actually runs against static embeddings: a table of 400,000 words x 300 numbers at 4 bytes each is already about 480 MB, the same order as BERT-base's 110 million parameters. What you save is compute, not memory.

Why This Matters

GloVe and FastText showed two fundamental directions for improvement:

  • GloVe: exploiting macroscopic statistics (how often words co-occur across the entire corpus) produces better embeddings than only looking at local windows.
  • FastText: decomposing words into morphemes or character n-grams solves the infinite vocabulary problem and handles complex languages with elegance.

Both contributions persist in today's models. BERT has a form of global vision: its bidirectional attention sees the whole sentence at once. And the idea that a word decomposes into reusable pieces is now universal, it is the very principle of subword tokenizers (BPE, WordPiece). Mind the chronology, though: those tokenizers were not inspired by FastText, they predate it (WordPiece in 2012, BPE applied to translation in 2015, FastText in 2016). The two traditions converged on the same intuition independently, which says a great deal about how sound it is.

Together, Word2Vec, GloVe, and FastText form the conceptual foundation of modern language processing, a foundation, not a working tool: their job today is to make clear why current models are built the way they are.

Check your understanding0 / 4

1. What information does GloVe ask its vectors to reproduce?

2. How does FastText build a vector for a word it has never seen?

3. Do GloVe and FastText produce contextual embeddings?

4. What is the remaining virtue of static embeddings compared to contextual models?