เมตริกสำหรับงานภาษา: ROUGE, METEOR, EM

Python เบื้องต้นสำหรับ LLMs

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

งานและเมตริกของ LLM

 

เมตริกการประเมินสำหรับงานภาษา

Python เบื้องต้นสำหรับ LLMs

งานและเมตริกของ LLM

 

เมตริกการประเมินสำหรับงานภาษา

Python เบื้องต้นสำหรับ LLMs

งานและเมตริกของ LLM

 

เมตริกการประเมินสำหรับงานภาษา

Python เบื้องต้นสำหรับ LLMs

ROUGE

  • ROUGE: ความคล้ายคลึงระหว่างสรุปที่สร้างขึ้นกับสรุปอ้างอิง
    • วิเคราะห์ n-gram และส่วนที่ทับซ้อนกัน
    • predictions: ผลลัพธ์จาก LLM
    • references: สรุปที่มนุษย์จัดทำ

เปรียบเทียบ the cat sat on the mat กับ the cat is on the mat

Python เบื้องต้นสำหรับ LLMs

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:

  • rouge1: การทับซ้อนของ unigram
  • rouge2: การทับซ้อนของ bigram
  • rougeL: ลำดับย่อยที่ทับซ้อนกันยาวที่สุด
Python เบื้องต้นสำหรับ LLMs

ผลลัพธ์ ROUGE

คะแนน ROUGE:

  • rouge1: การทับซ้อนของ unigram
  • rouge2: การทับซ้อนของ bigram
  • rougeL: ลำดับย่อยที่ทับซ้อนกันยาวที่สุด

 

  • คะแนนอยู่ระหว่าง 0-1: คะแนนสูงขึ้นหมายถึงความคล้ายคลึงสูงขึ้น
results = rouge.compute(predictions=predictions,
                         references=references)

print(results)
{'rouge1': 0.7441860465116279, 
'rouge2': 0.4878048780487805, 
'rougeL': 0.6976744186046512, 
'rougeLsum': 0.6976744186046512}
Python เบื้องต้นสำหรับ LLMs

METEOR

  • METEOR: คำนึงถึงคุณลักษณะทางภาษาเพิ่มเติม เช่น รูปแบบคำ ความหมายใกล้เคียง และลำดับคำ
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."]
Python เบื้องต้นสำหรับ LLMs

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
  • คะแนน 0-1: ยิ่งสูงยิ่งดี
Python เบื้องต้นสำหรับ LLMs

การถามตอบ

 

เมตริกการประเมินสำหรับงานภาษา

Python เบื้องต้นสำหรับ LLMs

Exact Match (EM)

  • Exact Match (EM): ให้ค่า 1 เมื่อผลลัพธ์ของ LLM ตรงกับคำตอบอ้างอิงทุกประการ

 

  • มักใช้ร่วมกับ 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}
Python เบื้องต้นสำหรับ LLMs

มาฝึกกันเถอะ!

Python เบื้องต้นสำหรับ LLMs

Preparing Video For Download...