A Maximum Entropy Approach to Natural Language Processing

Berger et al., 1996, A Maximum Entropy Approach to Natural Language Processing (Computational Linguistics)

Subscriber deck — free during early access

30 cards

1 Introduction

  1. What are the two essential tasks of statistical modeling, according to Berger et al.?
    Feature selection (determining a set of statistics that capture the behavior of a random process) and model selection (corralling those facts into an accurate predictive model). Maximum entropy gives a unified approach to both.

2 A maximum entropy overview

  1. Model an expert translating English in into one of {dans, en, à, au cours de, pendant}, knowing only that set. What does maximum entropy choose?
    The uniform model: each phrase gets 1/5. Models like p(dans) = 1 assume more than we know.
  2. Add the fact that dans or en was chosen 30% of the time. What is the maximum entropy model now?
    Spread probability as evenly as the constraints allow: p(dans) = p(en) = 3/20, and p(à) = p(au cours de) = p(pendant) = 7/30. Adding a third fact (dans or à half the time) makes the most uniform model no longer obvious, which motivates a precise measure of uniformity.
  3. State the maximum entropy principle informally.
    Model all that is known and assume nothing about what is unknown: among models consistent with all the facts, choose the most uniform one.
  4. How is maximum entropy related to Laplace and Jaynes?
    Laplace’s Principle of Insufficient Reason: with no information to distinguish two events, treat them as equally likely. Jaynes: the maximum-entropy distribution agrees with everything known but carefully avoids assuming anything not known.

3.2 Statistics, features and constraints

  1. What is a feature in a maximum entropy model? Give an example.
    A binary-valued (indicator) function of a context \(x\) and output \(y\), e.g. \(f(x, y) = 1\) if \(y = \text{en}\) and April follows in, else 0. Any statistic of the sample can be expressed as the expected value of such a function.
  2. What is a constraint in a maximum entropy model?
    An equation requiring the model’s expected value of a feature to equal its empirical expected value: \(p(f) = \tilde{p}(f)\), i.e. \(\sum_{x,y} \tilde{p}(x)\, p(y \mid x)\, f(x, y) = \sum_{x,y} \tilde{p}(x, y)\, f(x, y)\). (Berger et al. insist on not confusing features with constraints.)

3.3 The maximum entropy principle

  1. How is the uniformity of a conditional model measured?
    By its conditional entropy \(H(p) = -\sum_{x,y} \tilde{p}(x)\, p(y \mid x) \log p(y \mid x)\), between 0 (no uncertainty) and \(\log |\mathcal{Y}|\) (uniform over outputs).
  2. State the maximum entropy principle formally.
    Given the set \(\mathcal{C}\) of models satisfying the constraints, choose \(p_* = \arg\max_{p \in \mathcal{C}} H(p)\). This model always exists and is unique.
  3. What can happen geometrically when linear constraints are imposed on the probability simplex?
    No constraint: any model allowed. One constraint: a line (hyperplane) of models. Two consistent constraints may pin down a single model, or be inconsistent. Constraints from a training sample are consistent by construction, and in practice leave an infinite set of models, from which maximum entropy picks one.
    C1C2all distributions over 3 outcomes

3.4 Exponential form

  1. What form does the maximum entropy model take?
    An exponential (log-linear) model with one parameter per feature: \(p_\lambda(y \mid x) = \frac{1}{Z_\lambda(x)} \exp\big(\sum_i \lambda_i f_i(x, y)\big)\), with \(Z_\lambda(x) = \sum_y \exp\big(\sum_i \lambda_i f_i(x, y)\big)\).
  2. How is the maximum entropy model found via Lagrange multipliers?
    Introduce a multiplier \(\lambda_i\) per constraint; maximizing the Lagrangian over \(p\) for fixed \(\lambda\) gives the exponential form \(p_\lambda\) and a dual function \(\Psi(\lambda)\). By the Kuhn–Tucker theorem the maximum entropy model is \(p_{\lambda^*}\) with \(\lambda^* = \arg\max_\lambda \Psi(\lambda)\).

3.5 Relation to maximum likelihood

  1. How are maximum entropy and maximum likelihood related?
    The dual function \(\Psi(\lambda)\) is exactly the log-likelihood \(L_{\tilde{p}}(p_\lambda) = \sum_{x,y} \tilde{p}(x, y) \log p_\lambda(y \mid x)\) of the training data. So the maximum entropy model subject to the constraints is the exponential model that maximizes the likelihood of the training sample.
    primalmaximum entropy: \(\arg\max_{p \in \mathcal{C}} H(p)\), constrained search over models
    dualmaximum likelihood: \(\arg\max_\lambda \Psi(\lambda)\), unconstrained search over \(\lambda\)
  2. Why is this duality an extra justification for maximum entropy?
    Even if choosing the most uniform model isn’t compelling in itself, the same model is the one in its parametric family that best accounts for the training sample.

3.6 Computing the parameters

  1. Why is the dual function convenient to optimize, and with which methods?
    It is smooth and concave in \(\lambda\), so standard numerical methods work: coordinate-wise ascent (the Brown algorithm), gradient methods, or iterative scaling designed for maximum entropy.
  2. Describe Improved Iterative Scaling (IIS).
    Start with all \(\lambda_i = 0\). Repeatedly, for each feature, find the increment \(\Delta\lambda_i\) solving \(\sum_{x,y} \tilde{p}(x)\, p(y \mid x)\, f_i(x, y)\, e^{\Delta\lambda_i f^\#(x, y)} = \tilde{p}(f_i)\), where \(f^\#(x, y) = \sum_i f_i(x, y)\) is the number of active features, and update \(\lambda_i \leftarrow \lambda_i + \Delta\lambda_i\) until convergence.
  3. What is the IIS update when every event has the same number \(M\) of active features?
    \(\Delta\lambda_i = \frac{1}{M} \log \frac{\tilde{p}(f_i)}{p_\lambda(f_i)}\); otherwise the increment is found numerically (e.g. Newton’s method). Darroch and Ratcliff’s original Generalized Iterative Scaling additionally requires features to sum to 1.

4 Feature selection

  1. Why is feature selection necessary in maximum entropy modeling?
    The principle only combines constraints; it doesn’t say which facts matter. Candidate features can number in the millions, and with a finite sample many empirical expectations \(\tilde{p}(f)\) are unreliable, so only a subset of “active” features should be used.
  2. How does incremental feature selection grow a maximum entropy model?
    Start with no features (the uniform model). At each step, for every candidate feature compute the gain in training log-likelihood from adding it, \(\Delta L(\mathcal{S}, f) = L(p_{\mathcal{S} \cup f}) - L(p_{\mathcal{S}})\), add the feature with the largest gain, re-fit, and repeat until a stopping criterion. Each added feature shrinks the set of allowed models.
  3. Why is basic feature selection impractical, and what approximation fixes it?
    It needs a full maximum entropy fit for every candidate at every step. Instead, assume adding \(f\) changes only its own new parameter \(\alpha\), keeping the other \(\lambda\)s fixed: the approximate gain is a one-dimensional optimization over \(\alpha\) (a line search, e.g. Newton’s method), at the cost of probably underestimating gains.
  4. How do Berger et al. decide when to stop adding features?
    Cross-validation: grow the model on part of the data and monitor log-likelihood on held-out data. Training likelihood keeps rising, but when held-out likelihood stops increasing the model has begun fitting noise (overtraining), so stop.

5.1 Review of statistical translation

  1. What was Candide, and how did it translate?
    IBM’s French-to-English statistical MT system: choose \(\hat{E} = \arg\max_E p(E)\, p(F \mid E)\) with a language model and a translation model (word fertilities, word translation probabilities and a distortion model) trained by EM on the Canadian Hansards.
  2. What shortcoming of the basic translation model motivated maximum entropy models in Candide?
    It ignores English context when translating a word: it always gives in the same probabilities for dans, pendant… regardless of whether “a month’s time” or “the fiscal year 1992” follows, leading to errors like supérieures → “superior” instead of “greater” before “50%”.

5.2 Context-dependent word models

  1. How were training events built for the context-dependent translation model of in?
    From Hansard sentence pairs: compute the Viterbi alignment, and for each occurrence of in take the context \(x\) = the six surrounding English words and the output \(y\) = the aligned French word.
  2. What feature templates did the in translation model use?
    templatef(x, y) = 1 iff …
    1y = ◇ (no context)
    2y = ◇ and the next word is □
    3y = ◇ and the previous word is □
    4y = ◇ and □ is among the 3 previous words
    5y = ◇ and □ is among the 3 next words
    ◇ is a French translation, □ an English word. Template 1 alone reproduces the context-free distribution.
  3. What did the feature selection algorithm learn for translating in?
    First a template-1 constraint for each translation seen, then context features chosen by approximate gain, e.g. that dans is more likely when speech is among the next three words; the run model showed a distinct “Hansard flavor” of parliamentary language.

5.3 Segmentation

  1. What is a rift, and why did Candide need safe segmentations?
    Candide’s processing time was exponential in input length, so long French sentences had to be split. A rift is a position \(j\) where all French words to the left align to English words left of \(y_j\)’s English word and all to the right align to the right; splitting only at rifts means no English word must account for French words in two segments.
  2. How was the rift model used to segment sentences?
    A maximum entropy model scored \(p(\text{rift} \mid x)\) at each position from a six-word window, POS tags and word classes; dynamic programming then chose segment boundaries with no segment longer than 10 words. Segments needn’t be semantically coherent, only translatable left to right.

5.4 Word reordering

  1. How was maximum entropy used for French NOUN de NOUN phrases?
    To predict whether the English translation swaps the nouns and drops de (taux d’intérêt → interest rate) or translates word for word (conflit d’intérêt → conflict of interest), using features on the left noun, the right noun, or both; it beat a baseline that never swaps.
  2. Why are features on both nouns needed in the NOUN de NOUN model?
    Some decisions depend on the pair: phrases ending in intérêt can go either way (conflit d’intérêt vs taux d’intérêt), and some, like taux d’inflation, can translate either way (inflation rate or rate of inflation).

Source

  • Adam L. Berger, Stephen A. Della Pietra and Vincent J. Della Pietra. 1996. A Maximum Entropy Approach to Natural Language Processing. In Computational Linguistics, pp. 39–71. https://aclanthology.org/J96-1002/