You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@OsaCode When you load LoRA adapters, did you load only your name/model_name?
Ie: danielhanchen/lora_model
Or unsloth/mistral-7b-bnb-4bit
After that, the below code is taken from the Mistral 7b notebook in the Readme:
fromunslothimportFastLanguageModelmodel, tokenizer=FastLanguageModel.from_pretrained(
model_name="lora_model", # YOUR MODEL YOU USED FOR TRAININGmax_seq_length=max_seq_length,
dtype=dtype,
load_in_4bit=load_in_4bit,
)
FastLanguageModel.for_inference(model) # Enable native 2x faster inferencealpaca_prompt="""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.### Instruction:{}### Input:{}### Response:{}"""inputs=tokenizer(
[
alpaca_prompt.format(
"What is a famous tall tower in Paris?", # instruction"", # input"", # output - leave this blank for generation!
)
], return_tensors="pt").to("cuda")
outputs=model.generate(**inputs, max_new_tokens=64, use_cache=True)
tokenizer.batch_decode(outputs)
Indeed, I tried to find if FastLanguageModel.from_pretrained had an argument "adapter" or "token" to let it query my private repo, but did not succeed.
I am able to load the model I saved in local, but I wanted to do the same from the hub but the documentation does not show any example.
I was able to load the model and the adapter using HuggingFace base method :
`from peft import PeftConfig, PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
from unsloth import FastLanguageModel
I saved to the hub the adapter I trained using the example notebook.
It's not a complete model.
I get the error in my Issue message with the token (which is correct, I used it with PeftModel.from_pretrained).
Activity
danielhanchen commentedon Feb 20, 2024
@OsaCode When you load LoRA adapters, did you load only your name/model_name?
Ie:
danielhanchen/lora_modelOr
unsloth/mistral-7b-bnb-4bitAfter that, the below code is taken from the Mistral 7b notebook in the Readme:
OsaCode commentedon Feb 20, 2024
Indeed, I tried to find if FastLanguageModel.from_pretrained had an argument "adapter" or "token" to let it query my private repo, but did not succeed.
I am able to load the model I saved in local, but I wanted to do the same from the hub but the documentation does not show any example.
OsaCode commentedon Feb 20, 2024
I was able to load the model and the adapter using HuggingFace base method :
`from peft import PeftConfig, PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
from unsloth import FastLanguageModel
base_model_name = "unsloth/mistral-7b-bnb-4bit"
adapter_model_name = "OsaCode/xxx"
model = AutoModelForCausalLM.from_pretrained(base_model_name, token="xxx")
model = PeftModel.from_pretrained(model, adapter_model_name, token="xxx")
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
FastLanguageModel.for_inference(model) # Enable native 2x faster inference`
But I am not sure Unsloth's faster inference took effect.
danielhanchen commentedon Feb 20, 2024
@OsaCode Oh for a token + your model
OsaCode/xxxOsaCode commentedon Feb 20, 2024
I saved to the hub the adapter I trained using the example notebook.
It's not a complete model.
I get the error in my Issue message with the token (which is correct, I used it with PeftModel.from_pretrained).
danielhanchen commentedon Feb 20, 2024
@OsaCode I just updated Unsloth - maybe it might work now? Unsure though :( Sorry on the issue :(
OsaCode commentedon Feb 21, 2024
You mean that it should be able to load the complete model just from the adapters ? It does not need to be given the name of the base model as well ?
I will be updating and trying.
danielhanchen commentedon Feb 21, 2024
@OsaCode Yes exactly! I will auto detect it as an adapter, and I will do the patching for you internally :)
OsaCode commentedon Feb 21, 2024
Ok updating solved the issue, thank you
Gemma 3N bug fixes (unslothai#184)