modelcards icon indicating copy to clipboard operation
modelcards copied to clipboard

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

Open mgerchick opened this issue 2 years ago • 0 comments

  • Template for NLP models with corresponding auto-fill texts for different variables: NLP_modelcard_new_spec.md

  • Explanation of template variables and expected values: nlp_modelcard_template_vars.md

  • Examples of generating model cards using the modelcards repo and this template:

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)

mgerchick avatar Jul 14 '22 21:07 mgerchick