Chỉ số cho tác vụ ngôn ngữ: ROUGE, METEOR, EM

Nhập môn LLMs trong Python

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

Tác vụ và chỉ số cho LLM

 

Chỉ số đánh giá cho tác vụ ngôn ngữ

Nhập môn LLMs trong Python

Tác vụ và chỉ số cho LLM

 

Chỉ số đánh giá cho tác vụ ngôn ngữ

Nhập môn LLMs trong Python

Tác vụ và chỉ số cho LLM

 

Chỉ số đánh giá cho tác vụ ngôn ngữ

Nhập môn LLMs trong Python

ROUGE

  • ROUGE: đo độ giống giữa tóm tắt tạo ra và tóm tắt tham chiếu
    • Xét n-gram và phần trùng lặp
    • predictions: đầu ra LLM
    • references: tóm tắt do con người cung cấp

So sánh the cat sat on the mat và the cat is on the mat

Nhập môn LLMs trong 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."""]

Điểm ROUGE:

  • rouge1: trùng unigram
  • rouge2: trùng bigram
  • rougeL: các chuỗi con dài trùng nhau
Nhập môn LLMs trong Python

Kết quả ROUGE

Điểm ROUGE:

  • rouge1: trùng unigram
  • rouge2: trùng bigram
  • rougeL: các chuỗi con dài trùng nhau

 

  • Thang 0–1: điểm cao hơn → giống hơn
results = rouge.compute(predictions=predictions,
                         references=references)

print(results)
{'rouge1': 0.7441860465116279, 
'rouge2': 0.4878048780487805, 
'rougeL': 0.6976744186046512, 
'rougeLsum': 0.6976744186046512}
Nhập môn LLMs trong Python

METEOR

  • METEOR: xét thêm đặc trưng ngôn ngữ như biến thể từ, nghĩa tương tự, và trật tự từ
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."]
Nhập môn LLMs trong 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
  • Điểm 0–1: cao hơn là tốt hơn
Nhập môn LLMs trong Python

Hỏi đáp

 

Chỉ số đánh giá cho tác vụ ngôn ngữ

Nhập môn LLMs trong Python

Exact Match (EM)

  • Exact Match (EM): 1 nếu đầu ra LLM khớp hoàn toàn với đáp án tham chiếu

 

  • Thường dùng cùng với F1 score
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}
Nhập môn LLMs trong Python

Ayo berlatih!

Nhập môn LLMs trong Python

Preparing Video For Download...