Module 5 • CS24351

Module 5: Core Applications, Evaluation Metrics & Ethics in NLP

Topics 46 to 53 • Machine Translation BLEU, Summarization ROUGE, RAG, NER & Algorithmic De-Biasing

Module 5: Core Applications, Evaluation Metrics & Ethics in NLP

📌 Syllabus & Pedagogical Blueprint (Topics 46 to 53)

Text Classification & Sentiment Analysis • Aspect-Based Sentiment Analysis (ABSA) • Named Entity Recognition (NER) & Sequence Tagging Schemas (BIO, BILOU) • BiLSTM-CRF Architecture for NER • Machine Translation: Statistical (SMT) vs. Neural (NMT) • Beam Search Decoding Mechanics • Exact Mathematical Formulation of the BLEU Metric with Brevity Penalty • Text Summarization: Extractive (TextRank / LexRank) vs. Abstractive (Seq2Seq with Copy/Coverage Mechanisms) • ROUGE-1, ROUGE-2, ROUGE-L Evaluation • Question Answering (Extractive SQuAD exact match/F1 vs. Retrieval-Augmented Generation / RAG) • Dialogue Systems (Task-Oriented vs. Open-Domain LLM Chatbots) • Ethics, Algorithmic Bias, De-biasing Word Embeddings, LLM Hallucinations & Environmental Sustainability • 15 Solved University Examination Questions.

Topic 46: Machine Translation & The BLEU Evaluation Metric

The standard benchmark for automated machine translation evaluation is the Bilingual Evaluation Understudy (BLEU - Papineni et al. 2002) metric, measuring modified n-gram precision penalized by brevity:

📐 Exact Mathematical Formulation of BLEU Score
$$\mathbf{\text{BLEU} = \text{BP} \cdot \exp\left( \sum_{n=1}^N w_n \ln p_n \right)}$$ $$\text{Modified Precision: } p_n = \frac{\sum_{C \in \{\text{Candidates}\}} \sum_{\text{n-gram} \in C} \text{Count}_{\text{clip}}(\text{n-gram})}{\sum_{C \in \{\text{Candidates}\}} \sum_{\text{n-gram} \in C} \text{Count}(\text{n-gram})}$$ $$\mathbf{\text{Brevity Penalty (BP): } \text{BP} = \begin{cases} 1 & \text{if } c > r \\ \exp\left( 1 - \frac{r}{c} \right) & \text{if } c \le r \end{cases}}$$

Where $c$ is the candidate translation length and $r$ is the effective reference corpus length (equal weights $w_n = 1/N$, typically $N=4$).

🏛️ Solved Numerical 5: Complete BLEU-1 and BLEU-2 Score Calculation

Candidate Translation ($c = 6$): "the cat the cat on the"

Reference Translation 1 ($r_1 = 6$): "the cat sat on the mat"

Reference Translation 2 ($r_2 = 6$): "there is a cat on mat"

1. Unigram Precision ($p_1$):

2. Bigram Precision ($p_2$):

3. Brevity Penalty ($c = 6, r = 6$): $c = r \implies \mathbf{\text{BP} = 1.0}$.

$$\mathbf{\text{BLEU-2} = 1.0 \times \exp(0.5 \ln(0.6667) + 0.5 \ln(0.6000)) = \sqrt{0.6667 \times 0.6000} = \sqrt{0.4000} = \mathbf{0.6325 \ (63.25\%)}}$$

Topic 47: Text Summarization & The ROUGE Evaluation Metric

ROUGE (Recall-Oriented Understudy for Gisting Evaluation - Lin 2004) measures the n-gram recall of candidate summaries against gold-standard human reference summaries:

$$\mathbf{\text{ROUGE-N} = \frac{\sum_{S \in \{\text{References}\}} \sum_{\text{n-gram} \in S} \text{Count}_{\text{match}}(\text{n-gram})}{\sum_{S \in \{\text{References}\}} \sum_{\text{n-gram} \in S} \text{Count}(\text{n-gram})}}$$ $$\mathbf{\text{ROUGE-L} = \frac{\text{LCS}(\text{Reference}, \text{Candidate})}{|\text{Reference}|} \quad (\text{Longest Common Subsequence})}$$

Topic 48: Retrieval-Augmented Generation (RAG) Architecture

Large Language Models suffer from hallucinations and frozen knowledge cutoffs. RAG (Lewis et al. 2020) augments generative transformers with dynamic external retrieval:

  1. Dense Indexing: Chunk knowledge base documents and encode chunks into dense vectors using a bi-encoder (e.g., DPR, BGE-embeddings). Index vectors into a vector database (FAISS, HNSW).
  2. Dense Retrieval: Encode user query $\mathbf{q}$ and retrieve top-$k$ most similar document passages via Cosine similarity.
  3. Prompt Synthesis & Generation: Concatenate retrieved passages as context into the prompt: "Answer query Q strictly using context C" $\rightarrow$ feed into LLM generator.

Topic 49: Ethics, Algorithmic Bias & De-biasing Word Vectors

Word embeddings trained on uncurated corpora learn harmful societal and gender stereotypes (e.g., $\mathbf{v}_{\text{doctor}} - \mathbf{v}_{\text{man}} + \mathbf{v}_{\text{woman}} \approx \mathbf{v}_{\text{nurse}}$). Bolukbasi et al. (2016) proposed geometric de-biasing:

  1. Identify Gender Subspace ($\mathbf{g}$): Compute PCA on difference vectors of defining gender pairs ($\mathbf{v}_{\text{she}} - \mathbf{v}_{\text{he}}$, $\mathbf{v}_{\text{woman}} - \mathbf{v}_{\text{man}}$).
  2. Hard De-biasing (Neutralization): Project gender-neutral words (e.g., `doctor`, `programmer`, `nurse`) to remove their component in the gender direction: $$\mathbf{\mathbf{w}_{\text{neutralized}} = \mathbf{w} - (\mathbf{w} \cdot \mathbf{g})\mathbf{g}}$$
  3. Equalization: Ensure gender-neutral words have equal distance to paired gender words ($\|\mathbf{w} - \mathbf{v}_{\text{grandmother}}\| = \|\mathbf{w} - \mathbf{v}_{\text{grandfather}}\|$).

Topic 50: Master University Examination Question Bank (Module 5)

Q1. Compare Extractive Summarization (TextRank) vs. Abstractive Summarization (T5/BART). (8 Marks)
• Extractive Summarization (TextRank): Builds a sentence-level graph where edge weights represent sentence similarity ($w_{ij} = \frac{|S_i \cap S_j|}{\log|S_i| + \log|S_j|}$). Runs PageRank centrality algorithm to identify the top $k$ most salient verbatim sentences. Guaranteed grammatically correct, but lacks cohesion and cannot paraphrase.
• Abstractive Summarization: Uses sequence-to-sequence transformers (BART, T5) to synthesize novel phrasing, compress clauses, and generate human-like summaries. Prone to hallucinating factual errors.
Q2. Explain Named Entity Recognition BIO vs BILOU Tagging Schemes. (6 Marks)
• BIO (IOB2): `B-Type` (Beginning of entity), `I-Type` (Inside continuation), `O` (Outside). Example: `[New(B-LOC), York(I-LOC), City(I-LOC), is(O)]`.
• BILOU: Explicitly distinguishes singleton entities: `B-Type` (Beginning), `I-Type` (Inside), `L-Type` (Last token of multi-token entity), `O` (Outside), and `U-Type` (Unique single-token entity). Gives higher discriminative power to CRF sequence labelers!

Topic 51: Beam Search Decoding Mechanics in Sequence Generation

Greedy search selects the single most probable next token $\arg\max_w P(w \mid y_{Beam Search maintains a beam of the top $B$ most probable candidate sequences:

🏛️ Solved Numerical 8: Step-by-Step Beam Search Trace ($B = 2$)

Translate input sentence with Beam Width $B = 2$ across 2 decoding time steps:

Length Normalization: Scores are normalized by $\frac{1}{T^\alpha}$ ($\alpha \approx 0.7$) to prevent unfair bias against longer sentence translations!

Topic 52: BiLSTM-CRF Architecture for Named Entity Recognition (NER)

Modern sequence labelers combine bidirectional recurrent neural feature extraction with global Conditional Random Field transition modeling:

  1. Word & Character Embeddings: Words are represented via pre-trained embeddings concatenated with character-level CNN/BiLSTM vectors.
  2. BiLSTM Layer: Forward LSTM ($\overrightarrow{\mathbf{h}}_t$) and backward LSTM ($\overleftarrow{\mathbf{h}}_t$) capture bidirectional unbounded contextual representations $\mathbf{h}_t = [\overrightarrow{\mathbf{h}}_t; \overleftarrow{\mathbf{h}}_t]$.
  3. CRF Layer: Learns a global state transition matrix $\mathbf{A}_{i, j} = P(tag_j \mid tag_i)$ that enforces valid syntactic constraints (e.g., prohibiting `I-PER` immediately following `O` without an intervening `B-PER`!).

Topic 53: Advanced Downstream Tasks & University Exam Problem Bank (Part II)

🏛️ Solved Numerical 13: ROUGE-1, ROUGE-2, and ROUGE-L Summarization Metrics Calculation

Generated Summary ($C$): "the prime minister visited london yesterday" (5 words)

Reference Summary ($R$): "prime minister visited london on monday" (6 words)

Q3. Detail the Extractive Question Answering Architecture for SQuAD with Span Boundary Logits. (8 Marks)
In extractive Question Answering (e.g., SQuAD), input text is formatted as `[CLS] Query Tokens [SEP] Passage Context Tokens [SEP]`.
1. Passage contextual embeddings $\mathbf{h}_i \in \mathbb{R}^d$ are passed to two linear classification heads $\mathbf{w}_s, \mathbf{w}_e \in \mathbb{R}^d$.
2. Start and End span probabilities are computed via softmax across all context tokens: $$P_{\text{start}}(i) = \frac{\exp(\mathbf{w}_s^T \mathbf{h}_i)}{\sum_j \exp(\mathbf{w}_s^T \mathbf{h}_j)} \qquad P_{\text{end}}(j) = \frac{\exp(\mathbf{w}_e^T \mathbf{h}_j)}{\sum_k \exp(\mathbf{w}_e^T \mathbf{h}_k)}$$ 3. The predicted answer span $(i^*, j^*)$ maximizes $P_{\text{start}}(i) \times P_{\text{end}}(j)$ subject to constraint $i \le j \le i + L_{\text{max}}$.

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

🏛️ Solved Problem 14: Aspect-Based Sentiment Analysis (ABSA) Pipeline

In ABSA, review sentence $S = \text{"The pasta was delicious but the service was terrible"}$ contains multiple polarities across distinct aspects:

  1. Aspect Term Extraction (ATE): Sequence tagging identifies aspect terms: `pasta` (Target 1), `service` (Target 2).
  2. Aspect Term Polarity Classification (APTC): Encodes sentence with target aspect marker: `[CLS] S [SEP] pasta [SEP] -> Positive (98%)`; `[CLS] S [SEP] service [SEP] -> Negative (95%)`.
Q4. Detail the Pointer-Generator Network for Abstractive Summarization with Out-Of-Vocabulary Copying. (8 Marks)
Pointer-Generator Networks (See et al. 2017) solve two major limitations of standard seq2seq summarizers: factual hallucinations and inability to produce out-of-vocabulary names/numbers.
1. Generation Probability $p_{\text{gen}} \in [0, 1]$: Computes a soft gating switch from decoder context $\mathbf{c}_t$, hidden state $\mathbf{s}_t$, and input $\mathbf{x}_t$: $$p_{\text{gen}} = \sigma(\mathbf{w}_{c}^T \mathbf{c}_t + \mathbf{w}_{s}^T \mathbf{s}_t + \mathbf{w}_{x}^T \mathbf{x}_t + b_{\text{ptr}})$$ 2. Hybrid Output Distribution: Interpolates between generating from vocabulary and copying directly from source text via attention weights $a_i^t$: $$\mathbf{P(w) = p_{\text{gen}} P_{\text{vocab}}(w) + (1 - p_{\text{gen}}) \sum_{i: w_i = w} a_i^t}$$ 3. Coverage Mechanism: Maintains a running sum of attention weights $c_i^t = \sum_{t'=1}^{t-1} a_i^{t'}$ and penalizes repeatedly attending to the same source words, completely eliminating repetitive loop summaries!
Q5. Explain Statistical Watermarking for LLM-Generated Text (Kirchenbauer et al. 2023). (8 Marks)
To detect AI-generated text without changing perplexity:
1. When sampling token $t$, use previous token hash $h(x_{t-1})$ as a pseudo-random seed to partition the vocabulary $V$ into a Green List $G$ (size $\gamma |V|$) and a Red List $R$.
2. Add a positive bias $\delta$ to the logits of green tokens: $\tilde{z}_k = z_k + \delta$ for $k \in G$.
3. Statistical Detection Test: For a candidate text of $T$ tokens, count green tokens $|T|_G$. Under human text, $|T|_G \sim \text{Binomial}(T, \gamma)$. Under watermarked text, $|T|_G \gg \gamma T$. A one-sided $Z$-score $z = \frac{|T|_G - \gamma T}{\sqrt{T\gamma(1-\gamma)}} > 4.0$ detects synthetic AI text with $p < 0.0001$ error rate!
🏛️ Solved Problem 19: Dense Passage Retrieval (DPR) Dual-Encoder Dot-Product Scoring

In modern Retrieval-Augmented Generation (RAG), traditional BM25 lexical search is replaced with dense semantic retrieval:

Q6. Explain the Carbon Footprint & Environmental Impact of Pretraining Large Language Models. (6 Marks)
Pretraining frontier LLMs (GPT-4, LLaMA-3 405B) requires clusters of thousands of high-power GPUs (Nvidia H100) running continuously for months, consuming megawatts of electrical power (hundreds of megawatt-hours) and generating tons of equivalent $CO_2$ carbon emissions.
• Mitigation Strategies: (1) Energy-efficient data center siting near renewable hydro/solar power, (2) Parameter-Efficient Fine-Tuning (LoRA / QLoRA), (3) Model quantization (4-bit GPTQ, AWQ, GGUF), and (4) Knowledge distillation into compact edge SLMs (Phi-3, Gemma).
🏛️ Solved Problem 23: Complete METEOR & chrF Translation Evaluation Metrics

• METEOR (Banerjee & Lavie 2005): Computes unigram harmonic mean precision and recall ($F_{\text{mean}} = \frac{10 P R}{R + 9 P}$) with explicit penalty for fragmented word order ($Penalty = 0.5 \times (\frac{\#chunks}{\#unigrams})^3$), incorporating exact match, WordNet synsets, and Porter stems.
• chrF (Popović 2015): Measures character n-gram F-score (typically 6-grams), completely eliminating language-dependent tokenizers and achieving superior correlation with human judgments on morphologically complex languages!

🏛️ Solved Problem 24: Dialogue State Tracking (DST) & Belief State Representation

In Task-Oriented Dialogue systems (MultiWOZ benchmark), the Belief State tracks user slot-value pairs across turns:

$$\text{Belief State: } \{\text{domain: 'restaurant'}, \text{food: 'italian'}, \text{price: 'moderate'}, \text{area: 'centre'}, \text{people: 4}\}$$

Dialogue Policy $\pi(a_t \mid s_t)$ maps belief state $s_t$ to system action $a_t = \text{Offer(Restaurant\_Name="Pizza Express")}$, and NLG converts action to natural utterance.

🏛️ Solved Problem 34: TextRank Sentence Graph PageRank Convergence Formula

In TextRank (Mihalcea & Tarau 2004), let $G = (V, E)$ be a graph where nodes are sentences and edge weights $w_{ij}$ represent token overlap similarity:

$$\mathbf{WS}(V_i) = (1 - d) + d \sum_{V_j \in \text{In}(V_i)} \frac{w_{ji}}{\sum_{V_k \in \text{Out}(V_j)} w_{jk}} WS(V_j) \quad (d = 0.85)}$$

Iterates power method until $|WS^{(t+1)} - WS^{(t)}| < 10^{-4}$, extracting top $k$ sentences with highest stationary centrality scores!

🏛️ Solved Problem 35: Contrastive Representation Learning with InfoNCE Loss

In modern dense retrieval (DPR, Contriever), embeddings are optimized using the InfoNCE objective with temperature $\tau = 0.05$:

$$\mathbf{\mathcal{L}_{\text{InfoNCE}} = -\log \frac{\exp(\text{sim}(\mathbf{q}, \mathbf{d}^+) / \tau)}{\exp(\text{sim}(\mathbf{q}, \mathbf{d}^+) / \tau) + \sum_{j=1}^K \exp(\text{sim}(\mathbf{q}, \mathbf{d}_j^-) / \tau)}}$$
🏛️ Solved Problem 36: Quantization of Large Language Models (GPTQ vs AWQ)

• GPTQ (Frantar et al. 2022): Second-order Taylor approximation of layer weights minimizing inverse Hessian reconstruction error $H^{-1}$.
• AWQ (Activation-aware Weight Quantization - Lin et al. 2023): Protects the top 1% salient weight channels that correspond to large activation magnitudes, quantizing the remaining 99% weights to 4-bit integers with zero perplexity degradation!

🏛️ Solved Problem 43: COMET & Neural Translation Evaluation Metrics

Traditional n-gram metrics (BLEU, ROUGE) penalize valid translations that use synonyms (e.g., `automobile` vs `car`). COMET (Rei et al. 2020) uses cross-lingual pretrained encoders (XLM-RoBERTa) to project the source sentence, candidate translation, and reference into a shared multilingual embedding space, computing neural semantic similarity that achieves state-of-the-art correlation with human professional translators!

🏛️ Solved Problem 44: Direct Preference Optimization (DPO) Closed-Form Loss Derivation

Rafailov et al. (2023) proved that the optimal policy under Bradley-Terry reward models satisfies: $r(x, y) = \beta \log \frac{\pi_\theta(y \mid x)}{\pi_{\text{ref}}(y \mid x)} + \beta \log Z(x)$.

$$\mathbf{\mathcal{L}_{\text{DPO}}(\theta; \pi_{\text{ref}}) = -\mathbb{E}_{(x, y_w, y_l) \sim \mathcal{D}}\left[ \log \sigma\left( \beta \log \frac{\pi_\theta(y_w \mid x)}{\pi_{\text{ref}}(y_w \mid x)} - \beta \log \frac{\pi_\theta(y_l \mid x)}{\pi_{\text{ref}}(y_l \mid x)} \right) \right]}$$

Eliminates the separate reward model and reinforcement learning training stability issues entirely!

🏛️ Solved Problem 52: BLEU vs NIST Metric Comparison

While BLEU gives equal weight to all n-grams ($w_n = 1/4$), the NIST Metric weights each matching n-gram by its Information Content: $\text{Info}(w_1 \dots w_n) = \log_2 \frac{C(w_1 \dots w_{n-1})}{C(w_1 \dots w_n)}$, heavily rewarding rare informative content words over common stopwords!

🏛️ Solved Problem 53: Factuality Evaluation in Abstractive Summarization (QAGS & FactCC)

• QAGS (Wang et al. 2020): Automatically generates QA pairs from the summary and verifies whether the source document answers them identically.
• FactCC (Kryscinski et al. 2020): Uses a binary classification BERT model trained on syntactically mutated sentences to detect hallucinations!

🏛️ Solved Problem 60: BLEU Brevity Penalty Exponential Decay Curve

For candidate length $c = 10$ and reference length $r = 15$: $\text{BP} = \exp(1 - 15/10) = \exp(-0.5) \approx \mathbf{0.6065}$. The score is penalized by $40\%$ for omitting essential reference content!

🏛️ Solved Problem 61: RAG Dense Indexing with FAISS Flat vs HNSW Graphs

• IndexFlatIP: Exact brute-force inner-product search $O(N \cdot d)$.
• HNSW (Hierarchical Navigable Small World): Multi-layer proximity graph achieving approximate nearest neighbor retrieval in blazing fast $O(\log N)$ logarithmic time!

🏛️ Solved Problem 68: Complete 4-Gram BLEU Score Calculation Trace

Given candidate $c=12$, reference $r=14$, clipped precisions: $p_1 = 0.833, p_2 = 0.636, p_3 = 0.500, p_4 = 0.333$:

$$\text{BP} = \exp(1 - 14/12) = \exp(-0.1667) = \mathbf{0.8465}$$ $$\mathbf{\text{BLEU-4} = 0.8465 \times \exp\left( \frac{\ln(0.833) + \ln(0.636) + \ln(0.500) + \ln(0.333)}{4} \right) = 0.8465 \times 0.545 = \mathbf{0.4613 \ (46.13\%)}}$$
🏛️ Solved Problem 69: ROUGE-L Longest Common Subsequence Dynamic Programming Recurrence

For reference $R[1..m]$ and candidate $C[1..n]$:

$$\mathbf{\text{LCS}[i, j] = \begin{cases} \text{LCS}[i-1, j-1] + 1 & \text{if } R[i] = C[j] \\ \max(\text{LCS}[i-1, j], \text{LCS}[i, j-1]) & \text{if } R[i] \neq C[j] \end{cases}}$$
🏛️ Solved Problem 73: Text Summarization Abstractive Length Penalty Proof

In Beam Search for abstractive summarization, the length normalization penalty $\text{lp}(Y) = \frac{(5 + |Y|)^\alpha}{(5 + 1)^\alpha}$ ($\alpha = 0.6$) prevents the decoder from prematurely outputting the `` end-of-sequence token!

🏛️ Solved Problem 77: Cross-Lingual Semantic Retrieval via Multilingual Sentence-BERT

In cross-lingual RAG, Sentence-BERT projects multilingual query $q_{\text{Hindi}}$ and English document passage $p_{\text{English}}$ into a unified shared semantic sphere, achieving high cosine similarity $\cos(\mathbf{q}, \mathbf{p}) > 0.85$ without explicit translation!

🏛️ Solved Problem 83: Exact Match (EM) vs Token-Level F1 in SQuAD QA

For prediction "the golden gate bridge" and gold answer "golden gate bridge":

🏛️ Solved Problem 84: Algorithmic Debiasing Hard-Neutralization Matrix Projection

For gender direction $\mathbf{g} = (0.6, 0.8)^T$ and biased word vector $\mathbf{w}_{\text{doctor}} = (2.0, 1.0)^T$:

$$\mathbf{w} \cdot \mathbf{g} = 2.0(0.6) + 1.0(0.8) = 1.2 + 0.8 = 2.0$$ $$\mathbf{\mathbf{w}_{\text{neutral}} = (2.0, 1.0)^T - 2.0(0.6, 0.8)^T = (2.0 - 1.2, \ 1.0 - 1.6)^T = \mathbf{(0.8, -0.6)^T}}$$ $$\mathbf{\text{Verification: } \mathbf{w}_{\text{neutral}} \cdot \mathbf{g} = 0.8(0.6) + (-0.6)(0.8) = 0.48 - 0.48 = \mathbf{0.000 \quad (Perfect Orthogonality!)}}}$$
🏛️ Solved Problem 89: Neural Machine Translation Beam Search Length Penalty Graph

Plot the cumulative log-probability $\sum_{t=1}^T \log P(y_t \mid y_{

🏛️ Solved Problem 90: RAG Vector Database Indexing with Inverted File Quantization (IVF-PQ)

IVF-PQ partitions 100 million document embeddings into 4096 Voronoi cell clusters and quantizes 768D float vectors into 64 bytes using Product Quantization, enabling billion-scale sub-millisecond retrieval!

🏛️ Solved Problem 95: Cross-Encoder vs Bi-Encoder RAG Reranking Pipeline

• Bi-Encoder (Fast Retrieval): Projects query and documents into isolated vectors; searches top 100 documents via FAISS in 5ms.
• Cross-Encoder (High Precision Reranker): Concatenates query and document `[CLS] Query [SEP] Doc [SEP]` through full cross-attention layers, sorting the top 5 most relevant passages with $\mathbf{+12.4\% \text{ MRR@10}}$ accuracy boost!

🏛️ Solved Problem 96: Watermark Detection Z-Score Calculation

For text of $T = 200$ tokens with $\gamma = 0.5$, an AI detector observes $|T|_G = 160$ green tokens:

$$\mu = 200(0.5) = 100 \qquad \sigma = \sqrt{200(0.5)(0.5)} = \sqrt{50} \approx 7.071$$ $$\mathbf{z = \frac{160 - 100}{7.071} = \frac{60}{7.071} = \mathbf{+8.485} \implies p < 10^{-16} \quad (\text{Definitive Proof of Synthetic AI Origin!})}$$
🏛️ Solved Problem 100: BLEU Brevity Penalty Strict Monotonicity Proof

Prove that $\frac{d}{dc} \text{BP}(c, r) > 0$ for all candidate lengths $c < r$, showing that adding correct words strictly monotonically increases the penalty multiplier!

🏛️ Solved Problem 104: TextRank Sentence Centrality Power Method Trace

Starting from uniform initial scores $WS_0 = (1/N, \dots, 1/N)^T$, power iteration multiplies by Google matrix $\mathbf{M} = d \mathbf{T} + \frac{1-d}{N}\mathbf{E}$, converging in $< 20$ matrix-vector multiplications!

🏛️ Solved Problem 107: Beam Search Decoding Node Expansion Budget

With beam width $B = 4$ and max sequence length $T = 50$, search space explores $B \times |V| = 4 \times 32000 = 128,000$ hypotheses per step, retaining only top 4 survivors!

🏛️ Solved Problem 112: ROUGE-2 Precision vs Recall Tradeoff in Document Summaries

Recall measures factual completeness ($\frac{\text{matching bigrams}}{\text{reference bigrams}}$), while Precision measures conciseness ($\frac{\text{matching bigrams}}{\text{summary bigrams}}$). $F_1$-harmonic mean provides balanced evaluation!

🏛️ Solved Problem 113: SQuAD 2.0 Unanswerable Question Classification Threshold

SQuAD 2.0 incorporates unanswerable questions. The model outputs no-answer probability $P(\text{no-answer}) = \text{softmax}(\mathbf{w}_{\text{null}}^T \mathbf{h}_{\text{[CLS]}})$. If $P > \tau$ (threshold $\tau \approx 0.5$), the system abstains from generating a span!

🏛️ Solved Problem 118: RAG Hybrid Search Reciprocal Rank Fusion (RRF) Trace

Given BM25 rank $r_{\text{BM25}}(d) = 2$ and Dense Vector rank $r_{\text{Dense}}(d) = 5$ with constant $k = 60$:

$$\mathbf{\text{RRF}(d) = \frac{1}{60 + 2} + \frac{1}{60 + 5} = \frac{1}{62} + \frac{1}{65} = 0.01613 + 0.01538 = \mathbf{0.03151}}$$

Combines exact lexical precision with semantic generalization without score normalization!

🏛️ Solved Problem 119: Generative Text Watermark Green-List Generation Trace

Given preceding token hash $h = 42$, pseudo-randomly partition vocabulary $V$ ($|V| = 32,000$) into green list $G$ (16,000 tokens) with bias $\delta = 2.0$, forcing $> 80\%$ of sampled tokens into $G$!

🏛️ Solved Problem 121: Translation Evaluation Metric Selection Guidelines

• BLEU: Standard academic baseline (fast n-gram exact match).
• ROUGE: Standard for summarization (recall-focused).
• COMET: Neural metric with highest correlation to human translation quality across 100+ languages!