Métricas para tarefas de linguagem: ROUGE, METEOR, EM

Introdução a LLMs em Python

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

Tarefas e métricas de LLM

 

Métricas de avaliação para tarefas de linguagem

Introdução a LLMs em Python

Tarefas e métricas de LLM

 

Métricas de avaliação para tarefas de linguagem

Introdução a LLMs em Python

Tarefas e métricas de LLM

 

Métricas de avaliação para tarefas de linguagem

Introdução a LLMs em Python

ROUGE

  • ROUGE: similaridade entre um resumo gerado e os de referência
    • Olha n-grams e sobreposição
    • predictions: saídas do LLM
    • references: resumos humanos

Comparando the cat sat on the mat e the cat is on the mat

Introdução a LLMs em 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."""]

Pontuações ROUGE:

  • rouge1: sobreposição de unigrama
  • rouge2: sobreposição de bigrama
  • rougeL: subsequências longas sobrepostas
Introdução a LLMs em Python

Saídas do ROUGE

Pontuações ROUGE:

  • rouge1: sobreposição de unigrama
  • rouge2: sobreposição de bigrama
  • rougeL: subsequências longas sobrepostas

 

  • Pontos de 0 a 1: quanto maior, maior a similaridade
results = rouge.compute(predictions=predictions,
                         references=references)

print(results)
{'rouge1': 0.7441860465116279, 
'rouge2': 0.4878048780487805, 
'rougeL': 0.6976744186046512, 
'rougeLsum': 0.6976744186046512}
Introdução a LLMs em Python

METEOR

  • METEOR: usa mais recursos linguísticos, como variações de palavra, sinônimos e ordem das palavras
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."]
Introdução a LLMs em 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
  • Pontuação 0-1: quanto maior, melhor
Introdução a LLMs em Python

Perguntas e respostas

 

Métricas de avaliação para tarefas de linguagem

Introdução a LLMs em Python

Exact Match (EM)

  • Exact Match (EM): vale 1 se a saída do LLM bate exatamente com a resposta de referência

 

  • Normalmente usado junto com a pontuação F1
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}
Introdução a LLMs em Python

Vamos praticar!

Introdução a LLMs em Python

Preparing Video For Download...