Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠️ Update tests and fix PPO #2463

Merged
merged 13 commits into from
Dec 12, 2024
Prev Previous commit
Next Next commit
Update tests/test_ppo_trainer.py
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
  • Loading branch information
kashif and qgallouedec authored Dec 12, 2024
commit 7f1e4e944ee26eea9bc4e2ec3050e5ca51c7c7e0
29 changes: 2 additions & 27 deletions tests/test_ppo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,8 @@ def setUp(self):
)

# Load dataset
raw_dataset = load_dataset(
"trl-internal-testing/descriptiveness-sentiment-trl-style",
split="descriptiveness",
)

def prepare_dataset(dataset, tokenizer):
"""pre-tokenize the dataset before training"""

def tokenize(element):
outputs = tokenizer(
element["prompt"],
padding=False,
)
return {"input_ids": outputs["input_ids"]}

return dataset.map(
tokenize,
batched=True,
remove_columns=dataset.column_names,
load_from_cache_file=False,
)

# Process the dataset
# Split into train and eval datasets as in ppo.py
eval_samples = 100
train_dataset = raw_dataset.select(range(len(raw_dataset) - eval_samples))
eval_dataset = raw_dataset.select(range(len(raw_dataset) - eval_samples, len(raw_dataset)))
raw_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only")
self.raw_dataset = raw_dataset.map(lambda x: self.tokenizer(x["prompt"]))

# Process both datasets
self.train_dataset = prepare_dataset(train_dataset, self.tokenizer)
Expand Down
Loading