Skip to content
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
1 change: 0 additions & 1 deletion examples/scripts/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class ScriptArguments:
# Model & Tokenizer
################
model = AutoModelForCausalLM.from_pretrained(model_config.model_name_or_path)
peft_config = get_peft_config(model_config)
tokenizer = AutoTokenizer.from_pretrained(model_config.model_name_or_path)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/dpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def process(row):
train_dataset=train_dataset,
eval_dataset=eval_dataset,
tokenizer=tokenizer,
peft_config=get_peft_config(model_config),
peft_config=peft_config,
callbacks=[RichProgressCallback] if TRL_USE_RICH else None,
)

Expand Down
10 changes: 3 additions & 7 deletions examples/scripts/dpo_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,8 @@ def process(row):
row["rejected"] = processor.apply_chat_template(row["rejected"], tokenize=False)

if "images" in row:
for idx, img in enumerate(row["images"]): # Resize each image so the largest side is 640 pixels
ratio = min(1.0, 640 / max(img.size))
new_size = (int(img.size[0] * ratio), int(img.size[1] * ratio))
row["images"][idx] = img.resize(new_size)
row["images"] = row["images"]

for img in row["images"]: # Resize each image so the largest side is 640 pixels
img.thumbnail((640, 640)) # Resize the image to at most 640x640 pixels
return row

with PartialState().local_main_process_first():
Expand All @@ -167,7 +163,7 @@ def process(row):
train_dataset=train_dataset,
eval_dataset=eval_dataset,
tokenizer=processor,
peft_config=get_peft_config(model_config),
peft_config=peft_config,
callbacks=[RichProgressCallback] if TRL_USE_RICH else None,
)

Expand Down
1 change: 0 additions & 1 deletion examples/scripts/orpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class ScriptArguments:
# Model & Tokenizer
################
model = AutoModelForCausalLM.from_pretrained(model_config.model_name_or_path)
peft_config = get_peft_config(model_config)
tokenizer = AutoTokenizer.from_pretrained(model_config.model_name_or_path)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
Expand Down