Bird
0
0

What will be the BLEU score output by this code snippet?

medium📝 Predict Output Q4 of 15
NLP - Text Generation
What will be the BLEU score output by this code snippet?
from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction
reference = [['a', 'quick', 'brown', 'fox']]
candidate = ['a', 'fast', 'brown', 'fox']
score = sentence_bleu(reference, candidate, smoothing_function=SmoothingFunction().method1)
print(round(score, 2))
A0.75
B0.92
C0.50
D0.33
Step-by-Step Solution
Solution:
  1. Step 1: Analyze n-gram matches

    The candidate differs from the reference only in 'quick' vs 'fast'. The rest of the words match exactly.
  2. Step 2: Consider smoothing

    Smoothing method1 reduces zero counts impact, increasing the score despite the mismatch.
  3. Step 3: Calculate approximate BLEU

    High overlap with smoothing leads to a score close to 0.92.
  4. Final Answer:

    0.92 -> Option B
  5. Quick Check:

    One word difference with smoothing yields high BLEU [OK]
Quick Trick: Smoothing boosts BLEU when few n-grams mismatch [OK]
Common Mistakes:
MISTAKES
  • Ignoring smoothing effects on BLEU score
  • Assuming exact word matches only
  • Miscounting n-gram overlaps

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes