ROUGE로 생성 텍스트 평가하기
질의응답 데이터셋(Softage-AI/sft-conversational_dataset)에서 가져온 10개의 샘플이 제공됩니다.
TinyLlama-1.1B를 사용해 이 샘플들에 대한 답을 생성했고, 이제 생성 결과가 정답과 얼마나 가까운지 평가하는 것이 과제예요.
이 모델이 생성한 답은 test_answers에, 정답은 reference_answers에 제공됩니다. ROUGE 평가 메트릭을 사용해 모델 생성 결과의 품질을 평가하세요.
이 연습은 강의의 일부입니다
Llama 3 미세 조정(Fine-Tuning)
연습 안내
- 평가 클래스와 메트릭(ROUGE 메트릭)을 임포트하세요.
- 평가 클래스를 인스턴스화하고 ROUGE 메트릭을 로드하세요.
- 제공된
reference_answers와test_answers로 평가 인스턴스를 실행해 ROUGE 점수를 계산하세요. - 결과 중에서 정답과 생성된 답 사이의 단어 쌍 겹침을 확인하는 점수를
final_score에 저장하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import the evaluation library from Hugging Face
import ____
# Instantiate your evaluate library and load the ROUGE metric
rouge_evaluator = ____.load(____)
# Fill in the method, and place your reference answers and test answers
results = rouge_evaluator.____
# Extract the ROUGE1 score from the results dictionary
final_score = results[____]
print(final_score)