Module 2 • CS24351

Module 2: Language Modeling, Smoothing & POS Tagging

Topics 13 to 24 • N-grams, Perplexity, Laplace, Kneser-Ney, HMMs, Viterbi Decoding & CRFs

Module 2: N-gram Language Models, Smoothing Techniques & POS Tagging

📌 Syllabus & Pedagogical Blueprint (Topics 13 to 24)

Probabilistic Language Modeling • Chain Rule of Probability & Markov Independence Assumptions • N-gram Language Models (Unigram, Bigram, Trigram) • Maximum Likelihood Estimation (MLE) • The Zero-Probability Sparsity Catastrophe • Perplexity and Cross-Entropy Evaluation • Smoothing Formalisms: Laplace (Add-1), Add-$k$, Absolute Discounting, Jelinek-Mercer Linear Interpolation, Katz Backoff with Good-Turing Discounting, Kneser-Ney Smoothing (Interpolated & Modified) • Part-of-Speech (POS) Tagging • The Penn Treebank Tagset • Hidden Markov Models (HMM) for POS Tagging: Transition ($A$), Emission ($B$), and Initial ($\pi$) Distributions • The Viterbi Decoding Algorithm Trellis Trace • Forward-Backward Algorithm • Maximum Entropy Markov Models (MEMM) & The Label Bias Problem • Linear-Chain Conditional Random Fields (CRF) • 15 Solved University Examination Questions.

Topic 13: Probabilistic Language Models & The Markov Chain

A Language Model (LM) computes the joint probability distribution $P(W) = P(w_1, w_2, \dots, w_N)$ over word sequences, or computes the conditional probability of a next word $P(w_N \mid w_1, \dots, w_{N-1})$.

📐 The Chain Rule of Probability & The Markov Assumption

By exact probabilistic chain rule decomposition:

$$\mathbf{P(w_1, w_2, \dots, w_N) = \prod_{k=1}^N P(w_k \mid w_1, w_2, \dots, w_{k-1})}$$

Because conditioning on the entire unbounded history is computationally intractable, the $k$-th Order Markov Assumption approximates history using only the preceding $n-1$ words:

Topic 14: Maximum Likelihood Estimation (MLE) & Perplexity

In standard MLE, bigram probabilities are estimated via relative corpus frequencies:

$$\mathbf{P_{\text{MLE}}(w_i \mid w_{i-1}) = \frac{C(w_{i-1}, w_i)}{\sum_w C(w_{i-1}, w)} = \frac{C(w_{i-1}, w_i)}{C(w_{i-1})}}$$
📊 Evaluating Language Models: Perplexity Metric

Perplexity (PP) measures how surprised the language model is by an unseen test set $W = (w_1, \dots, w_N)$. A lower perplexity indicates a superior predictive model:

$$\mathbf{\text{PP}(W) = P(w_1, w_2, \dots, w_N)^{-\frac{1}{N}} = \sqrt[N]{\frac{1}{\prod_{i=1}^N P(w_i \mid w_{i-1})}} = 2^{H(W)}}$$ $$\text{where Cross-Entropy } H(W) = -\frac{1}{N} \sum_{i=1}^N \log_2 P(w_i \mid w_{i-1})$$

Topic 15: Comprehensive Smoothing Techniques

If an unseen bigram appears in test data ($C(w_{i-1}, w_i) = 0$), $P_{\text{MLE}} = 0$, causing the entire corpus probability to crash to zero and $\text{PP}(W) \rightarrow \infty$. Smoothing reallocates probability mass from frequent n-grams to zero-count events:

Smoothing Technique Mathematical Formulation Key Analytical Properties
Laplace (Add-1) $$P_{\text{Laplace}}(w_i \mid w_{i-1}) = \frac{C(w_{i-1}, w_i) + 1}{C(w_{i-1}) + |V|}$$ Assigns far too much probability mass to zero counts when vocabulary $|V|$ is large.
Add-$k$ (Lidstone) $$P_{\text{Lidstone}}(w_i \mid w_{i-1}) = \frac{C(w_{i-1}, w_i) + k}{C(w_{i-1}) + k|V|} \quad (0 < k < 1)$$ Requires optimizing hyperparameter $k$ on held-out validation data.
Jelinek-Mercer Interpolation $$P_{\text{JM}}(w_i \mid w_{i-1}) = \lambda P_{\text{MLE}}(w_i \mid w_{i-1}) + (1 - \lambda) P_{\text{MLE}}(w_i)$$ Linear combination of higher and lower-order models; $\lambda$ learned via EM.
Kneser-Ney (Interpolated) $$P_{\text{KN}}(w_i \mid w_{i-1}) = \frac{\max(C(w_{i-1}, w_i) - d, 0)}{C(w_{i-1})} + \lambda(w_{i-1}) P_{\text{cont}}(w_i)$$ Uses Continuation Probability $P_{\text{cont}}(w_i) = \frac{|\{w_{i-1} : C(w_{i-1}, w_i) > 0\}|}{\sum_w |\{w' : C(w', w) > 0\}|}$. State of the art!
🏛️ Solved Numerical 3: Kneser-Ney vs Unigram Probability Calculation

Consider the word "Francisco" in a corpus. It occurs 1000 times, but always and only immediately following the word "San" ($C(\text{San}, \text{Francisco}) = 1000$). Total bigram tokens = 100,000.

Topic 16: Hidden Markov Models (HMM) for Part-of-Speech Tagging

POS tagging maps a word sequence $W = (w_1, \dots, w_T)$ to an optimal sequence of grammatical tags $T = (t_1, \dots, t_T)$. In a generative HMM model:

$$\mathbf{\hat{T} = \arg\max_T P(T \mid W) = \arg\max_T \frac{P(W \mid T) P(T)}{P(W)} = \arg\max_T \prod_{i=1}^T \underbrace{P(w_i \mid t_i)}_{\text{Emission } b_{t_i}(w_i)} \underbrace{P(t_i \mid t_{i-1})}_{\text{Transition } a_{t_{i-1}, t_i}}}$$

The Viterbi Dynamic Programming Algorithm

Let $v_t(j)$ be the maximum probability of observing sequence $w_1 \dots w_t$ and ending in hidden state $j$ at time $t$:

$$\mathbf{v_t(j) = \max_{i=1}^{|S|} \left[ v_{t-1}(i) \cdot a_{ij} \right] \cdot b_j(w_t)}$$ $$\mathbf{\text{Backpointer: } \text{ptr}_t(j) = \arg\max_{i=1}^{|S|} \left[ v_{t-1}(i) \cdot a_{ij} \right]}$$
🏛️ Solved Numerical 4: Step-by-Step Viterbi Trellis Trace for POS Tagging

Given 2 POS states $\{\text{Noun (N), Verb (V)}\}$ and sentence $W = (\text{"Janet"}, \text{"will"}, \text{"back"})$.

Initial Probabilities: $\pi_N = 0.8, \pi_V = 0.2$.

Transitions ($A$): $P(N \mid N) = 0.4, P(V \mid N) = 0.6; \quad P(N \mid V) = 0.7, P(V \mid V) = 0.3$.

Emissions ($B$):

Step 1: $t=1$ ("Janet"):

Step 2: $t=2$ ("will"):

Step 3: $t=3$ ("back"):

Backtracking from Max Final State ($\max(v_3(N), v_3(V)) = v_3(N)$):

$$\hat{t}_3 = N \xrightarrow{\text{ptr}_3(N)} \hat{t}_2 = V \xrightarrow{\text{ptr}_2(V)} \hat{t}_1 = N \implies \mathbf{\hat{T} = (\text{Noun, Verb, Noun})}$$

Topic 17: Maximum Entropy Markov Models (MEMM) vs. Conditional Random Fields (CRF)

Model Probability Formulation & Normalization Key Architectural Trade-Off
HMM Generative joint model: $P(W, T) = \prod P(t_i \mid t_{i-1}) P(w_i \mid t_i)$. Fast, but cannot incorporate overlapping, arbitrary non-independent lexical features.
MEMM Discriminative: $P(T \mid W) = \prod P(t_i \mid t_{i-1}, \mathbf{x}_i) = \prod \frac{\exp(\mathbf{w}^T \mathbf{f}(t_i, t_{i-1}, \mathbf{x}))}{Z(t_{i-1}, \mathbf{x})}$. Local per-state normalization. Suffers from the Label Bias Problem: States with few outgoing transitions dominate paths regardless of observation evidence!
Linear-Chain CRF Discriminative: $P(T \mid W) = \frac{1}{Z(W)} \exp\left( \sum_{t=1}^T \sum_k w_k f_k(t_i, t_{i-1}, W, t) \right)$. Global sequence-level normalization. Completely eliminates Label Bias; provably optimal discriminative sequence labeler.

Topic 18: Master University Examination Question Bank (Module 2)

Q1. Prove why Perplexity is equal to $2^{H(W)}$ for base-2 cross-entropy. (6 Marks)
Let empirical cross-entropy be $H(W) = -\frac{1}{N} \log_2 P(w_1, \dots, w_N)$.
Then: $2^{H(W)} = 2^{-\frac{1}{N} \log_2 P(W)} = \left( 2^{\log_2 P(W)} \right)^{-\frac{1}{N}} = (P(W))^{-\frac{1}{N}} = \sqrt[N]{\frac{1}{P(w_1, \dots, w_N)}} \equiv \text{PP}(W)$. Q.E.D.
Q2. Explain the Label Bias Problem in MEMMs with a concrete state graph. (8 Marks)
In an MEMM, the transition probabilities from a given state must sum locally to 1 ($\sum_{s'} P(s' \mid s, x) = 1$). If state $S_1$ has only one outgoing transition to state $S_2$, then $P(S_2 \mid S_1, x) = 1.0$ regardless of how poorly the observation feature $x$ matches state $S_2$! In contrast, a Conditional Random Field (CRF) normalizes globally across all possible entire sequences via partition function $Z(\mathbf{x}) = \sum_{y'} \exp(\sum_t \mathbf{w}^T \mathbf{f}(y_t, y_{t-1}, \mathbf{x}))$, allowing subsequent strong evidence to overturn locally constrained transitions!
Q3. Detail the Forward and Backward Algorithms in HMMs and their computational complexity. (8 Marks)
• Forward Variable $\alpha_t(j) = P(w_1 \dots w_t, t_t=j \mid \lambda)$: Computes the total joint probability of observing the prefix sequence: $\alpha_t(j) = \sum_{i=1}^{|S|} \alpha_{t-1}(i) a_{ij} b_j(w_t)$.
• Backward Variable $\beta_t(i) = P(w_{t+1} \dots w_T \mid t_t=i, \lambda)$: Computes the conditional probability of future suffix emissions: $\beta_t(i) = \sum_{j=1}^{|S|} a_{ij} b_j(w_{t+1}) \beta_{t+1}(j)$.
Both run in $O(T \cdot |S|^2)$ time, compared to naive exhaustive evaluation $O(|S|^T)$! Used together in the Baum-Welch (EM) algorithm to estimate expected transition and emission counts.

Topic 19: Advanced Smoothing Formalisms — Good-Turing & Witten-Bell

Good-Turing estimation reallocates probability mass based on the frequency of frequencies:

📐 Good-Turing Frequency of Frequencies Formulation

Let $N_r$ be the number of distinct n-grams that occurred exactly $r$ times in the training corpus. The adjusted Good-Turing count $r^*$ for an n-gram seen $r$ times is:

$$\mathbf{r^* = (r + 1) \frac{N_{r+1}}{N_r}}$$ $$\mathbf{\text{Total Probability Mass Assigned to Unseen Events } (r=0): \ P_0 = \frac{N_1}{N}}$$

Where $N = \sum_{r=1}^\infty r N_r$ is the total number of observed token instances. The probability of an n-gram with count $r$ is $P_{\text{GT}} = \frac{r^*}{N}$.

🏛️ Solved Numerical 7: Complete Good-Turing Discounting Calculation

In a corpus of $N = 100,000$ tokens, count statistics are: $N_1 = 20,000$ (singletons), $N_2 = 5,000$, $N_3 = 2,000$, $N_4 = 1,000$.

Topic 20: HMM Training via the Baum-Welch (EM) Algorithm

When training sequences lack labeled hidden state annotations, the Baum-Welch Algorithm iteratively optimizes HMM parameters $\lambda = (A, B, \pi)$ to maximize marginal observation likelihood $P(W \mid \lambda)$:

  1. Expectation (E-step): Compute forward probabilities $\alpha_t(i)$ and backward probabilities $\beta_t(i)$. $$\mathbf{\gamma_t(i) = P(t_t = q_i \mid W, \lambda) = \frac{\alpha_t(i)\beta_t(i)}{\sum_{j=1}^{|S|} \alpha_t(j)\beta_t(j)}}$$ $$\mathbf{\xi_t(i, j) = P(t_t = q_i, t_{t+1} = q_j \mid W, \lambda) = \frac{\alpha_t(i) a_{ij} b_j(w_{t+1}) \beta_{t+1}(j)}{\sum_k \sum_m \alpha_t(k) a_{km} b_m(w_{t+1}) \beta_{t+1}(m)}}$$
  2. Maximization (M-step): Re-estimate parameters by normalized expected event transitions: $$\mathbf{\hat{a}_{ij} = \frac{\sum_{t=1}^{T-1} \xi_t(i, j)}{\sum_{t=1}^{T-1} \gamma_t(i)} \qquad \hat{b}_j(k) = \frac{\sum_{t=1, w_t=v_k}^T \gamma_t(j)}{\sum_{t=1}^T \gamma_t(j)} \qquad \hat{\pi}_i = \gamma_1(i)}$$

Topic 24: Advanced Probability Formalisms & University Exam Problem Bank (Part II)

🏛️ Solved Numerical 10: Trigram Perplexity Calculation on Test Sentence

Given test sentence $S = \text{" I love NLP "}$ ($N = 4$ tokens: `I`, `love`, `NLP`, ``).

Learned Trigram Conditional Probabilities:

1. Joint Sentence Probability:

$$P(S) = 0.25 \times 0.50 \times 0.10 \times 0.20 = 0.0025 = 2.5 \times 10^{-3}$$

2. Test Set Perplexity ($N = 4$):

$$\mathbf{\text{PP}(S) = \left( \frac{1}{0.0025} \right)^{1/4} = (400)^{0.25} \approx \mathbf{4.472}}$$

Interpretation: At each word position, the language model is as uncertain as if choosing uniformly from among $4.47$ possible words!

Q4. Compare Katz Backoff with Jelinek-Mercer Linear Interpolation. (8 Marks)
• Jelinek-Mercer Interpolation: Always combines higher and lower-order n-gram estimates ($P_{\text{JM}} = \lambda_3 P(w_i \mid w_{i-2}, w_{i-1}) + \lambda_2 P(w_i \mid w_{i-1}) + \lambda_1 P(w_i)$), even when high-order counts are large.
• Katz Backoff: Uses the high-order MLE count discounted by Good-Turing ($d_r$) if $C(w_{i-k}^i) > 0$. It backs off to lower-order models only when the high-order n-gram count is zero ($C=0$), scaling the lower-order estimate by backoff normalization factor $\alpha(w_{i-k}^{i-1})$ so total probability sums strictly to 1.0!
Q5. Explain the Linear-Chain Conditional Random Field (CRF) Feature Functions and Viterbi Inference. (8 Marks)
In a linear-chain CRF, the conditional probability of label sequence $\mathbf{y}$ given observation sequence $\mathbf{x}$ is: $$\mathbf{P(\mathbf{y} \mid \mathbf{x}) = \frac{1}{Z(\mathbf{x})} \exp\left( \sum_{t=1}^T \sum_{k=1}^K w_k f_k(y_t, y_{t-1}, \mathbf{x}, t) \right)}$$ Where $f_k$ are arbitrary feature functions (e.g., $f_1 = 1$ if $y_t = \text{PROPN}$ and $x_t$ starts with capital letter). Unlike HMMs, CRFs support arbitrary overlapping, non-independent features, and normalize globally via partition function $Z(\mathbf{x})$, completely eliminating the label bias problem!

Topic 24.3: Master University Exam Problem Bank (Part III)

🏛️ Solved Problem 11: Modified Kneser-Ney Smoothing with 3 Distinct Discount Parameters

Standard Kneser-Ney uses a single constant discount $d$. Modified Kneser-Ney (Chen & Goodman 1996) utilizes 3 distinct discounts $d_1, d_2, d_{3+}$ based on whether the n-gram count is 1, 2, or $\ge 3$:

$$\mathbf{d_1 = 1 - 2Y\frac{N_2}{N_1}, \quad d_2 = 2 - 3Y\frac{N_3}{N_2}, \quad d_{3+} = 3 - 4Y\frac{N_4}{N_3} \quad \text{where } Y = \frac{N_1}{N_1 + 2N_2}}$$

Provides the most empirically accurate statistical language modeling probability estimates in computational linguistics!

Q6. Explain the Log-Probability Formulation in Viterbi Decoding to Prevent Numerical Underflow. (8 Marks)
In standard Viterbi decoding, sequence probabilities are computed via multiplying dozens of small floating-point emission and transition probabilities ($P \approx 10^{-4}$): $$v_t(j) = \max_i [v_{t-1}(i) \cdot a_{ij}] \cdot b_j(w_t)$$ For a sentence of length $T = 30$, multiplying 30 small probabilities produces values below $10^{-60}$, causing catastrophic 64-bit IEEE floating-point numerical underflow to zero ($0.0$).
• Log-Viterbi Transformation: Transform all operations into log-space: $$\mathbf{V_t(j) = \max_{i} \left[ V_{t-1}(i) + \ln(a_{ij}) \right] + \ln(b_j(w_t))}$$ Replaces multiplications with additions and handles arbitrary sequence lengths $T$ with zero precision loss!
Q7. Detail the Witten-Bell Smoothing Algorithm and Compare it with Good-Turing. (8 Marks)
Witten-Bell Smoothing models zero-count events as the arrival of a previously unseen token. It defines the probability of seeing a novel word based on the number of distinct word types $T(w_{i-1})$ that have already been observed following history $w_{i-1}$:
$$\mathbf{\lambda(w_{i-1}) = 1 - \frac{T(w_{i-1})}{T(w_{i-1}) + C(w_{i-1})} = \frac{C(w_{i-1})}{C(w_{i-1}) + T(w_{i-1})}}$$ $$P_{\text{WB}}(w_i \mid w_{i-1}) = \frac{C(w_{i-1}, w_i)}{C(w_{i-1}) + T(w_{i-1})} + \frac{T(w_{i-1})}{C(w_{i-1}) + T(w_{i-1})} P(w_i)$$ Unlike Good-Turing (which requires global frequency-of-frequency counts $N_r$), Witten-Bell computes parameters directly from local history statistics.
🏛️ Solved Problem 16: Linear-Chain CRF Forward-Backward Variable Recursion

In a Linear-Chain CRF with potential functions $\psi_t(y_{t-1}, y_t, \mathbf{x}) = \exp(\sum_k w_k f_k(y_t, y_{t-1}, \mathbf{x}, t))$:

  • Forward Variable $\alpha_t(j)$: Unnormalized score of prefix paths ending in state $j$ at time $t$: $$\mathbf{\alpha_t(j) = \sum_{i=1}^{|S|} \alpha_{t-1}(i) \psi_t(i, j, \mathbf{x}) \qquad \alpha_1(j) = \psi_1(\text{start}, j, \mathbf{x})}$$
  • Backward Variable $\beta_t(i)$: Unnormalized score of suffix paths starting from state $i$ at time $t$: $$\mathbf{\beta_t(i) = \sum_{j=1}^{|S|} \psi_{t+1}(i, j, \mathbf{x}) \beta_{t+1}(j) \qquad \beta_T(i) = 1.0}$$
  • Global Partition Function: $Z(\mathbf{x}) = \sum_{j=1}^{|S|} \alpha_T(j)$. Marginal probability: $P(y_t = j \mid \mathbf{x}) = \frac{\alpha_t(j)\beta_t(j)}{Z(\mathbf{x})}$.
Q8. Explain Cross-Entropy Loss in Language Model Training and its Relationship to Perplexity. (8 Marks)
During language model training with true one-hot next-word targets $y_t$ and predicted probabilities $\hat{y}_t$, the token-level cross-entropy loss is: $$\mathcal{L}_t = -\sum_{w=1}^{|V|} y_{t, w} \log_2 \hat{y}_{t, w} = -\log_2 P(w_t \mid w_{Perplexity is the exponential of cross-entropy: $\text{PP}(W) = 2^{H(W)}$. Minimizing cross-entropy loss via gradient descent directly minimizes test set perplexity!
🏛️ Solved Problem 17: Maximum Entropy / Logistic Regression POS Tagger Feature Weights

In a Maximum Entropy POS tagger, the conditional probability of tag $t$ given context $h$ is: $P(t \mid h) = \frac{1}{Z(h)}\exp(\sum_i \lambda_i f_i(h, t))$.

  • Feature 1 ($f_1$): Word ends in `-ing` and $t = \text{VBG}$ ($\lambda_1 = +2.5$).
  • Feature 2 ($f_2$): Previous tag is $\text{TO}$ and $t = \text{VB}$ ($\lambda_2 = +3.1$).
  • Feature 3 ($f_3$): Word starts with Capital and $t = \text{NNP}$ ($\lambda_3 = +4.0$).
🏛️ Solved Problem 18: Trigram Jelinek-Mercer Expectation-Maximization $\lambda$ Estimation

Linear interpolation weights $\lambda_1, \lambda_2, \lambda_3$ ($\sum \lambda_i = 1$) are learned on held-out validation corpus using EM:

$$\lambda_i^{(t+1)} = \frac{1}{N_{\text{heldout}}} \sum_{k=1}^{N_{\text{heldout}}} \frac{\lambda_i^{(t)} P_i(w_k \mid \text{history}_k)}{\sum_j \lambda_j^{(t)} P_j(w_k \mid \text{history}_k)}$$
🏛️ Solved Problem 26: Cross-Entropy & Shannon Entropy in N-Gram Language Models

Prove that minimizing relative entropy (Kullback-Leibler Divergence $D_{\text{KL}}(P || Q)$) is strictly equivalent to minimizing cross-entropy loss $H(P, Q)$:

$$D_{\text{KL}}(P || Q) = \sum_{x} P(x) \log_2 \frac{P(x)}{Q(x)} = \sum_{x} P(x) \log_2 P(x) - \sum_{x} P(x) \log_2 Q(x) = -H(P) + H(P, Q)$$ $$\mathbf{\arg\min_Q D_{\text{KL}}(P || Q) \equiv \arg\min_Q H(P, Q) \quad (\text{Since true data entropy } H(P) \text{ is constant!})}$$
🏛️ Solved Problem 27: Absolute Discounting with Interpolation Formula

Given discount $d = 0.75$: $P_{\text{Absolute}}(w_i \mid w_{i-1}) = \frac{\max(C(w_{i-1}, w_i) - 0.75, 0)}{C(w_{i-1})} + \frac{0.75 \times |\{w: C(w_{i-1}, w) > 0\}|}{C(w_{i-1})} P(w_i)$.

🏛️ Solved Problem 38: Trigram Smoothing with Katz Backoff & Good-Turing Multipliers

In Katz Backoff, the probability of trigram $w_i \mid w_{i-2}, w_{i-1}$ is formulated as:

$$P_{\text{Katz}}(w_i \mid w_{i-2}, w_{i-1}) = \begin{cases} d_r \frac{C(w_{i-2}^i)}{C(w_{i-2}^{i-1})} & \text{if } C(w_{i-2}^i) > 0 \\ \alpha(w_{i-2}, w_{i-1}) P_{\text{Katz}}(w_i \mid w_{i-1}) & \text{if } C(w_{i-2}^i) = 0 \end{cases}$$

Where backoff weight $\alpha(w_{i-2}, w_{i-1}) = \frac{1 - \sum_{w: C>0} P_{\text{Katz}}(w \mid w_{i-2}, w_{i-1})}{1 - \sum_{w: C>0} P_{\text{Katz}}(w \mid w_{i-1})}$. Ensures exact conservation of total probability mass!

🏛️ Solved Problem 46: Trigram Language Model Linear Interpolation Grid Search

Optimize weights $\lambda_1, \lambda_2, \lambda_3$ on validation cross-entropy $H(V) = -\frac{1}{N}\sum \log_2(\lambda_3 P_3 + \lambda_2 P_2 + \lambda_1 P_1)$:

  • Trial 1: $(\lambda_1, \lambda_2, \lambda_3) = (0.1, 0.3, 0.6) \implies H(V) = 4.12 \text{ bits/token} \implies \text{PP} = 17.39$.
  • Trial 2: $(\lambda_1, \lambda_2, \lambda_3) = (0.05, 0.25, 0.70) \implies H(V) = 3.98 \text{ bits/token} \implies \mathbf{\text{PP} = 15.78 \ (Optimal!)}}$.
🏛️ Solved Problem 47: HMM Initial State & Transition Probability Smoothing

Apply Laplace smoothing to HMM transition matrix: $A_{ij} = \frac{C(t_{i-1}, t_i) + 1}{\sum_k C(t_{i-1}, t_k) + |S|}$, guaranteeing non-zero transitions for all grammatical POS pairs!

🏛️ Solved Problem 55: Forward-Backward State Posterior Decoding

In HMMs, state posterior probability $\gamma_t(i) = P(t_t = q_i \mid W) = \frac{\alpha_t(i)\beta_t(i)}{\sum_j \alpha_t(j)\beta_t(j)}$ allows computing the expected number of transitions from state $i$ during Baum-Welch training!

🏛️ Solved Problem 63: Trigram Good-Turing Discounting on Sparse Web Corpora

In a 1-billion-word web crawl, $N_1 = 40,000,000$ singleton trigrams, $N_2 = 10,000,000$ doubletons. $P_0 = \frac{40M}{1B} = \mathbf{0.040 = 4.0\%}$ total probability mass is safely reserved for previously unseen novel trigram sequences!

🏛️ Solved Problem 70: Viterbi Trellis Backpointer Array Proof

Prove by induction that the Viterbi dynamic programming backpointer array $\text{ptr}_t(j)$ recovers the globally optimal sequence $\hat{T}_{1..T}$ with zero heuristic approximation error!

🏛️ Solved Problem 74: Trigram Perplexity vs Bigram Perplexity Comparative Analysis

On the Penn Treebank test corpus, standard Bigram MLE achieves Perplexity $\text{PP} \approx 170$, whereas Trigram with Kneser-Ney smoothing drops Perplexity to $\mathbf{\text{PP} \approx 109}$, demonstrating a $35\%$ reduction in predictive uncertainty!

🏛️ Solved Problem 78: Maximum Entropy Markov Model (MEMM) Objective Function Proof

In MEMMs, parameters $\mathbf{w}$ are learned by maximizing conditional log-likelihood with $L_2$ Gaussian regularization: $\mathcal{L}(\mathbf{w}) = \sum_{i} \sum_{t} \left[ \mathbf{w}^T \mathbf{f}(y_{i, t}, y_{i, t-1}, \mathbf{x}_i) - \ln Z(y_{i, t-1}, \mathbf{x}_i) \right] - \frac{\|\mathbf{w}\|^2}{2\sigma^2}$. Optimized via L-BFGS in linear time!

🏛️ Solved Problem 85: Trigram Jelinek-Mercer vs Absolute Discounting

In Absolute Discounting: $P(w_i \mid w_{i-1}) = \frac{\max(C(w_{i-1}, w_i) - d, 0)}{C(w_{i-1})} + \frac{d \cdot |\{w: C(w_{i-1}, w) > 0\}|}{C(w_{i-1})} P(w_i)$. Subtracts constant $d \approx 0.75$ from all seen bigrams to fund lower-order unigram probability!

🏛️ Solved Problem 91: Trigram Witten-Bell Dynamic Weight Trace

In Witten-Bell smoothing: $\lambda(w_{i-1}) = \frac{C(w_{i-1})}{C(w_{i-1}) + T(w_{i-1})}$. If history $w_{i-1}$ has count $C = 100$ and precedes $T = 20$ distinct word types, $\lambda = \frac{100}{120} = \mathbf{0.8333}$, reserving $16.67\%$ mass for novel unseen transitions!

🏛️ Solved Problem 97: HMM State Sequence Viterbi Dynamic Programming Invariance

Show that adding a constant $\log C$ to all transition and emission log-probabilities shifts all path scores uniformly without changing the $\arg\max$ argmax state sequence!

🏛️ Solved Problem 101: Absolute Discounting Modified Interpolation Proof

Prove that for any vocabulary $V$, the sum of smoothed conditional probabilities $\sum_{w \in V} P_{\text{Absolute}}(w \mid w_{i-1}) = 1.0$ strictly conserves probability mass.