Tłumaczenia z metryką BLEU
Zapoznajmy się z metryką BLEU.
Potok oparty na modelu tłumaczeń hiszpańsko-angielskich Helsinki-NLP oraz metryka BLEU zostały już dla ciebie załadowane – za pomocą evaluate.load("bleu") z biblioteki evaluate.
Dane wejściowe i referencje do ewaluacji:
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."]
]
To ćwiczenie jest częścią kursu
Wprowadzenie do LLM w Pythonie
Interaktywne ćwiczenie praktyczne
Spróbuj tego ćwiczenia, uzupełniając ten przykładowy kod.
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)