Model Cards

New! Try our experimental Model Card Creator App

What are Model Cards?

Model cards are files that accompany the models and provide handy information. Under the hood, model cards are simple Markdown files with additional metadata. Model cards are essential for discoverability, reproducibility, and sharing! You can find a model card as the README.md file in any model repo.

The model card should describe:

The model card template is available here.

Model card metadata

A model repo will render its README.md as a model card. The model card is a Markdown file, with a YAML section at the top that contains metadata about the model.

The metadata you add to the model card supports discovery and easier use of your model. For example:

Dataset, metric, and language identifiers are those listed on the Datasets, Metrics and Languages pages.

Adding metadata to your model card

There are a few different ways to add metadata to your model card including:

Many libraries with Hub integration will automatically add metadata to the model card when you upload a model.

Using the metadata UI

You can add metadata to your model card using the metadata UI. To access the metadata UI, go to the model page and click on the Edit model card button in the top right corner of the model card. This will open an editor showing the model card README.md file, as well as a UI for editing the metadata.

This UI will allow you to add key metadata to your model card and many of the fields will autocomplete based on the information you provide. Using the UI is the easiest way to add metadata to your model card, but it doesn’t support all of the metadata fields. If you want to add metadata that isn’t supported by the UI, you can edit the YAML section of the README.md file directly.

Editing the YAML section of the README.md file

You can also directly edit the YAML section of the README.md file. If the model card doesn’t already have a YAML section, you can add one by adding three --- at the top of the file, then include all of the relevant metadata, and close the section with another group of --- like the example below:

---
language: 
  - "List of ISO 639-1 code for your language"
  - lang1
  - lang2
thumbnail: "url to a thumbnail used in social sharing"
tags:
- tag1
- tag2
license: "any valid license identifier"
datasets:
- dataset1
- dataset2
metrics:
- metric1
- metric2
base_model: "base model Hub identifier"
---

You can find the detailed model card metadata specification here.

Specifying a library

You can specify the supported libraries in the model card metadata section. Find more about our supported libraries here. The library will be specified in the following order of priority:

  1. Specifying library_name in the model card (recommended if your model is not a transformers model). This information can be added via the metadata UI or directly in the model card YAML section:
library_name: flair
  1. Having a tag with the name of a library that is supported
tags:
- flair

If it’s not specified, the Hub will try to automatically detect the library type. Unless your model is from transformers, this approach is discouraged and repo creators should use the explicit library_name as much as possible.

  1. By looking into the presence of files such as *.nemo or *saved_model.pb*, the Hub can determine if a model is from NeMo or Keras.
  2. If nothing is detected and there is a config.json file, it’s assumed the library is transformers.

Specifying a base model

If your model is a fine-tune or adapter of a base model, you can specify the base model in the model card metadata section:

base_model: HuggingFaceH4/zephyr-7b-beta

This metadata will be used to display the base model on the model page. Users can also use this information to filter models by base model or find models that are fine-tuned from a specific base model.

Specifying a dataset

You can specify the datasets used to train your model in the model card metadata section. The datasets will be displayed on the model page and users will be able to filter models by dataset. You should use the Hub dataset identifier, which is the same as the dataset’s repo name as the identifier:

datasets:
- imdb
- HuggingFaceH4/no_robots

Specifying a task ( pipeline_tag )

You can specify the pipeline_tag in the model card metadata. The pipeline_tag indicates the type of task the model is intended for. This tag will be displayed on the model page and users can filter models on the Hub by task. This tag is also used to determine which widget to use for the model and which APIs to use under the hood.

For transformers models, the pipeline tag is automatically inferred from the model’s config.json file but you can override it in the model card metadata if required. Editing this field in the metadata UI will ensure that the pipeline tag is valid. Some other libraries with Hub integration will also automatically add the pipeline tag to the model card metadata.

Specifying a license

You can specify the license in the model card metadata section. The license will be displayed on the model page and users will be able to filter models by license. Using the metadata UI, you will see a dropdown of the most common licenses.

If required, you can also specify a custom license by adding other as the license value and specifying the name and a link to the license in the metadata.

# Example from https://huggingface.co/coqui/XTTS-v1
---
license: other
license_name: coqui-public-model-license
license_link: https://coqui.ai/cpml
---

If the license is not available via a URL you can link to a LICENSE stored in the model repo.

Evaluation Results

You can even specify your model’s eval results in a structured way, which will allow the Hub to parse, display, and even link them to Papers With Code leaderboards. See how to format this data in the metadata spec.

Here is a partial example (omitting the eval results part):

---
language:
- ru
- en
tags:
- translation
license: apache-2.0
datasets:
- wmt19
metrics:
- bleu
- sacrebleu
---

If a model includes valid eval results, they will be displayed like this:

CO <sub> 2 </sub> Emissions

The model card is also a great place to show information about the CO2 impact of your model. Visit our guide on tracking and reporting CO2 emissions to learn more.

Linking a Paper

If the model card includes a link to a paper on arXiv, the Hugging Face Hub will extract the arXiv ID and include it in the model tags with the format arxiv:<PAPER ID>. Clicking on the tag will let you:

Read more about Paper pages here.

FAQ

How are model tags determined?

Each model page lists all the model’s tags in the page header, below the model name. These are primarily computed from the model card metadata, although some are added automatically, as described in Creating a Widget.

Can I add custom tags to my model?

Yes, you can add custom tags to your model by adding them to the tags field in the model card metadata. The metadata UI will suggest some popular tags, but you can add any tag you want. For example, you could indicate that your model is focused on finance by adding a finance tag.

How can I indicate that my model is not suitable for all audiences

You can add a not-for-all-audience tag to your model card metadata. When this tag is present, a message will be displayed on the model page indicating that the model is not for all audiences. Users can click through this message to view the model card.

Can I write LaTeX in my model card?

Yes! The Hub uses the KaTeX math typesetting library to render math formulas server-side before parsing the Markdown.

You have to use the following delimiters:

Then you’ll be able to write: LaTeX \LaTeX MSE=(1n)i=1n(yixi)2 \mathrm{MSE} = \left(\frac{1}{n}\right)\sum_{i=1}^{n}(y_{i} - x_{i})^{2} E=mc2 E=mc^2