Chuẩn bị dữ liệu cho RLHF

Reinforcement Learning from Human Feedback (RLHF)

Mina Parham

AI Engineer

Bộ dữ liệu Preference và Prompt

Quy trình RLHF hoàn chỉnh.

Reinforcement Learning from Human Feedback (RLHF)

Bộ dữ liệu Preference và Prompt

Quy trình RLHF hoàn chỉnh với bộ dữ liệu prompt ban đầu.

Reinforcement Learning from Human Feedback (RLHF)

Bộ dữ liệu Preference và Prompt

Quy trình RLHF hoàn chỉnh với bộ dữ liệu prompt ban đầu và bộ dữ liệu preference đưa vào mô hình phần thưởng.

Reinforcement Learning from Human Feedback (RLHF)

Bộ dữ liệu Prompt

  • Câu hỏi dành cho mô hình
  • Có thể tìm trên Hugging Face datasets
prompt_data = load_dataset("center-for-humans-and-machines/rlhf-hackathon-prompts", 
                           split="train")
prompt_data['prompt'][0]
'How important is climate change?'
  • Có thể cần trích xuất prompt
  • Tìm các dấu mốc như: Input=, {{Text}}:, ###Human:
Reinforcement Learning from Human Feedback (RLHF)

Khám phá bộ dữ liệu preference

from datasets import load_dataset
preference_data = load_dataset("qgallouedec/hh-rlhf-helpful-base-trl-style", 
                               split="train")
Reinforcement Learning from Human Feedback (RLHF)

Xử lý bộ dữ liệu preference

def extract_prompt(text):
    # Extract the prompt as the first element in the list
    prompt = text[0]["content"]
    return prompt
# Apply the extraction function to the dataset
preference_data_with_prompt = preference_data.map(
    lambda example: {**example, 'prompt': extract_prompt(example['chosen'])}
)
  • Cách trích xuất prompt khác nhau giữa các bộ dữ liệu
Reinforcement Learning from Human Feedback (RLHF)

Bộ dữ liệu preference cuối cùng

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 ...}]
Reinforcement Learning from Human Feedback (RLHF)

Cùng luyện tập nào!

Reinforcement Learning from Human Feedback (RLHF)

Preparing Video For Download...