Modeladvanced
Maximum entropy language model
Also called exponential language model, Rosenfeld maxent model.
A log-linear model of the next word given features of the history, such as n-grams and triggers, fit to match feature expectations.
A maximum entropy language model gives the probability of the next word after a history as a softmax of a weighted sum of features:
Each feature is a fact about the pair, such as "the last word is stock and is market" or "stock occurred earlier in the document and is shares". Any set of such facts can be put together in one model, which is the main appeal. The weights are fitted so that, on the training text, the expected value of each feature under the model equals its count. Among all models that meet these constraints, this is the one with the largest entropy, which is where the name comes from. Rosenfeld (1996) used it to combine n-gram features with long-distance trigger features and lowered the perplexity of a trigram model by 32 to 39 percent.
The machine
Features. A feature is a function , in practice almost always 0 or 1. Common kinds:
- n-gram features, if the last words of and form a given -gram, for ;
- trigger features, if a given word occurred in the document history and , for a selected trigger pair ; with this is a self-trigger, the effect that a cache models;
- class features, the same as n-gram features over word classes;
- any other test of the history, such as the topic of the document.
The model. For a history , the score of a word is the sum of the weights of its active features, and the softmax turns the scores into a distribution over the vocabulary . The normalizer depends on , so it must be computed for every history.
The fit. Let be the relative frequency of the pair in the training text and that of the history. The weights maximize the conditional log-likelihood
Its gradient is the difference between the data count and the model expectation of each feature,
so at the optimum the two are equal for every feature. The classic algorithms are generalized iterative scaling (Darroch and Ratcliff 1972) and improved iterative scaling; later practice uses gradient methods such as L-BFGS or stochastic gradient descent. A Gaussian prior on the weights, or a cutoff on rare features, is needed in practice: a feature that is never active in the data would otherwise get the weight .
The maximum entropy view. Consider all conditional models whose feature expectations, with the history weights , equal the data counts. The one with the largest conditional entropy has the log-linear form above, and its weights are the maximum likelihood weights. The weights are the Lagrange multipliers of the constraints. So the model assumes nothing beyond the constraints: where no feature says otherwise, it spreads the probability as evenly as it can.
An example. The training data has the history a 4 times and a second history x 6 times. After a come b 3 times and c once; after x come a twice, b once and c 3 times. Take the unigram features of a, b and c, and one bigram feature for "a then b". The constraints are the counts 2, 4 and 4 of a, b and c, and the count 3 of a b. The bigram feature forces , so , and then the count of b forces . No feature separates a from c, so after both histories they keep the same ratio , and the count of a gives , so . The fitted model is
| a | b | c | |
|---|---|---|---|
| a | 1/12 | 3/4 | 1/6 |
| x | 5/18 | 1/6 | 5/9 |
with and the bigram weight . Every constraint holds; for c, . The model gives a after a the probability 1/12, although a b and a c are the only pairs seen after a: nothing in the constraints forbids it. After x it does not reproduce the counts, because no feature is specific to x.
What it counts
The model is measured by its perplexity on test text, and in a recognizer by the word error rate. The cost is dominated by the normalizer. One probability needs , a sum over all words, each with its active features: for active features per pair, against lookups for a backoff n-gram model. One pass of training computes the model expectations for every distinct history in the data, for distinct histories, and the fit needs many passes. Large vocabularies made this the main limit of the method. Word classes help: with each normalizer runs over the classes or over one class, about terms each for a good split.
Relation to other models
- Softmax regression. The model is softmax regression with the words as classes and features that depend on both the history and the class. With two classes it is logistic regression.
- Exponential family. For each history it is an exponential family distribution over with sufficient statistics , which explains the moment matching at the optimum.
- n-gram models. With one indicator feature for every n-gram of one order and no prior, the likelihood is maximized by the maximum likelihood n-gram model, in the limit where the weights of the unseen n-grams go to . With features of all orders up to it is a smoothed model in which each n-gram adds to the score of the shorter ones, in place of backoff.
- Sequence models. The maximum entropy Markov model uses the same conditional form for tags, and the conditional random field normalizes over whole tag sequences.
- Neural language models. A neural probabilistic language model has the same softmax output, but learns its features of the history with a hidden layer instead of using a fixed list.
- Cache models. A self-trigger feature does the work of a cache inside one model, and trigger pairs extend it to related words.
Known results in the model
- Duality. The maximum likelihood model in the log-linear family and the maximum entropy model under the expectation constraints are the same model (Berger, Della Pietra and Della Pietra 1996). The log-likelihood is concave in , so every local maximum is global, and the fitted distribution is unique when the constraints can be met.
- Generalized iterative scaling converges. Darroch and Ratcliff proved that GIS increases the likelihood at each step and converges to the solution, for non-negative features with a constant sum ; a slack feature makes any feature set meet this condition. Its steps shrink with , so it is slow with many active features.
- Triggers help. Rosenfeld (1996) selected trigger pairs by their mutual information and combined them with n-gram constraints in one maximum entropy model. On Wall Street Journal text this lowered the perplexity by 32 to 39 percent against a trigram model, and in the SPHINX-II recognizer it lowered the word error rate by 10 to 14 percent.
- Feature induction. Since any feature can be added, the choice of features is part of the fit. Berger and the Della Pietras add features one at a time by their gain in likelihood, a form of feature selection.
- No explicit backoff. Smoothing comes from the prior on the weights and from the features of shorter histories, not from a discount; an unseen n-gram simply has no feature.
References
- Ronald Rosenfeld, A maximum entropy approach to adaptive statistical language modelling, Computer Speech and Language 10(3), 1996, pages 187 to 228, trigger pairs, the maximum entropy model with n-gram and trigger constraints, and the results on Wall Street Journal text and in the SPHINX-II recognizer
- Berger, Della Pietra and Della Pietra 1996, the conditional maximum entropy model, its duality with maximum likelihood in the exponential family, and feature selection
- J. N. Darroch and D. Ratcliff, Generalized iterative scaling for log-linear models, Annals of Mathematical Statistics 43(5), 1972, pages 1470 to 1480, the generalized iterative scaling algorithm and its convergence
- E. T. Jaynes, Information theory and statistical mechanics, Physical Review 106(4), 1957, pages 620 to 630, the principle of maximum entropy
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 CNH4EZ Edit this page History Report an error Markdown