Pregătirea datelor pentru RLHF

Reinforcement Learning from Human Feedback (RLHF)

Mina Parham

AI Engineer

Seturi de date: preferințe vs. prompt-uri

Procesul complet RLHF.

Reinforcement Learning from Human Feedback (RLHF)

Seturi de date: preferințe vs. prompt-uri

Procesul complet RLHF cu setul de date inițial de prompt-uri.

Reinforcement Learning from Human Feedback (RLHF)

Seturi de date: preferințe vs. prompt-uri

Procesul complet RLHF cu setul de date inițial de prompt-uri și un set de date de preferințe care alimentează modelul de recompensă.

Reinforcement Learning from Human Feedback (RLHF)

Set de date de prompt-uri

  • Întrebări pentru model
  • Pot fi găsite în seturile de date 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?'
  • Poate fi necesară extragerea prompt-ului
  • Caută markeri precum: Input=, {{Text}}:, ###Human:
Reinforcement Learning from Human Feedback (RLHF)

Explorarea setului de date de preferințe

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

Procesarea setului de date de preferințe

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'])}
)
  • Modul în care sunt extrase prompt-urile diferă în funcție de setul de date
Reinforcement Learning from Human Feedback (RLHF)

Setul final de date de preferințe

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)

Hai să exersăm!

Reinforcement Learning from Human Feedback (RLHF)

Preparing Video For Download...