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

13b-chat使用llama.cpp转换模型的时候,词表长度对不上 #110

Open
iDonal opened this issue Sep 15, 2023 · 3 comments
Open

13b-chat使用llama.cpp转换模型的时候,词表长度对不上 #110

iDonal opened this issue Sep 15, 2023 · 3 comments

Comments

@iDonal
Copy link

iDonal commented Sep 15, 2023

Exception: Vocab size mismatch (model has 60928, but /home/rsync_user/tigerbot-13b-chat/tokenizer.model combined with /home/rsync_user/tigerbot-13b-chat/added_tokens.json has 60515).

提供的词表tokens 总数应该是60515
模型词表宽度是60928

@iDonal
Copy link
Author

iDonal commented Sep 15, 2023

@i4never
Copy link
Contributor

i4never commented Sep 15, 2023

你好,这是因为pretrain时候对词表进行了分片,由于分片均匀要求,对embedding和lm head做了pad处理。可以试试用以下代码转换后的模型:

import transformers

model = transformers.AutoModelForCausalLM.from_pretrained('/home/rsync_user/tigerbot-13b-chat', torch_dtype=torch.bfloat16)
model.resize_token_embeddings(60515)
model.save_pretrained('./tigerbot-13b-chat-vocab-60515')

resize会丢弃embedding与lm_head的末尾pad部份。
https://github.com/huggingface/transformers/blob/869733ab621495b938d0754176f7f1e360ae7ea9/src/transformers/modeling_utils.py#L1581

@iDonal
Copy link
Author

iDonal commented Sep 20, 2023

可以了通过llama.cpp转换了,感谢!

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

No branches or pull requests

2 participants