Sub topic 2
What a Model Card Is and Where It Came From
This chapter defines the model card, traces its origin, and walks through its standard sections. It assumes you know basic supervised learning (training, validation and test sets), common metrics such as accuracy, precision and recall, and basic Python and Markdown. Later chapters cover each section in detail, so here the aim is the working model of a card and the mistakes people make when they first write one.
The idea in one paragraph
A model card is a short, structured document that travels with a trained model. It says what the model is, what it is meant for, what data shaped it, how it was evaluated, and where it is known to fail. The reader is someone who did not build the model: a teammate who wants to reuse it, a reviewer who must approve it, an auditor, or an engineer deciding whether it fits a new product.
A card is not a marketing page and not a research paper. It is closer to a nutrition label or a technical data sheet for an electronic part. It gives a fixed set of facts, in a predictable order, so that readers can compare models and spot missing information.
Where it came from
The term comes from the 2019 paper "Model Cards for Model Reporting" by Margaret Mitchell and colleagues, presented at the ACM Conference on Fairness, Accountability, and Transparency. The paper proposed a short document that accompanies a released model and reports its performance in a way that is open about the conditions under which it works.
Two earlier ideas shaped it:
- Data sheets in electronics. Component makers publish operating conditions and tolerances. A buyer can tell whether a part is suited to a circuit before wiring it in.
- Datasheets for datasets. A related proposal asked dataset creators to document how data was collected and what it should not be used for. Model cards apply the same discipline to the model itself.
The main motivation was a pattern seen in deployed systems. A model scored well on an aggregate metric, was reused in a setting it was never tested on, and performed worse for some groups of people or some input conditions. The aggregate number hid the problem, and nothing in the released artifact warned anyone.
Since then the format has spread. Large model hubs ask for cards, many organizations require one before a model enters production, and regulators and auditors increasingly ask for the same kinds of facts. The exact layout varies, but the core content has stayed stable.
The working model: a card answers questions
It helps to treat each section as the answer to a question a downstream reader will ask.
| Section | Question it answers |
|---|---|
| Model details | What exactly is this artifact, who made it, and under what terms can I use it? |
| Intended use | What was this built for, and who should use it? |
| Out-of-scope use | What should I not use it for? |
| Training data | What did it learn from? |
| Evaluation | How well does it work, measured on what? |
| Disaggregated results | Does it work equally well for every group and condition? |
| Limitations and risks | Where does it fail, and what harm could follow? |
The original paper also listed factors (the groups and conditions that matter), metrics, evaluation data, training data, quantitative analyses, ethical considerations, and caveats and recommendations. Many modern cards merge these into the shorter list above. The names matter less than the questions being answered.
A card is structured content
Because a card has fixed sections, you can build it from data. The following dataclass holds the core fields and renders them as Markdown. This is the same content you would write by hand, but held in a form that code can create, check, and update.
from dataclasses import dataclass, field
@dataclass
class ModelCard:
name: str
version: str
intended_use: str
out_of_scope: str
training_data: str
metrics: dict
limitations: list = field(default_factory=list)
def to_markdown(self) -> str:
lines = [
f"# {self.name} (v{self.version})",
"",
"## Intended use",
self.intended_use,
"",
"## Out-of-scope use",
self.out_of_scope,
"",
"## Training data",
self.training_data,
"",
"## Evaluation",
]
lines += [f"- {name}: {value}" for name, value in self.metrics.items()]
lines += ["", "## Limitations"]
lines += [f"- {item}" for item in self.limitations]
return "\n".join(lines) + "\n"
card = ModelCard(
name="support-ticket-classifier",
version="1.2.0",
intended_use="Route English-language support tickets to one of five queues.",
out_of_scope="Not for legal, medical, or safety-critical triage.",
training_data="120k anonymized tickets collected 2022-2024.",
metrics={"accuracy": 0.91, "macro_f1": 0.88},
limitations=["Accuracy drops on tickets shorter than 5 words."],
)
print(card.to_markdown())Running this prints a Markdown document with a title, five headed sections, and bullet lists for metrics and limitations. Each field maps to one of the questions in the table above.
Generating a card from data has a practical benefit. Metrics can be written by the evaluation job itself, so the numbers in the card cannot drift from the numbers the job produced. Prose fields such as intended use still need a human, because they record a judgment and not a measurement.
Reading a card critically
Knowing the sections is only half the skill. The other half is noticing when a section is present but empty of content. Here are the most common failures.
Vague intended use
"Classifies text" tells a reader nothing. A useful statement names the task, the input type, the language, the user, and the setting. Compare it with the example above: "Route English-language support tickets to one of five queues." A reader can check that against their own use and see a mismatch quickly.
A single headline number
A lone accuracy figure says nothing about which inputs the model gets wrong. The next snippet shows why. Overall accuracy is 4 of 6, about 0.67, which looks mediocre but uniform. In fact group a is perfect and group b is mostly wrong.
from collections import defaultdict
def accuracy_by_group(y_true, y_pred, groups):
correct = defaultdict(int)
total = defaultdict(int)
for truth, pred, group in zip(y_true, y_pred, groups):
total[group] += 1
correct[group] += int(truth == pred)
return {group: correct[group] / total[group] for group in total}
y_true = [1, 0, 1, 1, 0, 0]
y_pred = [1, 0, 1, 1, 1, 1]
groups = ["a", "a", "a", "b", "b", "b"]
print(accuracy_by_group(y_true, y_pred, groups))
# {'a': 1.0, 'b': 0.3333333333333333}This is the central reason the model card format exists. A card should report results per group or condition wherever the model will meet different populations. A later chapter covers how to choose those groups and how to handle small samples.
Limitations that are only boilerplate
"The model may make mistakes" is true of every model and helps no one. A limitation should be specific and testable, such as "Accuracy drops on tickets shorter than 5 words." If you have not measured a limitation, say so plainly and mark it as unverified, not leaving it out.
Missing out-of-scope use
Teams often write what the model is for and skip what it is not for. The out-of-scope statement is the part a reviewer uses to refuse a risky reuse, so it is worth stating even when it seems obvious to the authors.
A stale card
A card that describes version 1.0 while version 1.2 is deployed is worse than no card, because it gives false confidence. Treat the card as part of the release artifact, versioned with the model.
Where cards live
Cards are usually stored next to the model, as a Markdown file in the same repository or model registry entry. On the Hugging Face Hub, the card is the README.md of the model repository. Its YAML front matter, the block between the --- lines, holds machine-readable fields, and the rest is prose.
---
license: apache-2.0
language:
- en
library_name: transformers
pipeline_tag: text-classification
tags:
- support-tickets
datasets:
- my-org/support-tickets
metrics:
- accuracy
- f1
base_model: distilbert-base-uncased
---
# support-ticket-classifier
## Intended use
Routes English-language support tickets to one of five queues.
## Limitations
Not evaluated on non-English text.The front matter lets tools filter and search by license, language, dataset, and metric without parsing prose. The prose below it carries the nuance that fields cannot, such as why a limitation exists. A good card uses both.
What a card cannot do
A card does not make a model safe. It makes the model's known properties visible, so that people can make informed choices. Three limits are worth remembering:
- A card reports only what its authors measured. If a failure mode was never tested, the card is silent about it, and silence is not evidence of safety.
- A card is a claim, not a proof. Readers may need to reproduce the evaluation, especially for high-stakes use.
- A card covers one model. Behavior of a full product, which may chain several models with rules and human review, needs system-level documentation. A later chapter compares model cards with datasheets and system documentation.
Checking that required sections exist
Teams that rely on cards often enforce a minimum structure automatically. This short check fails a CI job when a card lacks required headings. It is only a presence check. It cannot tell whether the content under a heading is any good, so human review still matters.
import re
REQUIRED = ["Intended use", "Training data", "Evaluation", "Limitations"]
def missing_sections(markdown: str) -> list:
headings = {
match.group(1).strip().lower()
for match in re.finditer(r"^#{1,6}\s+(.+)$", markdown, re.MULTILINE)
}
return [
section
for section in REQUIRED
if not any(section.lower() in heading for heading in headings)
]
with open("README.md", encoding="utf-8") as f:
missing = missing_sections(f.read())
if missing:
raise SystemExit(f"Model card is missing sections: {missing}")The check lowercases each heading and tests whether each required name appears inside one. That makes it tolerant of headings like "Intended use and users", but it also means a heading with the right words and an empty body passes.
Summary of the working model
- A model card is a structured, versioned document that accompanies a model and answers a fixed set of questions for outside readers.
- It originated in the 2019 paper "Model Cards for Model Reporting" and borrows from hardware data sheets and datasheets for datasets.
- Its value comes from specifics: a precise intended use, a stated out-of-scope use, per-group results, and testable limitations.
- It is a claim limited by what was measured, and it must be kept in step with the model it describes.
Exercise
A card for a face-detection model reports "accuracy: 0.95" and lists the limitation "The model may sometimes be wrong." Name two specific problems with this card and say what you would add to fix each.
Show answer
First, the single aggregate accuracy hides differences between groups and conditions. Add results disaggregated by relevant factors, such as skin tone, age range, lighting, and image quality, so a reader can see where accuracy falls. Second, the limitation is boilerplate that is true of every model and cannot be acted on. Replace it with specific, testable statements, for example a named drop in accuracy under low light or for small faces, and mark any limitation you have not measured as unverified. Adding an out-of-scope statement, such as a ban on identifying individuals, would also help.
Exercise
The structure check above passes for a card that has a heading "## Limitations" followed by no text. Why does it pass, and how would you reduce the chance of this slipping through?
Show answer
The check only looks for required words inside heading lines and never reads the body under a heading, so an empty section still counts as present. To reduce the risk, extend the check to require some minimum non-empty text under each required heading, and keep a human review step in the release process to judge whether the content is specific and accurate.