ELMo (Embeddings from Language Models) is a model that gives each word a different vector in each sentence where it occurs. It was introduced in 2018 by researchers at the Allen Institute for AI and the University of Washington (Peters et al., 2018), and it was the hinge between the static embeddings of word2vec and pretrained transformers.
The problem: one vector per word
word2vec gives "bank" a single vector, whether it is the bank of a river or the one that charges fees. Alammar & Grootendorst (2024) use exactly this example: the word's meaning, and therefore its embedding, should change with the context (2024, p. 11). ELMo solves the problem by moving from types to occurrences: it produces contextual embeddings (Alammar & Grootendorst, 2024, pp. 58–61).
How it works
Its core is a bidirectional language model (biLM). One LSTM reads the sentence left to right and predicts each word from the preceding ones; another reads it right to left and predicts each word from the following ones (Peters et al., 2018, pp. 2228–2229). Each direction has two layers of 4,096 units with 512-dimensional projections, and the input is not words but characters, processed by a convolutional network, so there are no unknown words (2018, p. 2230). It was trained for ten epochs on the 1B Word Benchmark, some 30 million sentences (2018, pp. 2228, 2230).
A word's ELMo vector combines all the layers (the character layer and both LSTMs) with weights learned by each task (2018, p. 2229). The biLM is then frozen and that vector is concatenated to the input of an existing task model: one for question answering, for inference, or for tagging (2018, pp. 2229–2230). In the terminology that BERT later popularized, it is a "feature-based" approach (Devlin et al., 2019, p. 4171).
What changed
Adding ELMo improved the state of the art on all six tasks evaluated (question answering, textual entailment, semantic roles, coreference, named entities and sentiment), with relative error reductions of 6 to 20% according to the authors (Peters et al., 2018, pp. 2230–2231). It also made models more data-efficient: for semantic roles, with 1% of the training data it matched the baseline trained on 10% (2018, p. 2234).
Most interesting for linguists is the layer-by-layer analysis. The nearest neighbors of play in GloVe mix forms and senses, mostly sporting ones; with ELMo, the play of a baseball report and the play on Broadway come apart (Peters et al., 2018, p. 2233). The first LSTM layer is better for part-of-speech tagging; the second, for word sense disambiguation (2018, pp. 2233–2234). Syntax below, semantics above, as in the linguistics textbooks.
Limits
ELMo's bidirectionality is shallow: two unidirectional models trained separately and concatenated, so no layer sees both sides at once. That was the criticism with which BERT introduced itself months later (Devlin et al., 2019, pp. 4172, 4178). Moreover, being recurrent, it reads one word at a time and cannot exploit GPU parallelism, and its corpus was shuffled at the sentence level, with no long-range structure (Radford et al., 2018, sec. 4.1). Its most visible legacy is another one: it started the habit of naming models after Sesame Street characters.