RLHF 用のデータ準備

人間のフィードバックによる強化学習(RLHF)

Mina Parham

AI Engineer

選好データ vs. プロンプトデータ

RLHF プロセス全体。

人間のフィードバックによる強化学習(RLHF)

選好データ vs. プロンプトデータ

初期プロンプトデータセット付きの RLHF プロセス全体。

人間のフィードバックによる強化学習(RLHF)

選好データ vs. プロンプトデータ

初期プロンプトデータセットと、報酬モデルに入力する選好データセット付きの RLHF プロセス全体。

人間のフィードバックによる強化学習(RLHF)

プロンプトデータセット

  • モデルへの質問
  • Hugging Face のデータセットで入手可
prompt_data = load_dataset("center-for-humans-and-machines/rlhf-hackathon-prompts", 
                           split="train")
prompt_data['prompt'][0]
'How important is climate change?'
  • プロンプトの抽出が必要な場合あり
  • 次のマーカーを探す: Input=, {{Text}}:, ###Human:
人間のフィードバックによる強化学習(RLHF)

選好データセットの探索

from datasets import load_dataset
preference_data = load_dataset("trl-internal-testing/hh-rlhf-helpful-base-trl-style", 
                               split="train")

Hugging Face プラットフォームで hh-rlhf データセットを示すスクリーンショット。

人間のフィードバックによる強化学習(RLHF)

選好データセットの処理

def extract_prompt(text):
    # リストの先頭要素をプロンプトとして抽出
    prompt = text[0]["content"]
    return prompt
# データセットに抽出関数を適用
preference_data_with_prompt = preference_data.map(
    lambda example: {**example, 'prompt': extract_prompt(example['chosen'])}
)
  • プロンプトの抽出方法はデータセットごとに異なる
人間のフィードバックによる強化学習(RLHF)

最終的な選好データセット

sample = preference_data_with_prompt.select(range(1))
sample['prompt']
'What vitamins are essential for the body to function?'
sample['chosen']
[ { "content": "What vitamins are essential for the body to function?", "role": 
   "user" }, { "content": "There are some very important vitamins that ensure the 
   proper functioning of the body, including Vitamins A, C, D, E, and K along ...}]
人間のフィードバックによる強化学習(RLHF)

Passons à la pratique !

人間のフィードバックによる強化学習(RLHF)

Preparing Video For Download...