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

[Feature] RLHF dataloading #1309

Merged
merged 25 commits into from
Jun 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
amend
  • Loading branch information
vmoens committed Jun 27, 2023
commit 4ffcf72b59dd794d5a18a26761e1f61b8edc5d33
10 changes: 8 additions & 2 deletions torchrl/data/rlhf/reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from tensordict import tensorclass

from torchrl.data.rlhf.dataset import TensorDictTokenizer, TokenizedDatasetLoader
from tqdm import tqdm

DEFAULT_DATASET = "CarperAI/openai_summarize_comparisons"
_has_datasets = importlib.util.find_spec("datasets") is not None
_has_tqdm = importlib.util.find_spec("tqdm") is not None


@tensorclass
Expand Down Expand Up @@ -197,7 +197,13 @@ def pre_tokenization_hook(dataset, min_length=5):

chosen = []
rejected = []
for sample in tqdm(dataset):
if _has_tqdm:
from tqdm import tqdm

pbar = tqdm(dataset)
else:
pbar = dataset
for sample in pbar:
prompt = sample["prompt"]
chosen_summary = sample["chosen"]
rejected_summary = sample["rejected"]
Expand Down