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

[fix]Update merge model related codes : avoid UnboundLocalError #1283

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Update merge_layerwise_model_from_raw_model.py
在transformers  = 4.43.1, peft  = 0.12.0版本中,原代码merge llm_reranker_model时会报错:UnboundLocalError: local variable 'active_adapters' referenced before assignment。

需要将model._hf_peft_config_loaded设为False,可以避免这个问题出现
AndyVerne authored Dec 6, 2024
commit 08657c566a03169438c23620ce7d9bae3696e727
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ def merge_layerwise_raw_llm(model_name_or_path, lora_name_or_path, save_path, ca

model = PeftModel.from_pretrained(model, lora_name_or_path)
model = model.merge_and_unload()
model._hf_peft_config_loaded = False
model.save_pretrained(save_path)

try: