Modelcore
Recurrent neural network language model
Also called RNN language model, RNNLM.
A language model whose recurrent hidden state summarizes the whole history and gives a softmax over the next word at each step.
A recurrent neural network language model reads a text one word at a time and keeps a hidden state, a vector that is updated from the previous state and the current word. From the state it gives a softmax over the next word. So the prediction depends, in principle, on the whole history, not only on the last words as in an n-gram model or the neural probabilistic language model. The network is the simple recurrent network of Elman (1990). Mikolov and colleagues used it as a language model for speech recognition in 2010, and on Wall Street Journal data a mixture of such models had about half the perplexity of a large Kneser-Ney model.
The machine
Parameters. For a vocabulary and hidden units:
- , an matrix; column is the input vector of the word ;
- , an matrix, the recurrent weights;
- , a matrix, the output weights.
The step. Let be the one-hot vector of the current word and the previous state. Mikolov and colleagues write the input as the concatenation . Then
with the logistic function applied to each unit, and is the probability that the next word is . The state starts as a fixed vector, for example all zeros or all 0.1. Because is one-hot, is just a column of , so the input costs no multiplications.
Training. The parameters maximize the log-likelihood of the training text by stochastic gradient descent. The gradient flows back through the recurrence by backpropagation through time, cut after steps. In the 2010 paper , so the error goes back into but not further; the start rate was , and the hidden layer had 30 to 500 units. Words below a count threshold share one rare-word output, and a rare word gets , with the number of rare words.
The dynamic model. The dynamic version keeps training on the test text as it reads it: after each word it takes one gradient step on that word. Like a cache, this adapts the model to the current document.
An example. Take , , , input columns for a, for b and for c, and output rows for a, for b and for c, with . After the word a the state is . After "a c" it is , and the next word has the distribution . After "b c" the state is and the distribution is . Both histories end in c, so a bigram model would give them the same distribution; the state still remembers the first word.
What it counts
The model is measured by its perplexity on test text, and in a recognizer by the word error rate after rescoring. The cost of one step is the number of multiply-adds:
- the recurrence, , plus for the input column;
- the output, , and for the softmax.
With and that is for the recurrence against for the output, so, as in the feedforward model, the output dominates. Truncated backpropagation through time over steps adds about per word for the gradient of the recurrence. Unlike an n-gram model, the state is a continuous vector, so a recognizer cannot merge two hypotheses that end in the same words: a lattice or an n-best list is usually rescored after a first pass with an n-gram model.
Relation to other models
- Feedforward neural models. The neural probabilistic language model sees a fixed window of words. The recurrent model replaces the window by the state, which has a fixed size but depends on all earlier words.
- n-gram models. An n-gram model is the special case where the state is the last words. The recurrent state is learned and can keep some of the earlier context.
- Hidden Markov models. Both carry a state from step to step, but the hidden Markov model state is discrete and random, while the recurrent state is a deterministic real vector.
- Gated recurrent networks. Long short-term memory (Hochreiter and Schmidhuber 1997) adds gates and a memory cell to the recurrent unit. It lets the error signal survive over many steps and replaced the simple recurrent unit in later language models.
- Cache models. The dynamic model adapts to the test document by training on it, and the neural cache of Grave, Joulin and Usunier adds an explicit memory of recent states.
- Transformers. A transformer language model drops the recurrence: each position looks at all earlier positions through attention, which trains in parallel over the positions.
Known results in the model
- Wall Street Journal. Against a 5-gram Kneser-Ney model with perplexity 221 and word error rate 13.5 percent, a mixture of recurrent models with the 5-gram model reached a perplexity of 112 and a word error rate of 11.1 percent: about 50 percent lower perplexity and about 18 percent fewer errors.
- NIST RT05. On meeting speech the word error rate was 24.1 percent with the baseline, 23.3 percent with static recurrent models and 22.8 percent with dynamic ones.
- Long dependence is hard to learn. The gradient through steps is a product of Jacobians of the step, so it tends to shrink or grow exponentially in : the vanishing gradient problem and the exploding gradient problem. Gradient clipping handles the second, and gated units the first.
- The output bottleneck. As for the feedforward model, the softmax over is the main cost. A factored output through word classes, the hierarchical softmax and noise-contrastive estimation reduce it.
- Mixing helps. The recurrent model and the n-gram model make different errors, so a linear mixture of the two is better than either, which is how the 2010 results were obtained.
References
- Tomáš Mikolov, Martin Karafiát, Lukáš Burget, Jan Černocký and Sanjeev Khudanpur, Recurrent neural network based language model, Proceedings of Interspeech 2010, pages 1045 to 1048, the model x(t) = [w(t); s(t-1)] with a sigmoid hidden layer and a softmax output, the training with truncated backpropagation through time, the dynamic model, the class for rare words, and the results on Wall Street Journal and NIST RT05
- Jeffrey L. Elman, Finding structure in time, Cognitive Science 14(2), 1990, pages 179 to 211, the simple recurrent network, with context units that hold a copy of the previous hidden state, trained to predict the next element of a sequence
- Sepp Hochreiter and Jürgen Schmidhuber, Long short-term memory, Neural Computation 9(8), 1997, pages 1735 to 1780, the gated memory cell that keeps the error signal from vanishing over long time lags
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag TXBYG6 Edit this page History Report an error Markdown