History of AI
Word2vec: Teaching Computers That Words Have Meaning
In 2013 Word2vec showed that word embeddings capture relationships like king and queen. Here is how it learned them.
In 2013, researchers at Google published Word2vec, a method that learns an embedding for each word from lots of text. It was developed by Tomáš Mikolov, Kai Chen, Greg Corrado, Ilya Sutskever and Jeff Dean, and presented at a conference called ICLR in 2013.
The idea: a word is known by its neighbours
Word2vec does not look up definitions. It reads a huge amount of text and looks at which words appear near which. Words that are used in similar contexts end up with similar numbers. That is why "similar meaning" words land close together.
The two designs from the original work are:
- CBOW (continuous bag of words) is a fill-in-the-blank task. Given the words around a gap, guess the word in the gap.
- Skip-gram goes the other way. Given one word, guess the words around it.
According to the method's authors, CBOW is faster, while skip-gram does a better job for infrequent words. Both are shallow neural networks with two layers. The sentence in the picture, "the man loves his son", is the example used on Wikipedia.
The famous example
The learned numbers captured relationships. The 2013 paper reports that vector("King") minus vector("Man") plus vector("Woman") gives a vector closest to the vector for "Queen". The same trick answers questions like "what is to small as biggest is to big?" (answer: smallest).
The authors even built a test set of 8,869 meaning questions and 10,675 grammar questions, such as capital cities, plurals and past tenses, to measure how good the vectors were.
Why it mattered
It showed that a simple prediction task could teach a computer something about meaning, and it was fast enough to learn from very large collections of text. A follow-up paper added tricks such as negative sampling and received the 2023 NeurIPS Test of Time Award.
What it could not do
Word2vec gives each word one fixed list of numbers. A word with two meanings, like "bank", gets a single vector for both. Later models, such as BERT and other transformers, give a word different numbers depending on the sentence around it.
Try this
Pick a word and write down five words you often see near it. Then pick a different word with a similar meaning and do the same. If your lists overlap, you have just done what Word2vec does, only with a pencil.