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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: add HF tags for models that have been trained with llama-factory #2474

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

younesbelkada
Copy link
Contributor

Hi @hiyouga !

Great work on the Llama-Factory library ! 🚀
I would like to propose a new feature request: model tagging

With transformers 4.37.0 we added model tagging support by automatically tagging models on the Hub. That way you could sort models that have a specific tag, e.g. it you want to filter models that have the tag trl you could use think link: https://huggingface.co/models?other=trl / so for llama-factory: https://huggingface.co/models?other=llama-factory

I see it is already done in the get_modelcard_args method but add_model_tags enables you to push that tag even if you don't call trainer.push_to_hub and simply calling model.push_to_hub() will automatically push the model + the llama-factory tag

Let me know if this PR makes sense, otherwise we can also close it as technically the tags are already pushed, this PR would just cover the case where users use your trainer without pushing the trainer itself but the model.

@hiyouga
Copy link
Owner

hiyouga commented Feb 13, 2024

Hi @younesbelkada ! Thanks for adding this patch, we are willing to utilize the new feature in transformers 4.37.0.

However, we found the implementation of push_to_hub in the Hugging Face's Trainer a bit strange: [1]

  1. "model_tags" would be only appended when the users pass the "tags" argument to push_to_hub.
  2. It would result in duplicate tags if there was an overlap between "model_tags" and "tags".

I am curious about the reason behind this design. Looking forward to hearing back from you.

[1] https://github.com/huggingface/transformers/blob/v4.37.2/src/transformers/trainer.py#L3737-L3747

@younesbelkada
Copy link
Contributor Author

Hi @hiyouga

Thanks!
I had a look at your comment, I think that I did a mistake when designing that logic, indeed we should always push the tag if model.add_model_tags() is called. I made huggingface/transformers#29009 which should solve this unintended behaviour
Regarding your second point, there shouldn't be any duplicated tag I think, the block:

                if model_tag not in kwargs["tags"]:
                    kwargs["tags"].append(model_tag)

Circumvents that + even if multiple duplicated tags exists on the model card (which is less likely to happen give that guard + https://github.com/huggingface/transformers/blob/main/src/transformers/utils/hub.py#L1142 ) on the frontend they'll be always displayed a as a single tag. See: https://huggingface.co/ybelkada/test-bert-tags/commit/631bcabcc22cf313dd63441a85b122317fce6680

Let me know what do you think !

@hiyouga
Copy link
Owner

hiyouga commented Feb 14, 2024

@younesbelkada Thanks! I think the above modification is fine, and this PR could now be safely merged.

@hiyouga hiyouga merged commit 8a1b389 into hiyouga:main Feb 14, 2024
1 check passed
@younesbelkada younesbelkada deleted the add-hf-tags branch February 14, 2024 02:33
@hiyouga hiyouga added the solved This problem has been already solved label Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved This problem has been already solved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants