A Neural Probabilistic Language Model
Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research)
Subscriber deck — free during early access
24 cards
1 Introduction
- What is the curse of dimensionality in language modelling, according to Bengio et al.?Modelling the joint distribution of many discrete variables needs huge numbers of parameters: 10 consecutive words over a 100,000-word vocabulary have potentially \(100000^{10} - 1 = 10^{50} - 1\) free parameters. Test word sequences are likely to differ from all training sequences, and discrete spaces offer no obvious smoothness to generalize with.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §1, pp. 1137–1138
- How do n-gram models generalize to unseen word sequences, in Bengio et al.’s view?By “gluing” very short overlapping pieces of length 1, 2, … up to \(n\) seen in training: backing off or interpolating to shorter contexts when a combination is unseen (Katz 1987; Jelinek and Mercer 1980).
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §1, pp. 1137–1138
- What two weaknesses of n-gram models did Bengio et al. target?They ignore context beyond 1 or 2 words, and they ignore similarity between words: having seen “The cat is walking in the bedroom” should make “A dog was running in a room” almost as likely, since dog/cat, the/a, room/bedroom play similar roles.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §1, pp. 1137–1138
1.1 Fighting the Curse of Dimensionality with Distributed Representations
- Summarize Bengio et al.’s approach in three steps.(1) Associate each vocabulary word with a distributed, real-valued feature vector in \(\mathbb{R}^m\); (2) express the joint probability of word sequences in terms of these vectors; (3) learn the word vectors and the probability function’s parameters simultaneously.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §1.1, pp. 1139–1140
- Why does a distributed word representation help a language model generalize?Similar words get similar feature vectors, and the probability function is smooth in those features, so a small change in features changes probabilities only slightly. Each training sentence thus raises the probability of a combinatorial number of “neighbouring” sentences.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §1.1, pp. 1139–1140
1.2 Relation to Previous Work
- How does the neural language model differ from class-based n-grams?Class-based models (e.g. Brown et al. 1992) assign each word a discrete class, a hard or soft partition of the vocabulary. The neural model represents similarity with a continuous learned feature vector per word, so words can be similar along many dimensions.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §1.2, pp. 1140–1141
- How do Bengio et al.’s word vectors differ from LSI-style vectors in information retrieval?LSI learns vectors from co-occurrence in documents; here the vectors are learned to represent the distribution of word sequences compactly, jointly with the model. Fixed vectors from principal components of co-occurrence counts did not work well; joint learning did.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §1.2, pp. 1140–1141
2 A Neural Model
- How do Bengio et al. decompose \(f(w_t, \ldots, w_{t-n+1}) = \hat P(w_t \mid w_1^{t-1})\)?Into a mapping \(C\) from each word \(i\) to a feature vector \(C(i) \in \mathbb{R}^m\) (a \(|V| \times m\) matrix of free parameters, shared across all context positions), and a function \(g\) mapping the context’s feature vectors to a distribution over the next word: \(f(i, w_{t-1}, \ldots, w_{t-n+1}) = g(i, C(w_{t-1}), \ldots, C(w_{t-n+1}))\).
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §2, pp. 1141–1142
- Give the computation of Bengio et al.’s neural language model.Concatenate the context word vectors \(x = (C(w_{t-1}), \ldots, C(w_{t-n+1}))\); compute \(y = b + Wx + U \tanh(d + Hx)\), where \(W\) are optional direct connections (or zero); then \(\hat P(w_t \mid \ldots) = e^{y_{w_t}} / \sum_i e^{y_i}\) (softmax).
Each word index looks up a row of the shared matrix C; dashed: optional direct connections W - Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §2, pp. 1141–1142
- How many free parameters does Bengio et al.’s model have, and how does it scale?\(\theta = (b, d, W, U, H, C)\), dominated by \(|V|(nm + h)\): linear in vocabulary size and in the order \(n\), not exponential as for n-gram tables. More sharing (time-delay or recurrent networks) could make it sublinear in \(n\).
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §2, pp. 1141–1142
- How is Bengio et al.’s neural LM trained?By stochastic gradient ascent on the penalized log-likelihood \(L = \frac{1}{T} \sum_t \log f(w_t, \ldots, w_{t-n+1}; \theta) + R(\theta)\), with weight decay on weights and \(C\) but not biases. Only the feature vectors of words in the current input window need updating after each example.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §2, pp. 1141–1142
- Why did Bengio et al. mix their neural model with an interpolated trigram?Mixing the probability predictions (fixed weight 0.5, a learned weight, or weights conditioned on context frequency) always reduced perplexity, suggesting the two models make their errors (low probability on the observed word) in different places.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §2, pp. 1141–1142
3 Parallel Implementation
- Why is a neural LM much more expensive to run than an n-gram model?An n-gram probability is a normalized relative frequency looked up directly, but the neural model must compute the output activations for every word in the vocabulary to normalize the softmax; the output layer is the main bottleneck.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §3, pp. 1143–1144
- What did Bengio et al. learn from data-parallel training on a shared-memory machine?Locking parameter writes left processors mostly waiting, so they let processors write asynchronously; occasionally an update is overwritten, adding a little noise that didn’t visibly slow training.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §3, pp. 1143–1144
3.2 Parameter-Parallel Processing
- How did Bengio et al. parallelize training across a cluster?Across the output units, where almost all computation happens (about 99.7% for the AP News network): each CPU computes and updates a block of outputs, duplicating the cheap input and hidden computations. CPUs share only the softmax normalizer and gradients on the hidden and feature layers, via MPI Allreduce; communication was 1/15 of total time.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §3.2, pp. 1144–1147
- How is the softmax computed stably across processors in Bengio et al.’s implementation?Each CPU finds the maximum \(q_i\) of its \(y_j\); an extra Allreduce shares the overall maximum \(Q\), and \(p_j = e^{y_j - Q}\) is computed, so no exponential overflows and at least one \(p_j\) is non-zero; then the sum of \(p_j\) is shared to normalize.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §3.2, pp. 1144–1147
4 Experimental Results
- On which corpora was Bengio et al.’s neural LM evaluated?The Brown corpus (about 1.18M words: 800k train, 200k validation, 181k test; words with frequency ≤ 3 merged, \(|V| = 16{,}383\)) and AP News 1995–96 (about 14M training words, \(|V| = 17{,}964\) after lowercasing and mapping rare words, numbers and proper nouns to special symbols).
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §4, p. 1147
4.1 N-Gram Models
- Which n-gram baselines did Bengio et al. compare against?A deleted-interpolation trigram with mixture weights conditioned on context frequency bins (trained by EM on validation data), modified Kneser-Ney back-off n-grams, and class-based n-grams, with order and number of classes chosen on validation data.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §4.1, pp. 1147–1148
4.2 Results
- How much did Bengio et al.’s neural LM improve test perplexity?On Brown: best MLP (mixed with the trigram) 252 vs 312 for the best n-gram (class-based, 500 classes), about 24% better, and 33% better than the interpolated trigram (336). On AP News: 109 vs 117 for the best Kneser-Ney model, about 8%.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §4.2, pp. 1148–1149
- What else did Bengio et al.’s Brown corpus experiments show?The network benefited from more context (4 instead of 2 context words helped it, not the n-grams); hidden units helped; mixing with the trigram always helped. Without direct connections training took twice as long (20 vs 10 epochs) but generalized slightly better, perhaps as a tighter bottleneck.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §4.2, pp. 1148–1149
5.1 An Energy Minimization Network
- What is the energy-minimization variant of the neural LM?The output word also gets a feature vector: the network reads \(x = (C(w_t), C(w_{t-1}), \ldots, C(w_{t-n+1}))\) and outputs an energy \(E = v \cdot \tanh(d + Hx) + \sum_{i=0}^{n-1} b_{w_{t-i}}\), low for likely sequences; normalizing \(e^{-E}\) over \(w_t\) gives the conditional probability. Hidden units act like products-of-experts experts.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §5.1, pp. 1150–1151
- How could Bengio et al.’s energy-based model handle out-of-vocabulary words?Initialize a new word’s feature vector as the probability-weighted average of the vectors of words that could occur in the context, \(C(j) \leftarrow \sum_{i \in V} C(i)\, \hat P(i \mid w_{t-n+1}^{t-1})\), then add it to the vocabulary and renormalize.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §5.1, pp. 1150–1151
5.2 Other Future Work
- Which future directions did Bengio et al. propose that later became standard?Tree-structured (hierarchical) output to cut computation by a factor of about \(|V|/\log|V|\); computing gradients for only a subset of output words (e.g. importance sampling); recurrent networks for longer context; and multiple vectors per word for polysemy.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §5.2, pp. 1151–1152
6 Conclusion
- How does the neural LM “fight the curse of dimensionality with its own weapons”?Each training sentence informs the model about a combinatorial number of other sentences through learned distributed representations. Compact, smooth representations replace tables of conditional probabilities, and computation and memory scale linearly, not exponentially, with the number of conditioning variables.
- Bengio et al., 2003, A Neural Probabilistic Language Model (Journal of Machine Learning Research), §6, pp. 1152–1153
Source
- Yoshua Bengio, Réjean Ducharme, Pascal Vincent and Christian Jauvin. 2003. A Neural Probabilistic Language Model. In Journal of Machine Learning Research, pp. 1137–1155. https://www.jmlr.org/papers/v3/bengio03a.html