Sub topic 1
Why Models Need Documentation
A machine learning model is more than a file containing learned parameters. It also has assumptions, data dependencies, performance limits, and rules for use. Without that context, another person may reuse the model in a setting where it was never tested.
Model documentation records this context in a form that people can read and review. A model card is a structured document that describes a model’s purpose, data, evaluation, limitations, and responsible uses. Documentation does not make a model safe by itself, but it makes important decisions visible.
Prerequisites
This chapter assumes that you understand the difference between training, validation, and test data. You should also know common metrics such as accuracy, precision, and recall. Basic Python, Markdown, and Git will help you follow the examples in later chapters.
What goes wrong without documentation
Consider a text classifier that routes customer support messages to five queues. Its overall test accuracy is 91%. Someone finds the model in a repository and deploys it for all incoming messages.
That person still needs answers to basic questions:
- What kinds of messages was the model trained on?
- Does it support only English?
- Which five queues can it predict?
- Was the test set representative of current traffic?
- How does it perform on short messages or messages containing spelling errors?
- Is it suitable for legal, medical, or safety-related requests?
- Which version of the model produced the reported score?
- Who should be contacted when the model behaves incorrectly?
An accuracy value cannot answer these questions. If the model performs well on common tickets but poorly on messages from a particular language group, the average can hide a serious deployment problem. If the training data contains old product names, the model may degrade after a product change.
Documentation reduces these unknowns before they become incidents.
Documentation supports reuse
A model is reusable only when a new user can understand its interface and operating conditions. The interface includes more than input and output types. It includes expected language, input length, label meanings, preprocessing steps, and confidence behavior.
A useful document lets a downstream user decide whether the model fits a proposed task. It should make unsuitable uses easy to reject rather than forcing every user to rediscover the original team’s assumptions.
| Without documentation | With documentation |
|---|---|
| A user guesses what the labels mean | The labels and intended task are defined |
| A score is treated as universal | The evaluation data and conditions are stated |
| A model is reused for a new population | Known gaps and tested groups are visible |
| A defect has no clear owner | A contact and model version are recorded |
Documentation supports auditing
An audit asks whether a system was developed and used according to stated requirements. Auditors need evidence about the model’s origin, data, evaluation process, and approvals.
A model card creates a stable reference for that evidence. It can record:
- The model name and version.
- The model type and base model, if any.
- The training data and important preprocessing steps.
- The test data and evaluation date.
- Metrics, including the conditions under which they were measured.
- Known limitations and prohibited uses.
- Reviewers, owners, and links to related records.
Versioning matters. If version 1.1 was evaluated on one test set and version 1.2 was retrained on new data, their cards should not silently share results. A reviewer must be able to connect each claim to the model version that produced it.
Documentation supports safer deployment
A deployment decision is a comparison between a model’s capabilities and the consequences of failure. Documentation helps a team make that comparison explicitly.
For example, a model that suggests a support queue may be acceptable when a human reviews every suggestion. The same model may be inappropriate for automatically denying a customer request. The prediction task is similar, but the impact of an error is different.
A model card should therefore distinguish intended use from out-of-scope use. It should also state whether the model is a recommendation tool, an automated decision-maker, or one component in a larger workflow.
A documentation workflow
Documentation works best when it is created during development rather than reconstructed after release.
Start by writing down the task and intended users. Add data and evaluation details as they become available. Before release, review the card with people who understand the model, its users, and the consequences of mistakes. After release, update it when the model, data, task, or operating environment changes.
A model card cannot replace dataset documentation, system design records, incident reports, or human review procedures. It connects model-specific facts to those other records so that a reader can understand the model in context.
Exercise
A classifier has 95% accuracy on a test set, but the test set contains only the same type of short English messages used during training. What should a model card communicate before deployment to a multilingual, customer-facing workflow?
Show answer
It should state the test set’s language and message-length conditions, explain that the reported accuracy may not transfer to multilingual or different-length inputs, identify the missing evaluation, and define whether multilingual automatic routing is out of scope until it is tested.