huggingface / alignment-handbook

Robust recipes to align language models with human and AI preferences
https://huggingface.co/HuggingFaceH4
Apache License 2.0
4.28k stars 367 forks source link

can we inference with lora adapter after running the SFT ? #76

Closed Tejaswi-kashyap-006 closed 7 months ago

Tejaswi-kashyap-006 commented 7 months ago

I trained the model using SFT on a custom dataset using lora config, which produced a Lora adapter, can we infer with it like having a base model and this adapter on top of it, or merge it ?

DRXD1000 commented 7 months ago

Yes sure.

You can load the Model via from peft import AutoPeftModelForCausalLM model = AutoPeftModelForCausalLM.from_pretrained("your-adapter-repo") and use it directly.

if you wish to merge the adapter do

model = model.merge_and_unload()

now the adapter is merged into the base model with adapter weights applied

Tejaswi-kashyap-006 commented 7 months ago

Thanks @DRXD1000