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

增加每个checkpoint的config文件的存储,防止加载错误 #86

Open
wants to merge 1 commit into
base: master
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
11 changes: 10 additions & 1 deletion finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,16 @@ def save_model(self, output_dir=None, _internal_call=False):
k: v.to("cpu") for k, v in self.model.named_parameters() if v.requires_grad
}
torch.save(saved_params, os.path.join(output_dir, "adapter_model.bin"))

if self.model.peft_config.base_model_name_or_path is None:
self.model.peft_config.base_model_name_or_path = (
self.model.base_model.__dict__.get("name_or_path", None)
if isinstance(self.model.peft_config, PromptLearningConfig)
else self.model.base_model.model.__dict__.get("name_or_path", None)
)
inference_mode = self.model.peft_config.inference_mode
self.model.peft_config.inference_mode = True
self.model.peft_config.save_pretrained(output_dir)
self.model.peft_config.inference_mode = inference_mode

def main():
finetune_args, training_args = HfArgumentParser(
Expand Down