ELMo, short for Embeddings from Language Models, is a method for producing contextual word embeddings: vector representations in which the same word receives a different vector depending on the sentence around it. Introduced in 2018 by researchers at the Allen Institute for AI and the University of Washington, ELMo derives these vectors from the internal states of a deep bidirectional LSTM language model pretrained on a large text corpus.
In speech & language AI, ELMo marks the transition from static embeddings such as word2vec, GloVe and fastText to context-sensitive pretrained representations. Adding ELMo vectors to existing models improved the state of the art on question answering, named entity recognition, sentiment analysis and coreference resolution, and it directly preceded the transformer-based models that now dominate the field.
How ELMo builds contextual word vectors
ELMo computes a word representation from every layer of a pretrained biLM, the bidirectional language model, rather than from a lookup table. A forward LSTM predicts each token from the tokens before it, and a separate backward LSTM predicts each token from the tokens after it. The two directions are trained jointly by maximizing the sum of their log-likelihoods, while sharing the token encoder and softmax layer.
The input to the network is character-based: each word is spelled out, passed through a character convolutional network with max pooling and highway layers, and projected to a 512-dimensional token vector. This design lets ELMo build representations for misspellings and words never seen in training, which a word-level vocabulary cannot do.
For a downstream task, ELMo does not just take the top layer. It computes a task-specific weighted sum of all layers, with softmax-normalized weights and a global scaling factor learned on the target task. The table below shows the reference architecture.
| Component | Configuration | Role |
|---|---|---|
| Character encoder | 2,048 character n-gram filters, 2 highway layers | Builds context-independent token vectors |
| Token projection | 512 dimensions | Layer 0 representation |
| biLSTM layers | 2 layers, 4,096 units, 512-dimensional projections | Context-dependent states |
| Residual connection | Between the first and second LSTM layers | Eases training of depth |
| Output vector | 1,024 dimensions (forward and backward concatenated) | Fed to the task model |
What the different layers capture
A central finding of the ELMo work is that different layers encode different kinds of linguistic information. Lower layers are better at syntax, while higher layers capture more context-dependent meaning. Letting the task model learn the layer weights therefore outperforms using only the top layer.
| Layer | Main information | Tasks that benefit most |
|---|---|---|
| Layer 0 (character encoder) | Spelling, morphology, word identity | Handling rare and unknown words |
| Layer 1 (first biLSTM) | Syntax, part of speech, local structure | Part-of-speech tagging, parsing |
| Layer 2 (second biLSTM) | Word sense and broader context | Word sense disambiguation, entailment |
The classic illustration is the word “play”: in a sentence about theater, the upper-layer ELMo vector lies near other stage performance contexts, while in a sentence about sports it lies near game action contexts. A static embedding assigns one vector to both senses.
ELMo compared with static embeddings and transformers
ELMo sits between two generations of text representation. It kept recurrent networks while introducing deep pretraining, and it was used mainly as a feature extractor rather than fine-tuned end to end.
| Method | Context sensitivity | Architecture | Typical use |
|---|---|---|---|
| word2vec, GloVe | None (one vector per word) | Shallow model or matrix factorization | Lookup features |
| fastText | None, but subword-aware | Shallow model with character n-grams | Lookup features, rare words |
| ELMo | Full sentence, two separate directions | Character CNN and 2-layer biLSTM | Frozen features added to a task model |
| BERT | Full sentence, jointly bidirectional | Transformer encoder | Fine-tuned whole model |
| GPT family | Left context only | Transformer decoder | Fine-tuning and prompting |
An important nuance is that ELMo is shallowly bidirectional: the forward and backward LSTMs run independently and are only concatenated. BERT conditions every layer on both sides at once through masked language modeling, which is one reason it outperformed ELMo on most benchmarks within months of release.
Using ELMo in a task model
The standard recipe freezes the pretrained biLM and adds ELMo vectors as extra input features to an existing architecture, such as a biLSTM-CRF tagger or an attention-based reader. Practitioners typically:
- Concatenate ELMo with the original token embeddings at the input of the task network.
- Optionally add ELMo again at the output of the task’s own recurrent layer, which helped on some tasks.
- Apply dropout to the ELMo vectors and a small L2 penalty on the layer weights.
- Optionally fine-tune the biLM on in-domain text before training the task model, which reduces perplexity and often improves accuracy.
Reported gains in the original evaluation were relative error reductions of roughly 6 to 20 percent across six benchmark tasks, including SQuAD question answering and CoNLL 2003 named entity recognition. ELMo also improved sample efficiency, reaching a given accuracy with considerably less labeled data.
Limitations and current relevance
ELMo has practical drawbacks that explain why it is rarely chosen for new systems today. Its LSTMs process tokens sequentially, so inference is slow and hard to parallelize compared with transformers. The 1,024-dimensional vectors from roughly 94 million parameters must be computed for every sentence, which adds noticeable latency to production pipelines.
Because the two directions are combined only at the end, ELMo captures interactions between left and right context less effectively than deeply bidirectional models. It also inherits biases present in its training corpus, the 1 Billion Word Benchmark of news text, which limits quality on informal, conversational or domain-specific language.
Despite this, ELMo remains historically and conceptually important. It established that representations from a pretrained language model transfer across tasks, that layer-wise mixing reveals linguistic structure, and that character input handles open vocabularies. These ideas carried into BERT, RoBERTa and modern large language models.
In everyday language
Words change meaning with their surroundings. A “bank” can hold money or line a river. Older methods gave each word one fixed number pattern. They could not tell the two banks apart.
ELMo reads the whole sentence first. It reads it forward and backward. Then it gives each word a pattern that fits that sentence. So the same word gets different meanings in different sentences. This helped computers understand text far better and opened the way to tools like BERT.
Seen in the real world
A team building a named entity recognition system for legal contracts in 2018 had about 4,000 annotated documents. Their biLSTM-CRF tagger using GloVe vectors often confused party names with ordinary capitalized words such as “Buyer” or “Agreement” and struggled with misspelled company names.
The team fine-tuned a pretrained ELMo biLM on a few hundred megabytes of unlabeled contracts, then concatenated the ELMo vectors with GloVe at the tagger input. The character encoder recognized unusual spellings, and the context layers separated defined terms from real parties. Entity-level F1 rose by several points, and the model reached its previous accuracy with roughly half the labeled training data, at the cost of slower inference on long documents.