低信心
在這個練習中,你將使用獎勵模型來評估它對輸入文字分類的信心程度,並過濾掉缺乏可靠性的預測。目標是評估模型產生預測的能力,並套用信心門檻,確保只將高信心的預測視為有效。
每則回饋文字的機率分佈(prob_dists)、回饋文字(texts)變數,以及 least_confidence() 函式都已載入。
本練習屬於課程
Reinforcement Learning from Human Feedback(RLHF)
練習說明
- 定義函式,用來篩選出信心低於指定門檻的機率分佈之索引。
- 將機率分佈傳入該函式以取得回饋評論的索引,並維持門檻不變(
0.5)。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Define the filter function
def filter_low_confidence_predictions(prob_dists, threshold=0.5):
filtered_indices = [i for i, ____ in enumerate(____) ____]
return filtered_indices
# Find the indices
filtered_indices = ____
high_confidence_texts = [texts[i] for i in filtered_indices]
print("High-confidence texts:", high_confidence_texts)