BLEU translations
Let's get familiar with the BLEU metric.
A pipeline based on the Helsinki-NLP Spanish-English translation model and the BLEU metric has been loaded for you, using evaluate.load("bleu")
from the evaluate
library.
Given the following inputs and references for evaluation:
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."]
]
Este exercício faz parte do curso
Introduction to LLMs in Python
Exercício interativo prático
Experimente este exercício preenchendo este código de exemplo.
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)