unsloth icon indicating copy to clipboard operation
unsloth copied to clipboard

How to merge lora adapter with pretrained weights?

Open MRQJsfhf opened this issue 9 months ago • 1 comments

MRQJsfhf avatar Apr 30 '24 07:04 MRQJsfhf

Oh our Colab notebooks on the bottom have this! See https://github.com/unslothai/unsloth/wiki#saving-models-to-16bit-for-vllm

Ie:

model.save_pretrained_merged("model", tokenizer, save_method = "merged_16bit",)
model.push_to_hub_merged("hf/model", tokenizer, save_method = "merged_16bit", token = "")

danielhanchen avatar May 01 '24 18:05 danielhanchen

I have trained an adapter for Qwen2 and pushed it to huggingface hub after using auto train. Now I don’t have access to the virtual machine that created the adapter. But, I have access to the adapter. How do I merge this adapter with the original Qwen2 model?

johnyquest7 avatar Jun 25 '24 14:06 johnyquest7

So sorry on the delay @johnyquest7 - just relocated to SF so the slowness. You can try loading the adapter itself through FastLanguageModel.from_pretrained(adapter) then doing the saving to 16bit

danielhanchen avatar Jul 01 '24 00:07 danielhanchen