mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-08-03 04:02:49 +08:00
Update utils.py
Fix parameters load error. Former-commit-id: 30fb721f1222d1b56a2712519960a63655c20360
This commit is contained in:
parent
1cd0ea1f13
commit
6ded1725d9
@ -10,8 +10,8 @@ if TYPE_CHECKING:
|
||||
def replace_model(model: "AutoModelForCausalLMWithValueHead", target: Literal["default", "reward"]) -> None:
|
||||
if target == "reward": # save default head temporarily
|
||||
valuehead_state_dict = model.v_head.state_dict()
|
||||
setattr(model, "default_head_weight", valuehead_state_dict["summary.weight"])
|
||||
setattr(model, "default_head_bias", valuehead_state_dict["summary.bias"])
|
||||
setattr(model, "default_head_weight", valuehead_state_dict["summary.weight"].clone())
|
||||
setattr(model, "default_head_bias", valuehead_state_dict["summary.bias"].clone())
|
||||
|
||||
model.pretrained_model.set_adapter(target) # set the LoRA adapter to be active
|
||||
model.v_head.load_state_dict({
|
||||
|
Loading…
x
Reference in New Issue
Block a user