Bird
0
0

Identify the error in this code snippet for a bigram language model: P('dog'|'the') = counts('the dog') / counts('dog')

medium📝 Debug Q6 of 15
NLP - Text Generation
Identify the error in this code snippet for a bigram language model: P('dog'|'the') = counts('the dog') / counts('dog')
ADenominator should be counts('the') not counts('dog')
BNumerator should be counts('dog') not counts('the dog')
CCounts should be replaced by probabilities
DNo error, formula is correct
Step-by-Step Solution
Solution:
  1. Step 1: Understand bigram probability formula

    Bigram probability P(w2|w1) = counts(w1 w2) / counts(w1).
  2. Step 2: Check denominator in given formula

    The denominator incorrectly uses counts('dog') instead of counts('the').
  3. Final Answer:

    Denominator should be counts('the') not counts('dog') -> Option A
  4. Quick Check:

    Bigram denominator = counts(previous word) [OK]
Quick Trick: Denominator counts previous word, not current word [OK]
Common Mistakes:
MISTAKES
  • Using counts of current word in denominator
  • Confusing numerator and denominator
  • Assuming counts are probabilities

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes