AI & Machine Learning Master Course — 178. Model cards and dataset documentation
Smartyfy AI & Machine Learning Master Course
Course ID: smartyfy-ai-ml-master-200
Lesson 178: Model cards and dataset documentation
Prerequisites: Lesson 177. Learning outcome: Write evidence-backed documentation of intended use, limitations, and provenance.
Documentation should support a decision
A model card is useful when another person can determine whether a model is appropriate for a specific purpose and trace its claims to evidence. A dataset document explains where data came from, what it represents, how it was processed, and which uses are permitted or unsupported. Neither document should be a collection of reassuring adjectives.
Separate the artifact from its narrative. Identify the exact model version, data snapshot, preprocessing, threshold policy, and evaluation report. A claim about version one does not automatically describe version two. If an evaluation report is unavailable, record the gap explicitly instead of supplying a plausible number.
Documentation is a living interface between developers, reviewers, operators, and affected people. Different audiences need different detail, but their summaries should refer to the same underlying evidence. A public summary may omit restricted data while still stating material limitations.
Describe the dataset before describing its score
Record the unit of observation, sampling process, collection period, source, inclusion and exclusion rules, and label definition. Explain whether a row represents an event, a person, a device, or a repeated measurement. Document known duplicates, missingness, historical changes, and relationships that affect train–test separation.
Provenance and permitted use are separate questions. Knowing a file's source does not establish permission to process it for any purpose. Record the basis for use, retention expectations, access restrictions, and unresolved questions using the appropriate organizational review process. Do not copy sensitive examples into documentation merely to make it concrete.
Explain annotation procedures and disagreements. A label produced after an outcome may be unavailable at prediction time. A label reflecting prior human decisions may encode their policies rather than an underlying objective truth. These distinctions affect what the model can reasonably be said to predict.
Make the model card operational
Start with intended use and explicit excluded uses. Include input and output meanings, required preprocessing, supported conditions, known failures, and the person or role responsible for maintenance. Distinguish predicted probability from a calibrated probability and distinguish a recommendation from an authorized action.
For evaluation, state data partitions, dates, selection rules, metrics, denominators, uncertainty methods, and relevant slices. Provide baseline comparisons and explain any threshold selection. A statement such as ninety percent accuracy is incomplete without the task, class balance, sampling process, and operating threshold.
Describe how to report incidents, obtain a review, and identify a retired version. Document unresolved limitations rather than pretending the card certifies compliance or safety. The model-card and datasheet papers propose useful reporting structures; filling those structures is not independent verification of their contents.
A small evidence map
| Claim | Evidence | Important limit |
|---|---|---|
| Evaluation error | Versioned predictions and labels | Applies to the stated sample |
| Permitted use | Applicable review record | Provenance alone is insufficient |
| Supported input | Schema and domain tests | Valid format does not prove familiarity |
CPU lab: detect missing fields without certifying truth
Save the complete standard-library program as example178.py. It defines a fictional card, a minimal structural checker, and a broken copy. The intact fixture has no detected issues. The broken copy lacks limitations and has a zero evaluation denominator, so both problems are reported. Its stated fixture error rate is 1/4 = 0.25.
This code does not read an evaluation report or verify that its identifier exists. It does not authenticate the owner, audit permissions, or establish that a stated limitation is complete. The word valid in the printed fixture label means passing this small checker only. Structural validation is a useful early gate, not a replacement for substantive review.
A production schema would validate types, nonempty text, allowed values, version formats, and nested records more thoroughly. The example deliberately implements only the checks shown, so a reader can see exactly what remains unchecked. Changing a card's number does not rerun the experiment that supposedly supports it.
from copy import deepcopy
card = {
'model_id': 'fixture-v1', 'dataset_id': 'synthetic-v1',
'intended_use': 'Offline teaching only',
'excluded_use': 'Operational decisions',
'split': 'Predeclared fixture, no fitted model',
'owner': 'Course exercise role', 'limitations': 'Four invented cases',
'evaluation': {'n': 4, 'errors': 1, 'report_id': 'fixture-report-v1'}
}
required = {'model_id', 'dataset_id', 'intended_use', 'excluded_use',
'split', 'owner', 'limitations', 'evaluation'}
def issues(document):
out = sorted(required - document.keys())
e = document.get('evaluation', {})
if not isinstance(e.get('n'), int) or e.get('n', 0) <= 0:
out.append('positive evaluation denominator')
elif not isinstance(e.get('errors'), int) or not 0 <= e['errors'] <= e['n']:
out.append('valid error count')
if not e.get('report_id'):
out.append('evaluation report reference')
return out
broken = deepcopy(card)
del broken['limitations']
broken['evaluation']['n'] = 0
assert issues(card) == []
assert issues(broken) == ['limitations', 'positive evaluation denominator']
print('valid fixture issues', issues(card))
print('broken fixture issues', issues(broken))
print('fixture error rate', card['evaluation']['errors'] / card['evaluation']['n'])
Review and maintain the evidence
Review the document against the actual artifact. Recompute a reported metric from saved predictions, check that the input schema matches serving behavior, and verify that the evaluation used the recorded version. Ask someone unfamiliar with the project to identify an unsupported use from the documentation alone.
Track changes with a date, an owner, and a reason. New data, thresholds, dependencies, or operating regions may invalidate prior evidence. Retain historical cards for traceability while making the active version unambiguous. When an incident reveals a new limitation, update the limitation and the operational response together.
A good handoff makes uncertainty visible. “Not evaluated on this device family” is more useful than an unsupported claim of generality. The document should help a downstream team decide to collect evidence, narrow the use, or decline deployment, rather than pressure them toward acceptance.
Four practice questions with worked answers
Practice 1
The card reports seven errors but gives no sample count. What is missing?
Answer: The denominator and sampling protocol are missing. Seven errors among ten cases differs greatly from seven among ten thousand. Request the evaluation report, partition, and metric definition before interpreting the result.
Practice 2
Why keep dataset and model identifiers separate?
Answer: Multiple models can use one dataset, and one model may combine several snapshots. Separate identifiers let a reviewer trace which data and transformations supported a particular artifact without conflating their versions.
Practice 3
The example returns an empty issue list. What has been verified?
Answer: Only the implemented field-presence and evaluation-count checks. The report reference, stated intended use, owner identity, and underlying experimental truth remain unverified by this program.
Practice 4
A threshold changes after the card was written. What should happen?
Answer: Version the decision policy, rerun affected evaluations, and update the card and report references. Threshold changes can alter precision, recall, workload, and subgroup behavior even when model weights remain identical.
Five multiple-choice questions
Question 1
Which is the strongest evaluation statement?
- A. A metric copied from a similar model without its version
- B. A claim of reliability based only on a completed card
- C. A metric tied to an artifact, sample, protocol, and report
Correct: C. Traceable evaluation requires both the measured quantity and the conditions under which it was measured.
Question 2
What is a dataset document especially suited to explain?
- A. Collection, composition, processing, labels, and permitted-use context
- B. Only the latest online prediction latency
- C. Only the final trained model weights
Correct: A. Dataset documentation focuses on the data lifecycle and its limitations, while other records describe model parameters and serving behavior.
Question 3
Why record excluded uses?
- A. To prove misuse is technically impossible
- B. To make unsupported contexts explicit for downstream decisions
- C. To replace input validation and access controls
Correct: B. Stated exclusions communicate boundaries but do not enforce them by themselves.
Question 4
What does a report identifier in this lab guarantee?
- A. That all metrics in the card were recomputed
- B. Only that a nonempty reference field was provided
- C. That the referenced report exists and was independently verified
Correct: B. The checker does not resolve references or inspect experimental evidence.
Question 5
How should a known evaluation gap be documented?
- A. Copy results from a nearby condition as if directly measured
- B. Omit the condition until a favorable result is available
- C. State the unsupported condition and needed evidence
Correct: C. Visible limitations support informed use; substitution or omission would obscure the evidence boundary.
Common pitfalls
Do not present a completed template as certification, conflate provenance with permission, hide missing denominators, or let a card drift away from its artifact and threshold versions.
Summary
Model and dataset documentation should connect intended use, provenance, evaluation, and limitations to inspectable evidence. Automated structure checks help catch omissions, while substantive review establishes what the statements actually support.