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 resize_token_embeddings #2290

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bingwork
Copy link

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]).

`

@BenjaminBossan
Copy link
Member

Thank you for this PR. I just want to let you know that we're currently on vacation and will review this next year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants