Příprava dat pro RLHF

Reinforcement Learning from Human Feedback (RLHF)

Mina Parham

AI Engineer

Datasety preferencí vs. promptů

Kompletní proces RLHF.

Reinforcement Learning from Human Feedback (RLHF)

Datasety preferencí vs. promptů

Kompletní proces RLHF s počátečním datasetem promptů.

Reinforcement Learning from Human Feedback (RLHF)

Datasety preferencí vs. promptů

Kompletní proces RLHF s počátečním datasetem promptů a datasetem preferencí vstupujícím do modelu odměn.

Reinforcement Learning from Human Feedback (RLHF)

Dataset promptů

  • Otázky pro model
  • Dostupné na 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?'
  • Prompt může být nutné extrahovat
  • Hledejte značky jako: Input=, {{Text}}:, ###Human:
Reinforcement Learning from Human Feedback (RLHF)

Prozkoumání datasetu preferencí

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

Snímek obrazovky platformy Hugging Face zobrazující dataset hh-rlhf.

Reinforcement Learning from Human Feedback (RLHF)

Zpracování datasetu preferencí

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'])}
)
  • Způsob extrakce promptů se liší podle datasetu
Reinforcement Learning from Human Feedback (RLHF)

Výsledný dataset preferencí

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)

Pojďme si procvičit!

Reinforcement Learning from Human Feedback (RLHF)

Preparing Video For Download...