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

origin/sm/sft #48

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export CUDA_VISIBLE_DEVICES=$1
python style_transfer/run_rb_gen.py model.name=meta-llama/Llama-3.2-3B-Instruct \
model.peft_config.target_modules='["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]' \
dataset.name=bio-datasets/mimic-iii-gpt4o-tokens \
max_steps=5 \
dataset.num_generated_samples=3500 \
score.model.model_name_or_path=sentence-transformers/all-mpnet-base-v2 \
dataset.sft_ratio=0.06 \
dataset.gen_ratio=0.7 \
dataset.sft_dataset=null \
sft.training_args.eval_steps=30 \
score.train.train_size=0.6 \
dpo.training_args.num_train_epochs=10 \
dpo.percentile=70 \
score.batch_size=8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export CUDA_VISIBLE_DEVICES=$1
python style_transfer/run_rb_gen.py model.name=meta-llama/Llama-3.2-3B-Instruct \
model.peft_config.target_modules='["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]' \
dataset.name=bio-datasets/mimic-iii-gpt4o-tokens \
max_steps=5 \
dataset.num_generated_samples=3500 \
score.model.model_name_or_path=sentence-transformers/all-mpnet-base-v2 \
dataset.sft_ratio=0.06 \
dataset.gen_ratio=0.7 \
sft.training_args.eval_steps=30 \
score.train.train_size=0.6 \
dataset.sft_dataset.size=977 \
dpo.training_args.num_train_epochs=20 \
dpo.percentile=70 \
score.batch_size=8
3 changes: 2 additions & 1 deletion lib/style-transfer/style_transfer/rb_gen/steps/sft.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ def sft_train(

cfg.sft.training_args.output_dir = f"models/{wandb.run.id}/sft"
args = hydra.utils.instantiate(cfg.sft.training_args)
wandb.config.update({"state": "sft"}, allow_val_change=True)
test_sft_dataset = None
if cfg.dataset.sft_dataset is not None:
sft_dataset, test_sft_dataset = sft_dataset.train_test_split(
train_size=0.1, shuffle=False
train_size=0.5, shuffle=False
).values()
args.load_best_model_at_end = True
trainer = SFTTrainer(
Expand Down
4 changes: 4 additions & 0 deletions lib/style-transfer/style_transfer/rb_gen/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def build_dataset(

ds_dict: dict = {"keywords": [], "text": []}
for keywords, text in zip(ds["keywords"], ds["text"]):
if isinstance(keywords, str):
keywords = [keywords]
if isinstance(text, str):
text = [text]
for kw, t in zip(keywords, text):
ds_dict["keywords"].append(kw)
ds_dict["text"].append(t)
Expand Down
Loading