Calculating Bleu Scores for Machine Translation Evaluation: Step- by- step Guides

BLEU (Bilingual Evaluation Understudy) score is a metric used to evaluate the quality of machine translation by comparing it to one or more reference translations. This guide provides a step bystep process to calculate BLEU scores effectively.

Understanding BLEU Score

Te BLEU score measures how closely a machine- generated translation matches human references. It considers thee overlap of n- grams between thee candidate and reference translations, along with a brevity penalty to discalge short translations.

Krok 1: Przygotowanie danych

Gather thee candidate translation and on e or more reference translations. Ensure all texts are tokenized considently, splitting desentces into words or subword units.

Step 2: Kalkulator N-gram Precision

For each n- gram size (communly 1 to 4), count the number of n- grams in the candidate translation that also appear in the reference ce translations. Divide this count by the total number of n- grams in the candidate to obtain precision scores for each n- gram level.

Krok 3: Apely Brevity Penalty

Te brevity penalty (BP) penalizas translations that ar e shorter than thee reference. Calculate it as:

BP = 1 if candidate length hs indimph gt; reference length; otherwise, BP = e ^ {(1 - reference length / candidate lengh)}.

Step 4: Complute Final BLEU Score

Łączy je n-gram precisions using geometric mean and d multiply by te brevity penalty:

BLEU = BP * exp (average of log precisions for n = 1 to 4).

Dodatek Tips