BLEU 번역
이제 BLEU 지표에 익숙해져 볼까요.
Helsinki-NLP 스페인어-영어 번역 모델과 BLEU 지표를 기반으로 한 파이프라인이 미리 로드되어 있어요. evaluate 라이브러리의 evaluate.load("bleu")를 사용했습니다.
다음의 입력과 기준(reference)을 가지고 평가해 보세요:
input_sentence_1 = "Hola, ¿cómo estás?"
reference_1 = [
["Hello, how are you?", "Hi, how are you?"]
]
input_sentences_2 = ["Hola, ¿cómo estás?", "Estoy genial, gracias."]
references_2 = [
["Hello, how are you?", "Hi, how are you?"],
["I'm great, thanks.", "I'm great, thank you."]
]
이 연습은 강의의 일부입니다
Python으로 배우는 LLM 입문
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-es-en")
# Translate the first input sentence then calucate the BLEU metric for translation quality
translated_output = ____
translated_sentence = translated_output[0]['translation_text']
print("Translated:", translated_sentence)
results = bleu.____(predictions=____, references=____)
print(results)