Explorarea modelelor de recompensă

Reinforcement Learning from Human Feedback (RLHF)

Mina Parham

AI Engineer

Procesul de până acum

O diagramă reprezentând partea din procesul RLHF acoperită până acum.

Reinforcement Learning from Human Feedback (RLHF)

Procesul de până acum

O diagramă reprezentând partea din procesul RLHF acoperită până acum și o săgeată spre pasul următor: modelele de recompensă.

Reinforcement Learning from Human Feedback (RLHF)

Ce este un model de recompensă?

 

  O diagramă care arată un model AI cu o săgeată spre o ieșire.

Reinforcement Learning from Human Feedback (RLHF)

Ce este un model de recompensă?

  • Modelul informează agentul
  • Agentul evaluează modelul pentru a maximiza recompensele

O diagramă care arată un model AI și un agent informat de o schemă de recompense cu o săgeată spre o ieșire.

Reinforcement Learning from Human Feedback (RLHF)

Utilizarea reward trainer

from trl import RewardTrainer, RewardConfig

from transformers import AutoModelForSequenceClassification, AutoTokenizer
from datasets import load_dataset
# Load pre-trained model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained("gpt2", num_labels=1)
tokenizer = AutoTokenizer.from_pretrained("gpt2")

# Load dataset in the required format dataset = load_dataset("path/to/dataset")
Reinforcement Learning from Human Feedback (RLHF)

Antrenarea modelului de recompensă

# Define training arguments
training_args = RewardConfig(

output_dir="path/to/output/dir",
per_device_train_batch_size=8, per_device_eval_batch_size=8,
num_train_epochs=3,
learning_rate=1e-3
)
Reinforcement Learning from Human Feedback (RLHF)

Antrenarea modelului de recompensă

# Initialize the RewardTrainer
trainer = RewardTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset["train"],
    eval_dataset=dataset["validation"],
    tokenizer=tokenizer,
)
# Train the reward model
trainer.train()
Reinforcement Learning from Human Feedback (RLHF)

Să exersăm!

Reinforcement Learning from Human Feedback (RLHF)

Preparing Video For Download...