Skip to content

FEAT: add HF tagging in unsloth - #170

Merged
danielhanchen merged 1 commit into
unslothai:mainfrom
younesbelkada:main
Feb 13, 2024
Merged

danielhanchen merged 1 commit into
unslothai:mainfrom
younesbelkada:main

Conversation

@younesbelkada

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

@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

julien-c commented Feb 15, 2024 •

Copy link
Copy Markdown

this is really cool! 🦥+🤗

@danielhanchen

Copy link
Copy Markdown
Member

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

cm2435 pushed a commit to cm2435/unsloth that referenced this pull request Feb 26, 2024
abiswas-realadvice pushed a commit to abiswas-realadvice/unsloth that referenced this pull request May 14, 2026
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.

3 participants