NLP interview question

Deep LearningNLPProbabilitymedium

A telecom's search-box autocomplete uses a bigram language model with add-one (Laplace) smoothing, P(w | prev) = (c(prev, w) + 1) / (c(prev) + V). The table lists every word that followed "my" in the training text; "my" occurs 20 times and the vocabulary has V = 1,000 words. What is the smoothed P(bill | my), and what does the result reveal?

Word after "my"Bigram count c(my, w)
bill8
plan6
account4
data2
each of the other 996 words0
c(my) = 20, vocabulary size V = 1,000
  1. AP(bill | my) = 9/24 = 0.375: the one is added to each of the four continuations seen in training, so the 996 unseen words keep zero probability and the estimate stays near the MLE of 0.40.
  2. BP(bill | my) = 0.40, unchanged from the MLE: add-one fills in zero counts and leaves observed counts as they are, so each unseen word gets 1/1,020 ≈ 0.001 and the distribution barely moves.
  3. CP(bill | my) = 9/1,020 ≈ 0.009 instead of the MLE 0.40: the 996 unseen words together receive 996/1,020 ≈ 98% of the mass, so add-one over-smooths when V is far larger than c(prev).
  4. DP(bill | my) = 9/1,020 ≈ 0.009, yet the 996 unseen words share 24/1,020 ≈ 2% of the mass, because the four observed words keep most of it, so add-one is a mild correction here.
Show the answer and explanation

Correct answer: C, P(bill | my) = 9/1,020 ≈ 0.009 instead of the MLE 0.40: the 996 unseen words together receive 996/1,020 ≈ 98% of the mass, so add-one over-smooths when V is far larger than c(prev).

Explanation NLP

Add-one smoothing pretends every possible bigram was seen once more than it was. The denominator grows by V so that the distribution still sums to 1:

P(bill | my) = (8 + 1) / (20 + 1,000) = 9/1,020 ≈ 0.0088, versus the maximum-likelihood estimate 8/20 = 0.40.

Continuations of "my"Raw countsAdd-one countsShare of the mass
bill, plan, account, data202424/1,020 ≈ 2.4%
996 unseen words0996996/1,020 ≈ 97.6%

Each unseen word gets only 1/1,020 ≈ 0.001, but there are 996 of them, so together they take almost all of the probability mass. That is the over-smoothing problem: when V ≫ c(prev), the pseudo-counts swamp the real evidence. The model now says "my" is followed by some never-seen word about 98% of the time, although all 20 training occurrences were followed by one of four words. The ranking still puts "bill" first, but probabilities and perplexity are badly distorted.

Why the other readings fail: adding one only to the observed words leaves every unseen word at zero probability, and avoiding zeros is the whole point of smoothing. Add-one changes every count, not just the zeros, and the denominator grows by V. The 24/1,020 ≈ 2.4% share is the mass left for the seen words, not the unseen ones.

Better choices for language models: add-k with a small k (e.g. 0.01), interpolation or back-off to unigram probabilities, and Kneser–Ney smoothing, the classic choice for n-gram LMs.

Interview tip: say that add-one is acceptable for Naive Bayes features but poor for language models, and justify it with the share of mass moved to unseen events.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Deep Learning questions

  1. The table shows how two tokenizers split the same text. What do the ## and Ġ markers mean?
  2. A retailer wants to cut the mobile-app download size of a product-image classifier (dense top-1 76.1%) by pruning it and shipping the weights in a compressed…
  3. A retailer's Stable Diffusion 1.5 pipeline uses classifier-free guidance, ε̂ = ε_uncond + w·(ε_cond − ε_uncond), with w = 7.5. For one latent element at one…
  4. An LLM interpretability team trains a sparse autoencoder (SAE) on residual-stream activations of size 4,096, with a 65,536-unit ReLU code layer and an L1…
  5. As an ablation, you delete every self-attention sublayer from a trained BERT-style encoder but keep the token and position embeddings, the feed-forward (FFN)…