TIGER-AI-Lab / Mantis

Official code for Paper "Mantis: Multi-Image Instruction Tuning"
https://tiger-ai-lab.github.io/Mantis/
Apache License 2.0
177 stars 15 forks source link

Merging LoRA weights with base model #19

Closed hungnh1125 closed 1 month ago

hungnh1125 commented 2 months ago

Hi,

Thank you for sharing the Mantis source code.

I trained your LLaMA3 model with SigLIP on my dataset. The model saves a checkpoint every 500 steps. I would like to merge the LoRA weights from these checkpoints (for example checkpoint in step 1000) with your base pretrained SigLIP-LLaMA3 model. Could you please share the source code for merging the LoRA weights?

Thank you! Hung Nguyen

jdf-prog commented 2 months ago

We did not explicitly merge the LoRA weights with some scripts. Instead, we directly set the model_name_or_path to be the path of the lora adapter path. Since the adapater_config.json has a parameter called base_model_name_or_path, which specifies which the path or name of which model it should be merged before use. And transformers library will automatically do this merging during the loading.

jdf-prog commented 2 months ago

See hugging face transformers doc for more details: https://huggingface.co/docs/transformers/en/peft#load-a-peft-adapter