언어 작업 지표: ROUGE, METEOR, EM

Python으로 배우는 LLM 입문

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

LLM 작업과 지표

 

언어 작업 평가 지표

Python으로 배우는 LLM 입문

LLM 작업과 지표

 

언어 작업 평가 지표

Python으로 배우는 LLM 입문

LLM 작업과 지표

 

언어 작업 평가 지표

Python으로 배우는 LLM 입문

ROUGE

  • ROUGE: 생성된 요약과 참조 요약 간 유사도
    • n-그램 및 겹침 분석
    • predictions: LLM 출력
    • references: 사람이 작성한 요약

"the cat sat on the mat"과 "the cat is on the mat" 비교

Python으로 배우는 LLM 입문

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: 유니그램 겹침
  • rouge2: 바이그램 겹침
  • rougeL: 긴 공통 부분 수열
Python으로 배우는 LLM 입문

ROUGE 출력

ROUGE 점수:

  • rouge1: 유니그램 겹침
  • rouge2: 바이그램 겹침
  • 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으로 배우는 LLM 입문

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으로 배우는 LLM 입문

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으로 배우는 LLM 입문

질의응답

 

언어 작업 평가 지표

Python으로 배우는 LLM 입문

정확 일치(EM)

  • 정확 일치(EM): LLM 출력이 참조 답변과 완전히 일치하면 1

 

  • 일반적으로 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}
Python으로 배우는 LLM 입문

연습해 봅시다!

Python으로 배우는 LLM 입문

Preparing Video For Download...