Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: add HF tagging in unsloth #170

Merged
merged 1 commit into from
Feb 13, 2024
Merged

Conversation

younesbelkada
Copy link
Contributor

Hi @danielhanchen 馃憢 !

This PR adds the model tagging feature so that you can easily filter all models that use unsloth that have been pushed on the Hub through a simple filter search on the Hub, e.g.: https://huggingface.co/models?other=unsloth

We do add the tag "unsloth" on SFTTrainer but this PR makes it possible to add the tags for all Trainer / non-Trainer usage for the FastLanguageModel from unsloth.

As this feature is only available from transformers >= 4.37.0 I guarded the call with a

if hasattr(model, "add_model_tags"):

Let me know what do you think !

@younesbelkada
Copy link
Contributor Author

I quickly tested the implementation with this snippet:

from unsloth import FastLanguageModel
# Load Llama model
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "HuggingFaceM4/tiny-random-LlamaForCausalLM", # Supports Llama, Mistral - replace this!
    max_seq_length = 512,
    dtype = None,
    load_in_4bit=False
)

print(model.model_tags)

and it seems to work fine: https://huggingface.co/ybelkada/test-tiny-llama-unsloth

@danielhanchen
Copy link
Contributor

@younesbelkada Oh thanks!! Oh yes definitely adding tags directly makes sense! Definitely can add this in - thanks so much again! :)

@danielhanchen danielhanchen merged commit 7c46209 into unslothai:main Feb 13, 2024
@julien-c
Copy link

julien-c commented Feb 15, 2024

this is really cool! 馃Ε+馃

@danielhanchen
Copy link
Contributor

@julien-c :)) Love the model tags feature! :)

cm2435 pushed a commit to cm2435/unsloth that referenced this pull request Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants