A Word Is a Point in Space
A computer does not know that «cat» and «kitten» have anything in common. To a program, words are strings of characters, and the classic way to feed them to a model was the one-hot vector: a list as long as the vocabulary, all zeros except for a single 1 in the position assigned to that word. With a vocabulary of 100,000 words, every word becomes a vector of 100,000 numbers, and every pair of words is exactly as far apart as every other pair. «Cat» is as distant from «kitten» as it is from «carburetor.»
A word embedding replaces that list with a short, dense vector, typically a few hundred numbers, learned from text. The goal is that words used in similar ways end up near each other. Once that works, distance means something, and a model that learned a fact about «kitten» can apply part of it to «cat» without ever having seen the second word in that context.
The Company a Word Keeps
Zellig Harris argued in his 1954 paper «Distributional Structure» that words with similar meanings tend to occur in similar environments. J. R. Firth put it more memorably in 1957: «You shall know a word by the company it keeps.»
The first computational versions counted. Build a huge table where each row is a word and each column is a context word, fill it with co-occurrence counts from a corpus, and compress it with a matrix factorization such as singular value decomposition. Latent Semantic Analysis, popular in information retrieval in the 1990s, worked this way.
Neural networks entered with Yoshua Bengio and colleagues, whose 2003 paper «A Neural Probabilistic Language Model» (Journal of Machine Learning Research) learned a vector for each word at the same time as it learned to predict the next word. The problem was cost: training on large corpora with the hardware of the time was slow.
Skip-gram and CBOW
In 2013 Tomas Mikolov, Kai Chen, Greg Corrado and Jeffrey Dean at Google published «Efficient Estimation of Word Representations in Vector Space.» Their move was to throw away most of the network. Instead of a full language model with hidden layers, they proposed two shallow architectures that do almost nothing except learn the vectors.
The continuous bag-of-words model (CBOW) takes the words around a position and tries to predict the word in the middle. Skip-gram does the reverse: given one word, predict the words within a small window around it. In the sentence «the cat sat on the mat,» skip-gram with a window of two would train «sat» to predict «the,» «cat,» «on» and «the.»
Each word has an input vector and an output vector, and the prediction is a dot product followed by a softmax. The paper reported that high quality vectors could be learned from a 1.6 billion word dataset in less than a day.
Negative Sampling
The softmax in skip-gram still had a hidden cost. To compute the probability of one context word, the model has to normalize over the whole vocabulary, so every training step touches hundreds of thousands of output vectors.
A second 2013 paper, «Distributed Representations of Words and Phrases and their Compositionality» (Mikolov, Sutskever, Chen, Corrado and Dean, NIPS 2013), replaced it with negative sampling. Instead of asking «which of all words is the context?», the model answers a yes-or-no question: is this pair of words a real pair from the text, or a fake pair made by drawing a random word? Each step updates the true context word and a handful of random «negative» words, between 2 and 20 depending on the size of the dataset. The same paper added subsampling of very frequent words like «the» and «of,» which carry little information and would otherwise dominate training, and a simple method to learn vectors for phrases such as «New York Times.»
Google released vectors trained this way on roughly 100 billion words of Google News text: 300 dimensions for about 3 million words and phrases.
Case: King Minus Man Plus Woman
The result that made word2vec famous was arithmetic. Take the vector for «king,» subtract «man,» add «woman,» and the nearest word to the result is «queen.» The same pattern held for capitals and countries, verb tenses and comparatives. Mikolov’s group built a test set of 19,544 analogy questions of this kind to measure it.
The example deserves some caution. In 2020, Malvina Nissim, Rik van Noord and Rob van der Goot pointed out in Computational Linguistics («Fair Is Better than Sensational: Man Is to Doctor as Woman Is to Doctor») that the standard analogy code never returns any of the input words. For many queries, the vector closest to «king minus man plus woman» is still «king» itself, and the code skips it to show the next candidate. When the input words are allowed, analogy accuracy on the standard benchmark drops. Still, a model that was only asked to predict neighbors produced directions that line up with gender and royalty, and nobody told it about either.
GloVe and the Matrix Underneath
Jeffrey Pennington, Richard Socher and Christopher Manning at Stanford came at the problem from the counting side. Their GloVe model (EMNLP 2014) starts from a global table of how often each pair of words occurs together, then fits vectors so that the dot product of two word vectors approximates the logarithm of their co-occurrence count.
Their motivating example uses ratios. On a 6 billion token corpus, «solid» appears with «ice» far more often than with «steam,» giving a ratio of about 8.9. «Gas» goes the other way, around 0.085. «Water,» which relates to both, and «fashion,» which relates to neither, both give ratios close to 1. The ratio filters out words that do not distinguish the two, and GloVe is designed so that differences between vectors capture those ratios. Stanford released vectors trained on 6, 42 and 840 billion tokens.
The two camps turned out to be closer than they looked. Omer Levy and Yoav Goldberg showed at NIPS 2014 that skip-gram with negative sampling is implicitly factorizing a word-context matrix of pointwise mutual information, shifted by a constant that depends on the number of negative samples. The neural method and the counting method were solving related problems by different routes.
Subwords and Unseen Words
Both word2vec and GloVe assign one vector to each word in the training vocabulary and nothing to anything else. A misspelling, a rare technical term or a new inflection of a known verb gets no vector at all. In languages like Finnish or Turkish, where one root produces dozens of surface forms, this is a serious gap.
fastText, from Piotr Bojanowski, Edouard Grave, Armand Joulin and Tomas Mikolov at Facebook (Transactions of the ACL, 2017), handles it by representing each word as a bag of character n-grams. «Where» becomes pieces like «<wh», «whe», «her», «ere» and «re>», plus the whole word. The word vector is the sum of its piece vectors. An unseen word can still be embedded from the pieces it shares with known words, and words that share a root share part of their representation. The team later released pre-trained fastText vectors for 157 languages, which made embeddings available for many languages that had little labeled data.
A harder limit remains. Each word still gets a single vector, so «bank» in «river bank» and in «bank account» is one point, somewhere between the two senses. Contextual models such as ELMo (2018) and BERT fixed this by computing a new vector for every occurrence of a word from the whole sentence, though the input layer of every transformer is still a table of learned token vectors.
Case: Thermoelectrics Hidden in Abstracts
One of the more surprising uses came from materials science. In 2019 Vahe Tshitoyan and colleagues at Lawrence Berkeley National Laboratory published in Nature a word2vec model trained on about 3.3 million abstracts of materials science papers. It had no labels and no property data.
The vectors still picked up structure from the field, including relationships that resemble the periodic table. The researchers then ranked chemical compounds by how close their vectors were to the word «thermoelectric.» By training the model only on papers up to a given year and checking what was published afterward, they showed that the method would have flagged several materials years before they were reported as thermoelectrics. The model had absorbed indirect associations that no single paper stated outright.
Bias Learned From the Corpus
The same mechanism that finds hidden chemistry also finds stereotypes. In 2016, Tolga Bolukbasi and coauthors at Boston University and Microsoft Research showed (NIPS 2016) that the Google News vectors completed «man is to computer programmer as woman is to» with «homemaker,» and that gender bias could be traced to a single direction in the embedding space. They proposed projecting that direction out of words that should be gender neutral.
A year later, Aylin Caliskan, Joanna Bryson and Arvind Narayanan published in Science a test modeled on the psychological Implicit Association Test. Applied to GloVe vectors trained on web text, it reproduced known human associations, from harmless ones (flowers are more pleasant than insects) to gender and racial stereotypes. Hila Gonen and Yoav Goldberg later showed (NAACL 2019) that debiasing by projection often hides the bias from simple measurements while leaving it recoverable from the neighborhoods of words.
A Final Observation
The thermoelectric study and the «homemaker» analogy are the same experiment. In both, a model was trained to predict which words appear near which, and in both it recovered associations that were present in the text but never written as a sentence. In one case people called it discovery. In the other they called it bias. The model has no way to tell the two apart, because an embedding does not store what is true about the world. It stores how people have written about it, and the decision about which of those regularities to trust stays with whoever reads the vectors.
By: Max Johnson B.