1. Suppose we have a small corpus of text with the following sentences:
"I love machine learning. She loves machine learning. They learn machine language. I learn to code."
From this corpus, we want to compute the bigram probabilities. However, given the small size of the dataset, we decide to use Add-k smoothing to handle potential zero probabilities for unseen bigrams.
Task:
1. Compute Raw Bigram Probabilities: Without smoothing, calculate the probability of the bigram "love machine". The formula for computing the raw bigram probabilities is:
P(wi|wi-1) = C(wi-1,wi) / C(wi-1)
Where:
P(wi|wi-1) is the probability of word wi following word wi-1
C(wi-1,wi) is the count of the bigram wi-1wi in the corpus.
C(wi-1) is the count of the preceding word wi-1 in the corpus.
2. Apply Add-k Smoothing: Use Add-k smoothing to calculate the probability of the same bigram "love machine". For this exercise, use k=1. Remember the formula for Add-k smoothing for bigrams:
P(wi|wi-1) = (C(wi-1,wi) + k) / (C(wi-1) + V)
Where:
C(wi-1,wi) is the count of the bigram wi-1wi
C(wi-1) is the count of the preceding word wi-1
V is the vocabulary size
Problem:
1. Compare the raw bigram probability from step 1 with the smoothed probability from step 2.
2. How would the probability change if k was set to a value greater than 1?
3. Compute the smoothed bigram probability for an unseen bigram, for instance "love code". How does Add-k smoothing help in this scenario?