Mätvärden för språkuppgifter: ROUGE, METEOR, EM

Introduktion till LLM:er i Python

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

LLM-uppgifter och mätvärden

 

Utvärderingsmätvärden för språkuppgifter

Introduktion till LLM:er i Python

LLM-uppgifter och mätvärden

 

Utvärderingsmätvärden för språkuppgifter

Introduktion till LLM:er i Python

LLM-uppgifter och mätvärden

 

Utvärderingsmätvärden för språkuppgifter

Introduktion till LLM:er i Python

ROUGE

  • ROUGE: likhet mellan en genererad sammanfattning och referenssammanfattningar
    • Tittar på n-gram och överlapp
    • predictions: LLM-utdata
    • references: mänskligt framtagna sammanfattningar

Jämförelse av "the cat sat on the mat" och "the cat is on the mat"

Introduktion till LLM:er i Python

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."""]

ROUGE-poäng:

  • rouge1: överlapp på unigramnivå
  • rouge2: överlapp på bigramnivå
  • rougeL: långa överlappande delsekvenser
Introduktion till LLM:er i Python

ROUGE-utdata

ROUGE-poäng:

  • rouge1: överlapp på unigramnivå
  • rouge2: överlapp på bigramnivå
  • rougeL: långa överlappande delsekvenser

 

  • Poäng mellan 0–1: högre poäng indikerar större likhet
results = rouge.compute(predictions=predictions,
                         references=references)

print(results)
{'rouge1': 0.7441860465116279, 
'rouge2': 0.4878048780487805, 
'rougeL': 0.6976744186046512, 
'rougeLsum': 0.6976744186046512}
Introduktion till LLM:er i Python

METEOR

  • METEOR: fångar fler språkliga drag som ordvariationer, liknande betydelser och ordföljd
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."]
Introduktion till LLM:er i Python

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
  • Poäng 0–1: högre är bättre
Introduktion till LLM:er i Python

Frågor och svar

 

Utvärderingsmätvärden för språkuppgifter

Introduktion till LLM:er i Python

Exact Match (EM)

  • Exact Match (EM): 1 om en LLM:s utdata exakt matchar referenssvaret

 

  • Används normalt tillsammans med F1-poäng
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}
Introduktion till LLM:er i Python

Nu kör vi en övning!

Introduktion till LLM:er i Python

Preparing Video For Download...