[Feature request] Improved metadata & code snippets
Hi @Felladrin ,
I think it could be a good idea to update the space to re-use the model card of the original repo, only with some minor tag changes (e.g., base_model, transformers.js compatibility, etc.)
Another -- more challenging -- task would be ensuring each model card comes with a boilerplate usage example (either w/ python onnxruntime or transformers.js, or both) depending on the task.
WDYT?
cc @reach-vb
Totally agree!
@PierreMesure has added a base template for the Readme [1], but I'm sure he had bigger plans for this.
If he doesn't pick this task any time soon, I'll do on my next gap.
Hi @Xenova @Felladrin ,
I'm sorry, I don't go often in my HuggingFace notifications. Happy to try to do the first part, it sounds easy. The second part with boilerplate usage example could be tricky, especially if we want them to remain updated. Is there some form of database with these code snippets for the different types of models? I had a quick look at the documentation for transformers.js and I found this list and code snippets there. Maybe it would be enough to link to the specific pipeline in the documentation?
Hi, @PierreMesure !
Glad to read you can do the first part!
About the second part, I agree that we could just link to the specific pipeline in the documentation. Besides that, in the model card there's the button "Use this model" which already shows the proper snippet to run it.
Here's an example from onnx-community/whisper-small-ONNX:
And regarding adding the link to the documentation in the model card, we just need a map from pipeline name to the documentation anchor.
The two links you pointed have all the info we need. And using the huggingface_hub
library, we can find out which pipeline the model uses:
from huggingface_hub import model_info
model_details = model_info(repo_id="openai/whisper-small")
pipeline_tag = model_details.pipeline_tag
print(f"The pipeline_tag for the model is '{pipeline_tag}'.")
# The pipeline_tag for the model is 'automatic-speech-recognition'.
So, at the moment of the conversion, we fetch the model's pipeline, match with the docs link and append it to the model card.