-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use Unsloth FastVisionModel for VLM #7295
base: main
Are you sure you want to change the base?
Conversation
@@ -48,11 +53,14 @@ def load_unsloth_pretrained_model( | |||
config: "PretrainedConfig", model_args: "ModelArguments" | |||
) -> Optional["PreTrainedModel"]: | |||
r"""Optionally load pretrained model with unsloth. Used in training.""" | |||
from unsloth import FastLanguageModel # type: ignore | |||
if is_multimodal(model_args.model_name_or_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about use FastModel
? https://github.com/unslothai/unsloth/blob/main/unsloth/models/loader.py#L722-L726
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for LLM, the recommended class to use is FastLanguageModel
, which inherits from FastLlamaModel
(https://github.com/unslothai/unsloth/blob/main/unsloth/models/loader.py#L69C25-L69C40, https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3.1_(8B)-Alpaca.ipynb)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
|
||
|
||
def load_unsloth_peft_model( | ||
config: "PretrainedConfig", model_args: "ModelArguments", is_trainable: bool | ||
) -> "PreTrainedModel": | ||
r"""Load peft model with unsloth. Used in both training and inference.""" | ||
from unsloth import FastLanguageModel # type: ignore | ||
if is_multimodal(model_args.model_name_or_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about the situation of providing a local path to the model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks ! I will check for that ASAP
What does this PR do?
This PR propose to use unsloth
FastVisionModel
instead ofFastLanguageModel
for multimodal model.