Sub topic 1
Why Models Need Documentation
This chapter explains why machine learning models need written documentation and introduces the model card, the standard document for recording a model's purpose, origin, and limits. It covers model details, licensing, contacts, and the intended and out-of-scope use of a model.
Prerequisites
You should understand supervised machine learning, including training and test sets. You should also be comfortable reading short Python snippets and know what a software license is.
Why undocumented models cause problems
A trained model is a file of numbers. The file does not say what data produced it, what it was tested on, or what it should never be used for. Without that information, a team that reuses the model can deploy it for the wrong task and get confident but wrong predictions.
Documentation solves three problems:
- Reuse: Others can decide whether the model fits their task.
- Auditing: Reviewers can trace which version was approved and why.
- Safe deployment: Operators know the conditions under which the model was checked.
What a model card is
A model card is a short document, usually written in Markdown, that accompanies a trained model. The idea comes from the 2019 paper "Model Cards for Model Reporting" by Mitchell and colleagues. The paper proposed a standard set of sections so that every model reports the same core facts in the same place.
Model details
The model details section records the basic facts needed to identify a model:
- Name and version: A unique name and a version number, such as
1.2.0. - Model type: The architecture or method, such as a fine-tuned transformer classifier.
- License: The terms under which others may use the model.
- Contact: A team or person responsible for questions and fixes.
from dataclasses import dataclass
@dataclass
class ModelDetails:
name: str
version: str
model_type: str
license: str
contact: str
details = ModelDetails(
name="support-ticket-classifier",
version="1.2.0",
model_type="DistilBERT text classifier",
license="Apache-2.0",
contact="[email protected]",
)
print(f"{details.name} v{details.version}")
print(f"Type: {details.model_type}")Intended use, users, and out-of-scope use
The intended use section names the task, the users, and the input the model expects. Be specific. "Routes English support tickets to one of five queues" is actionable. "Helps customers" is not.
The out-of-scope section names uses the model was not built or tested for. Name them explicitly, because readers rarely guess the limits on their own.
Exercise
Exercise
A team's model card says "Intended use: classify text." Why is this statement hard to act on, and how would you fix it?
Show answer
It does not name the input, the task outputs, or the users, so a reader cannot tell whether the model fits their case. Fix it by stating the language, the input type, the number of output classes, and the intended users, for example "Routes English-language support tickets to one of five queues for the support operations team."