Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This may not be the best modification, but the previous code couldn't run directly. The following code needs to be added for it to work, otherwise, the following error would occur:
`
Traceback (most recent call last):
File "/workspace/wubing/titan/scripts/leaderboard/lora/merge_loras_peft_example.py", line 13, in
model = PeftModel.from_pretrained(model, "smangrul/tinyllama_lora_norobots", adapter_name="norobots")
File "/workspace/wubing/anaconda3/envs/titan/lib/python3.10/site-packages/peft/peft_model.py", line 581, in from_pretrained
load_result = model.load_adapter(
File "/workspace/wubing/anaconda3/envs/titan/lib/python3.10/site-packages/peft/peft_model.py", line 1239, in load_adapter
load_result = set_peft_model_state_dict(
File "/workspace/wubing/anaconda3/envs/titan/lib/python3.10/site-packages/peft/utils/save_and_load.py", line 451, in set_peft_model_state_dict
load_result = model.load_state_dict(peft_model_state_dict, strict=False)
File "/workspace/wubing/anaconda3/envs/titan/lib/python3.10/site-packages/torch/nn/modules/module.py", line 2584, in load_state_dict
raise RuntimeError(
RuntimeError: Error(s) in loading state_dict for PeftModelForCausalLM:
size mismatch for base_model.model.model.embed_tokens.base_layer.weight: copying a param with shape torch.Size([32005, 2048]) from checkpoint, the shape in current model is torch.Size([32000, 2048]).
size mismatch for base_model.model.model.embed_tokens.lora_embedding_A.norobots: copying a param with shape torch.Size([8, 32005]) from checkpoint, the shape in current model is torch.Size([8, 32000]).
size mismatch for base_model.model.lm_head.base_layer.weight: copying a param with shape torch.Size([32005, 2048]) from checkpoint, the shape in current model is torch.Size([32000, 2048]).
size mismatch for base_model.model.lm_head.lora_B.norobots.weight: copying a param with shape torch.Size([32005, 8]) from checkpoint, the shape in current model is torch.Size([32000, 8]).
`