BLEU
Bilingual Evaluation Understudy
기계 번역 품질을 측정하는 지표. n-gram 일치도 기반.
Bilingual Evaluation Understudy
기계 번역 품질을 측정하는 지표. n-gram 일치도 기반.
BLEU(Bilingual Evaluation Understudy)는 기계 번역의 품질을 자동으로 평가하는 지표로, 기계 번역 결과와 인간 번역(참조 번역) 간의 n-gram 일치도를 측정합니다. 0에서 1(또는 0-100) 사이의 점수로, 높을수록 참조 번역과 유사함을 의미합니다.
2002년 IBM의 Kishore Papineni 팀이 제안했으며, 빠르고 저렴하게 번역 품질을 측정할 수 있어 기계 번역 연구의 표준 평가 지표가 되었습니다. WMT(Workshop on Machine Translation) 등 주요 대회에서 공식 지표로 사용되어 왔습니다.
계산 원리는 1-gram부터 4-gram까지의 precision을 기하평균으로 결합하고, 짧은 번역에 불이익을 주는 brevity penalty를 곱합니다. Modified precision을 사용해 같은 단어를 과도하게 반복하는 것을 방지합니다. 여러 참조 번역이 있으면 가장 유리한 것과 비교합니다.
실무에서 BLEU는 빠른 모델 비교와 개발 과정 모니터링에 유용합니다. 다만 의미적 유사성보다 표면적 일치를 측정하므로, 최종 품질 판단에는 인간 평가나 COMET, BERTScore 같은 neural metric과 함께 사용하는 것이 권장됩니다.
# BLEU 점수 계산 예제
from nltk.translate.bleu_score import sentence_bleu, corpus_bleu
from nltk.translate.bleu_score import SmoothingFunction
# 1. 문장 단위 BLEU
reference = [['the', 'cat', 'is', 'on', 'the', 'mat']]
candidate = ['the', 'cat', 'sat', 'on', 'the', 'mat']
# 기본 BLEU (1~4-gram 균등 가중치)
score = sentence_bleu(reference, candidate)
print(f"문장 BLEU: {score:.4f}")
# 개별 n-gram 가중치 지정
weights_1gram = (1, 0, 0, 0) # BLEU-1
weights_2gram = (0.5, 0.5, 0, 0) # BLEU-2
print(f"BLEU-1: {sentence_bleu(reference, candidate, weights=weights_1gram):.4f}")
print(f"BLEU-2: {sentence_bleu(reference, candidate, weights=weights_2gram):.4f}")
# 2. Smoothing (짧은 문장이나 n-gram 미일치 시)
smoother = SmoothingFunction()
short_candidate = ['the', 'cat']
smoothed_score = sentence_bleu(
reference, short_candidate,
smoothing_function=smoother.method1
)
print(f"Smoothed BLEU: {smoothed_score:.4f}")
# 3. Corpus 단위 BLEU (여러 문장)
references_corpus = [
[['the', 'cat', 'is', 'on', 'the', 'mat']],
[['there', 'is', 'a', 'dog', 'in', 'the', 'house']]
]
candidates_corpus = [
['the', 'cat', 'sat', 'on', 'the', 'mat'],
['a', 'dog', 'is', 'in', 'the', 'house']
]
corpus_score = corpus_bleu(references_corpus, candidates_corpus)
print(f"Corpus BLEU: {corpus_score:.4f}")
# 4. SacreBLEU (표준화된 BLEU, 권장)
# pip install sacrebleu
import sacrebleu
refs = [["The cat is on the mat."]]
hyp = "The cat sat on the mat."
bleu = sacrebleu.sentence_bleu(hyp, refs)
print(f"SacreBLEU: {bleu.score:.2f}")
"현재 모델의 BLEU가 32.5인데, production 기준인 35에는 미달이에요. 다만 BLEU만 보면 안 되고, 실제로 '의미는 맞지만 다른 표현'을 쓴 경우도 있어서 BERTScore도 함께 확인해야 합니다. 인간 평가 샘플링도 병행하죠."
"이 논문은 BLEU가 0.5 올랐다고 하는데, 토큰화 방식이나 참조 번역 수가 다르면 비교가 안 돼요. SacreBLEU로 표준화된 점수를 제시하지 않으면 재현이 어렵습니다. 토큰화 설정까지 명시해야 공정한 비교죠."
"BLEU의 한계는 동의어나 패러프레이즈를 인식하지 못한다는 점입니다. 'The boy is happy'와 'The child is glad'는 의미가 같지만 BLEU는 낮게 나옵니다. 그래서 의미 기반 평가인 BERTScore나 COMET이 최근 더 선호됩니다."
BLEU 점수는 토큰화 방식에 따라 크게 달라집니다. 논문 간 비교 시 반드시 동일한 토큰화를 사용하거나 SacreBLEU로 표준화된 점수를 사용하세요.
문장 단위 BLEU를 평균내면 corpus BLEU와 다른 값이 나옵니다. 시스템 평가에는 반드시 corpus-level BLEU를 사용하고, 문장 BLEU는 디버깅 용도로만 활용하세요.
BLEU 40이 "좋은 번역"을 보장하지 않습니다. 도메인과 언어쌍에 따라 기준이 다르며, 인간 평가와의 상관관계도 완벽하지 않습니다. 단독 지표로 품질을 판단하지 마세요.