How to change the "How to use from the Transformers library"
Hi,I have uploaded my trained model to HF and created a model card for it.I’m trying to modify the code snippet on the  “How to use from the Transformers library” (after pressing the “use this model” top right button), how can I do that?Thanks
2024-05-20T09:16:46Z
Hi,This can be done as shown in this PR:Add snippets to KerasNLP models by Wauplin · Pull Request #628 · huggingface/huggingface.js · GitHub. Basically there’s a file named “model-libraries-snippets.ts” (this is in TypeScript) where you can add your custom code snippet.
2024-05-20T12:34:33Z
Is there a way that doesn’t involve changing the source code?
2024-05-20T12:57:27Z
Pinging@osansevierohere
2024-05-20T13:07:53Z
My main issue is that I want to have a snippet with different tokenizer from the model’s tokenizer, for both the pipeline and the direct use.it supposed to look like that:Screenshot 2024-05-20 at 16.02.291920×1038 76.7 KB
2024-05-21T06:44:04Z
Unfortunately, you cannot directly modify the code snippet on the “How to use from the Transformers library” section of your uploaded model on Hugging Face. This code snippet is automatically generated based on the model you upload and the configuration files associated with it.However, there are a few ways you can address this:Update your Model Card:The model card is the primary place for users to find information on how to use your model. You can clearly explain any specific steps or considerations needed when using your model in the “Usage” section of the model card. This includes mentioning any deviations from the standard Transformers library usage for your particular model.Provide a Separate Usage Script:You can upload a separate script or Jupyter Notebook to your model repository that demonstrates how to use your model.  In the description of the script, mention that users should refer to this script for detailed usage instructions.Link to an External Resource:If you have a blog post, documentation, or another external resource that details how to use your model, you can link to that resource in the model card.Here are some additional tips:Be Clear and Concise: In your model card or external resource, provide clear and concise instructions on how to use your model. This should include information on:
    How to install any required dependencies
    How to load your model from the Hub
    How to prepare your data for inference
    How to make predictions with your model
Provide Examples: Including code examples in your model card or external resource can be incredibly helpful for users who want to quickly get started using your model.
2024-05-22T07:28:34Z
These are all useful approaches, thank you!