Metriky pro jazykové úlohy: ROUGE, METEOR, EM

Úvod do LLMs v Pythonu

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

Úlohy LLM a metriky

 

Evaluační metriky pro jazykové úlohy

Úvod do LLMs v Pythonu

Úlohy LLM a metriky

 

Evaluační metriky pro jazykové úlohy

Úvod do LLMs v Pythonu

Úlohy LLM a metriky

 

Evaluační metriky pro jazykové úlohy

Úvod do LLMs v Pythonu

ROUGE

  • ROUGE: podobnost mezi vygenerovaným a referenčním shrnutím
    • Sleduje n-gramy a překryvy
    • predictions: výstupy LLM
    • references: shrnutí od člověka

Porovnání the cat sat on the mat a the cat is on the mat

Úvod do LLMs v Pythonu

ROUGE

rouge = evaluate.load("rouge")
predictions = ["""as we learn more about the frequency and size distribution of 
exoplanets, we are discovering that terrestrial planets are exceedingly common."""]
references = ["""The more we learn about the frequency and size distribution of 
exoplanets, the more confident we are that they are exceedingly common."""]

Skóre ROUGE:

  • rouge1: překryv unigramů
  • rouge2: překryv bigramů
  • rougeL: dlouhé překryvné podposloupnosti
Úvod do LLMs v Pythonu

Výstupy ROUGE

Skóre ROUGE:

  • rouge1: překryv unigramů
  • rouge2: překryv bigramů
  • rougeL: dlouhé překryvné podposloupnosti

 

  • Skóre v rozsahu 0–1: vyšší skóre znamená větší podobnost
results = rouge.compute(predictions=predictions,
                         references=references)

print(results)
{'rouge1': 0.7441860465116279, 
'rouge2': 0.4878048780487805, 
'rougeL': 0.6976744186046512, 
'rougeLsum': 0.6976744186046512}
Úvod do LLMs v Pythonu

METEOR

  • METEOR: víc lingvistických rysů jako variace slov, podobné významy a slovosled
bleu = evaluate.load("bleu")
meteor = evaluate.load("meteor")


prediction = ["He thought it right and necessary to become a knight-errant, roaming the world in armor, seeking adventures and practicing the deeds he had read about in chivalric tales."] reference = ["He believed it was proper and essential to transform into a knight-errant, traveling the world in armor, pursuing adventures, and enacting the heroic deeds he had encountered in tales of chivalry."]
Úvod do LLMs v Pythonu

METEOR

results_bleu = bleu.compute(predictions=pred, references=ref)
results_meteor = meteor.compute(predictions=pred, references=ref)
print("Bleu: ", results_bleu['bleu'])
print("Meteor: ", results_meteor['meteor'])
Bleu:  0.19088841781992524
Meteor:  0.5350702240481536
  • Skóre 0-1: vyšší je lepší
Úvod do LLMs v Pythonu

Otázky a odpovědi

 

Evaluační metriky pro jazykové úlohy

Úvod do LLMs v Pythonu

Exact Match (EM)

  • Exact Match (EM): 1, pokud výstup LLM přesně odpovídá referenční odpovědi

 

  • Obvykle se používá společně s F1 skóre
from evaluate import load
em_metric = load("exact_match")

exact_match = evaluate.load("exact_match")
predictions = ["The cat sat on the mat.",
               "Theaters are great.", 
               "Like comparing oranges and apples."]
references = ["The cat sat on the mat?", 
              "Theaters are great.", 
              "Like comparing apples and oranges."]

results = exact_match.compute(
  references=references, predictions=predictions)
print(results)
{'exact_match': 0.3333333333333333}
Úvod do LLMs v Pythonu

Pojďme cvičit!

Úvod do LLMs v Pythonu

Preparing Video For Download...