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

[FIXED] I wrote a script to merge lora thanks to slaren its done #1516

Closed
FNsi opened this issue May 18, 2023 · 6 comments
Closed

[FIXED] I wrote a script to merge lora thanks to slaren its done #1516

FNsi opened this issue May 18, 2023 · 6 comments

Comments

@FNsi
Copy link
Contributor

FNsi commented May 18, 2023

merge.py
it seems work. may stuck in embedding step? No clue now.

but while using convert.py

File "convert.py", line 1168, in
main()
File "onvert.py", line 1148, in main
model_plus = load_some_model(args.model)
File "convert.py", line 1076, in load_some_model
model_plus = merge_multifile_models(models_plus)
File "convert.py", line 583, in merge_multifile_models
model = merge_sharded([mp.model for mp in models_plus])
File "convert.py", line 562, in merge_sharded
return {name: convert(name) for name in names}
File "convert.py", line 562, in
return {name: convert(name) for name in names}
File "convert.py", line 537, in convert
lazy_tensors: List[LazyTensor] = [model[name] for model in models]
File "convert.py", line 537, in
lazy_tensors: List[LazyTensor] = [model[name] for model in models]
KeyError: 'embed_tokens.weight'

can someone try that script?

@FNsi FNsi changed the title [User] I wrote a script to merge lora, but afterall, cannot be done by convert.py?? [User] I wrote a script to merge lora, but afterall, cannot be done by convert.py, anyone can help? May 18, 2023
@slaren
Copy link
Member

slaren commented May 18, 2023

Using LlamaForCausalLM instead of LlamaModel seems to fix it.

@FNsi
Copy link
Contributor Author

FNsi commented May 18, 2023

Using LlamaForCausalLM instead of LlamaModel seems to fix it.

It's not working in my env?

As I wrote in the last lines... "llamaforcusallm" no attribute "merge_and_unload"

@FNsi
Copy link
Contributor Author

FNsi commented May 18, 2023

merge.txt

Using LlamaForCausalLM instead of LlamaModel seems to fix it.

It's not working in my env?

As I wrote in the last lines... "llamaforcusallm" no attribute "merge_and_unload"

So wired, I try it again and it work....
feel free to play with it.

@FNsi FNsi changed the title [User] I wrote a script to merge lora, but afterall, cannot be done by convert.py, anyone can help? [FIX] I wrote a script to merge lora, but afterall, cannot be done May 18, 2023
@FNsi FNsi changed the title [FIX] I wrote a script to merge lora, but afterall, cannot be done [FIX] I wrote a script to merge lora thanks to slaren its done May 18, 2023
@FNsi FNsi changed the title [FIX] I wrote a script to merge lora thanks to slaren its done [FIXED] I wrote a script to merge lora thanks to slaren its done May 18, 2023
@FNsi
Copy link
Contributor Author

FNsi commented May 19, 2023

Using LlamaForCausalLM instead of LlamaModel seems to fix it.

Do you mind I creat a PR with it?

@Naozumi520
Copy link

Naozumi520 commented Aug 30, 2023

May I ask, how can I use the model after merging? I gotpytorch_model-00001-of-00002.bin, pytorch_model-00002-of-00002.bin, config.json and generation_config.json after merging. Then, I used convert-llama-hf-to-gguf.py to covert to gguf. One problem is it returns error did not have the file tokenizer.model and refuse to process, so I copied it from the original base model (meta-llama/Llama-2-7b-chat-hf) and then quantized it into 4bit. But after that it didn't act like I expected. My lora is trained with Cantonese dataset, but the merge model didn't return even a word in cantonese. Any idea? :(

@FNsi
Copy link
Contributor Author

FNsi commented Aug 31, 2023

May I ask, how can I use the model after merging? I gotpytorch_model-00001-of-00002.bin, pytorch_model-00002-of-00002.bin, config.json and generation_config.json after merging. Then, I used convert-llama-hf-to-gguf.py to covert to gguf. One problem is it returns error did not have the file tokenizer.model and refuse to process, so I copied it from the original base model (meta-llama/Llama-2-7b-chat-hf) and then quantized it into 4bit. But after that it didn't act like I expected. My lora is trained with Cantonese dataset, but the merge model didn't return even a word in cantonese. Any idea? :(

Sorry I didn't have any idea about GGUF now....

Might be able to convert it to ggml and then convert to gguf?

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

3 participants