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

Implement BoN for training and eval #528

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f04446d
Implementing support for dense rewards
Dahoas Jun 5, 2023
13a01fc
added "num_return_sequences" param which corresponds to n in Best-of-…
SharathRaparthy Jun 16, 2023
5421a73
updates to "num_return_sequences" param
SharathRaparthy Jun 16, 2023
2f3ac28
BoN implementation
SharathRaparthy Jun 16, 2023
2f1dace
Changed back to default.
SharathRaparthy Jun 19, 2023
f58170d
TopK sampling instead of Top1
SharathRaparthy Jun 19, 2023
be8bc1a
summed along dim=1
SharathRaparthy Jun 26, 2023
608d812
Generating samples in chunks
SharathRaparthy Jun 26, 2023
d8557e7
added gen_chunk_size parameter
SharathRaparthy Jun 26, 2023
8ef9c36
chunking in forward prop
SharathRaparthy Jun 26, 2023
4c1d82d
chunking generations in train and eval
SharathRaparthy Jun 26, 2023
ecd5107
Implementing support for dense rewards
Dahoas Jun 5, 2023
4071604
Fix distributed ref_mean, ref_var bug for dense rewards
Dahoas Jun 15, 2023
5f41413
Make generation respect max seq length
Dahoas Jun 23, 2023
22ae83f
Make experience before first round of training
Dahoas Jun 23, 2023
7d0a4be
Refactoring .generate/.generate_eval
Dahoas Jun 27, 2023
b79dd19
Fix BoN metric support
Dahoas Jun 29, 2023
cb49dc5
Enforce chunk_size param for eval generation when present
Dahoas Jul 3, 2023
e290412
Fix: Don't shuffle prompt dataset
Dahoas Jul 4, 2023
391d04c
Move inputs to device
Dahoas Jul 18, 2023
8de84e4
Fix style
Dahoas Jul 18, 2023
3d7e0d5
Fix chunked generation
Dahoas Jul 21, 2023
1fda0ce
fix(accelerate_base_trainer): order of keyword arguments
maxreciprocate Jul 22, 2023
4ac1707
Merging main
Dahoas Aug 7, 2023
de3d854
Merge branch 'BoN' of https://github.com/CarperAI/trlx into BoN
Dahoas Aug 7, 2023
3ce3c2b
Removing old example
Dahoas Aug 7, 2023
2635de5
Fix: remove extraneous method args
Dahoas Aug 7, 2023
1be2c3c
Fix: Always set generate_experience_kwargs
Dahoas Aug 7, 2023
3cba0db
Fix: Remove mask from RunningMoments update call
Dahoas Aug 7, 2023
0cb91c4
Fix: style
Dahoas Aug 7, 2023
cc92911
Fix: rename 'gen_chunk_size' to 'chunk_size'
Dahoas Aug 7, 2023
4297f98
Fix: generated samples padding
Dahoas Aug 7, 2023
36f06af
Remove prints
Dahoas Aug 7, 2023
a2980dd
Rename 'num_train_sequences' to 'num_topk_samples'
Dahoas Aug 21, 2023
3d5a639
Address nits
Dahoas Aug 21, 2023
87837b6
Fix: style
Dahoas Aug 21, 2023
ed93be8
Set 'num_return_sequences' to 1 by default
Dahoas Aug 21, 2023
24925c8
Fix: typo
Dahoas Aug 21, 2023
a022d3f
Merge branch 'main' into BoN
maxreciprocate Sep 1, 2023
9680c9f
Merge branch 'main' into bon-x
maxreciprocate Sep 1, 2023
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
5 changes: 3 additions & 2 deletions trlx/trainer/accelerate_base_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import ray
import torch
from torch.nn.utils.rnn import pad_sequence
from accelerate import Accelerator # type: ignore
from ray.air import session
from rich.console import Console
Expand Down Expand Up @@ -288,8 +289,8 @@ def generate(self, input_ids, attention_mask=None, chunk_size=None, **kwargs):
input_ids=input_ids[chunk_idx], attention_mask=attention_mask[chunk_idx], **generate_kwargs
)
samples.append(sample)
# Concat samples
samples = torch.cat(samples, 0)
# Concat padded samples
samples = pad_sequence(samples, batch_first=True, self.tokenizer.pad_token_id)
maxreciprocate marked this conversation as resolved.
Show resolved Hide resolved
return samples

def save_pretrained(self, directory: Optional[str] = None, **kwargs):
Expand Down