Reinforcement Learning from Human Feedback(RLHF)
Mina Parham
AI Engineer





偏好資料 preference_df,來源含 'Journalist'、'Social Media Influencer'、'Marketing Professional':

此範例資料可輕鬆用 'id' 分組來整合:
df_majority = preference_df.groupby(['id']).apply(majority_vote)
接著使用多數決:
from collections import Counter
def majority_vote(df):
votes = Counter(zip(df['chosen'], df['rejected']))
return max(votes, key=votes.get)
偏好資料 preference_df2,同樣來自三位專家:

preference_df2 以找出不可靠來源:df_majority = preference_df2.groupby('id').apply(majority_vote)disagreements = {source: 0 for source in preference_df2['source'].unique()}for _, row in preference_df2.iterrows(): if (row['chosen'], row['rejected']) != df_majority[row['id']]: disagreements[row['source']] += 1detect_unreliable_source = max(disagreements, key=disagreements.get)
Reinforcement Learning from Human Feedback(RLHF)