nateraw / modelcards

📝 Utility to create, edit, and publish model cards on the Hugging Face Hub. [**Now lives in huggingface_hub**]
MIT License
15 stars 4 forks source link

Model card template for NLP models with corresponding auto-fill texts for different variables #59

Open mgerchick opened 2 years ago

mgerchick commented 2 years ago
from modelcards import ModelCard, CardData

repo_id = "" # Place your repo id here

# Set the metadata that will go at the top of the card
card_data = CardData(
    license='mit',
    language=['en', 'fr', 'multilingual'],
    )

# Model card for a text generation model
card1 = ModelCard.from_template(
    card_data, 
    template_path='NLP_modelcard_new_spec.md', 
    model_id=repo_id.split('/')[-1], 
    model_task="text_generation", 
    authors=['person1', 'person2', 'person3'],
    model_summary="This is a placeholder summary.",
    related_models=['fake_model1', 'fake_model2'],
    blog_link="https://huggingface.co", 
    paper_link="https://huggingface.co",
    model_card_user="policymaker")

# Model card with no task specified, where direct use and downstream use are specified
card2 = ModelCard.from_template(
    card_data, 
    template_path='NLP_modelcard_new_spec.md', 
    model_id=repo_id.split('/')[-1], 
    authors=['person1', 'person2', 'person3'],
    model_summary="This is a placeholder summary.",
    related_models=['fake_model1', 'fake_model2'],
    blog_link="https://huggingface.co", 
    paper_link="https://huggingface.co",
    direct_use="This model can be used to do some sort of task.",
    downstream_use="This model can be used downstream as part of some system.")

# if you want to push it to the hub
card1.push_to_hub( # change to card 1 or 2 accordingly
    repo_id,
    commit_message="initial model card",
    create_pr=True)