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

add script: merge the lora weights to the base model #136

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions training/lora/example/redpajama-incite-chat-3b_merge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM

peft_model_path = 'outputs/redpajama-incite-chat-3b-sample-lowrank'

config = PeftConfig.from_pretrained(peft_model_path)
model = AutoModelForCausalLM.from_pretrained(
config.base_model_name_or_path,
return_dict=True,
device_map='auto')

# Load the Lora model
model = PeftModel.from_pretrained(model, peft_model_path)

model = model.merge_and_unload()

model.save_pretrained('outputs/redpajama-incite-chat-3b-sample-lowrank-merged')