Preparando dados para RLHF

Reinforcement Learning from Human Feedback (RLHF)

Mina Parham

AI Engineer

Conjuntos de dados de Preferência vs. Prompt

O processo completo de RLHF.

Reinforcement Learning from Human Feedback (RLHF)

Conjuntos de dados de Preferência vs. Prompt

O processo completo de RLHF com conjunto inicial de prompts.

Reinforcement Learning from Human Feedback (RLHF)

Conjuntos de dados de Preferência vs. Prompt

O processo completo de RLHF com conjunto inicial de prompts e um conjunto de preferências alimentando o modelo de recompensa.

Reinforcement Learning from Human Feedback (RLHF)

Conjunto de dados de prompts

  • Perguntas para o modelo
  • Disponível em conjuntos de dados do 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?'
  • Pode ser preciso extrair o prompt
  • Procure marcadores como: Input=, {{Text}}:, ###Human:
Reinforcement Learning from Human Feedback (RLHF)

Explorando o conjunto de preferências

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

Processando o conjunto de preferências

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'])}
)
  • A extração de prompts é diferente entre conjuntos de dados
Reinforcement Learning from Human Feedback (RLHF)

Conjunto final de preferências

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)

Vamos praticar!

Reinforcement Learning from Human Feedback (RLHF)

Preparing Video For Download...