開始使用免費開始

使用 ROUGE 評估產生的文字

你會拿到來自問答資料集(Softage-AI/sft-conversational_dataset)的 10 個樣本。

你已使用 TinyLlama-1.1B 為這些樣本產生答案,你的任務是將產生的結果與正確答案進行比對,評估品質。

此模型產生的答案已放在 test_answers,而正確答案在 reference_answers。請使用 ROUGE 評估指標來評估模型生成的品質。

本練習屬於課程

使用 Llama 3 進行微調

檢視課程

練習說明

  • 匯入評估類別與指標(ROUGE 指標)。
  • 建立評估類別的實例並載入 ROUGE 指標。
  • 使用給定的 reference_answerstest_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)
編輯並執行程式碼