Practical Interpretability
Documentation
Read aloud is unavailable in this browser.
The Foundation of Sustainable Interpretability
Interpretability methods can extract insights from models, visualizations can communicate patterns, and explanations can satisfy stakeholder questions. But without comprehensive documentation, all these capabilities degrade over time. Team members leave. Contexts change. Memory fades. What seemed obvious during development becomes mysterious six months later.
Documentation is the institutional memory of machine learning. It transforms individual knowledge into organizational capability, ensures continuity across team transitions, enables audit and accountability, and provides the foundation for continuous improvement. Without documentation, every team confronting an ML system must rediscover what previous teams learned—often after problems have occurred.
This page examines documentation as a comprehensive practice: what to document, when to document it, how to maintain living documentation, and how to build organizational systems that make documentation sustainable rather than burdensome.
By the end of this page, you will understand comprehensive ML documentation architecture, lifecycle-appropriate documentation practices, documentation governance and maintenance strategies, and practical approaches to making documentation sustainable and valuable.
The Documentation Architecture
Effective ML documentation isn't a single document—it's an architecture of interconnected artifacts serving different purposes and audiences. Understanding this architecture enables strategic documentation that maximizes value while minimizing redundancy.
The Documentation Pyramid:
| Layer | Purpose | Audience | Update Frequency |
|---|---|---|---|
| Summary Layer | Quick understanding, decision support | Executives, auditors, product teams | Major changes only |
| Operational Layer | Day-to-day use, monitoring, incidents | ML ops, on-call engineers, support | With operational changes |
| Technical Layer | Deep understanding, debugging, improvement | ML engineers, reviewers, researchers | With model changes |
| Provenance Layer | Audit trail, compliance, investigation | Auditors, legal, compliance | Immutable, append-only |
| Research Layer | Exploration, experimentation, learning | R&D, advanced ML practitioners | Continuous experimentation |
Key Artifact Types:
- •Model Card: Standardized summary (covered previously)—serves the summary layer
- •Technical Specification: Comprehensive architecture, algorithms, parameters, feature definitions—serves the technical layer
- •Data Documentation: Sources, schemas, preprocessing, quality, lineage—bridges technical and provenance layers
- •Validation Report: Evaluation methodology, results, subgroup analysis, calibration—serves technical and summary layers
- •Operational Runbook: Deployment, monitoring, alerting, incident response, retraining procedures—serves operational layer
- •Decision Log: Key choices, rationale, alternatives considered, risk acceptance—serves provenance layer
- •Experiment Records: Hypotheses tested, results, learnings—serves research layer
- •Change Log: Version history, what changed, why, testing performed—bridges all layers
The Cross-Reference Principle:
Documents should reference each other rather than duplicate content:
Model Card
├── References Technical Specification for architecture details
├── References Validation Report for complete metrics
├── References Data Documentation for training data details
└── Links to Operational Runbook for deployment information
Technical Specification
├── References Data Documentation for feature sources
├── References Experiment Records for design choices
└── Links to Change Log for version history
Operational Runbook
├── References Model Card for model behavior summary
├── References Technical Specification for troubleshooting
└── Links to Decision Log for operational decisions
This reduces duplication, ensures consistency, and allows appropriate detail at each level.
Every fact should live in exactly one document. Other documents reference it. Duplication creates inconsistency—when updates happen, some copies get missed. Reference liberally; duplicate never.
What to Document
Comprehensive ML documentation requires capturing information across multiple dimensions. Here's a systematic breakdown of documentation content.
Intent and Context Documentation:
Document the why before the what:
Problem Definition
- What business/user problem does this model address?
- What decisions will the model inform or automate?
- Who are the affected stakeholders?
- What are the consequences of model errors (false positives, false negatives)?
- What alternatives were considered (non-ML solutions, different ML approaches)?
Success Criteria
- How will success be measured?
- What metrics indicate adequate performance?
- What thresholds trigger concern or action?
- How does model success connect to business outcomes?
Constraints
- What constraints shape the solution? (latency, compute, interpretability, regulatory)
- What tradeoffs were made and why?
- What compromises exist between ideal and implemented?
Scope
- What is in scope for this model?
- What is explicitly out of scope?
- What populations, use cases, or scenarios are not covered?
Historical Context
- What preceded this model? (earlier versions, different approaches)
- What problems with the previous approach motivated this one?
- What was learned from prior attempts?
Lifecycle Documentation
Different ML lifecycle phases have different documentation needs. Matching documentation activities to lifecycle phases ensures coverage without overwhelming teams.
Documentation by Lifecycle Phase:
| Phase | Primary Documentation | Documentation Focus |
|---|---|---|
| Problem Scoping | Problem definition, success criteria, constraints | Why are we building this? What does success look like? |
| Data Collection | Data sources, collection methods, consent | What data do we have? How was it obtained? |
| Data Preparation | Preprocessing pipeline, feature engineering | How is raw data transformed to model inputs? |
| Exploration | Experiment records, EDA findings | What did we learn about the data and problem? |
| Model Development | Architecture decisions, training procedures | What approach are we taking and why? |
| Validation | Evaluation methodology, results, subgroup analysis | How well does this work? For whom? |
| Pre-Deployment | Model Card, operational runbook, risk assessment | Is this ready for production? What's the plan? |
| Deployment | Deployment records, configuration, monitoring setup | How was this deployed? What's being monitored? |
| Production | Monitoring logs, incident records, performance trends | How is it working? What problems have occurred? |
| Maintenance | Retraining records, version history, improvement log | How has this evolved? What's been learned? |
| Retirement | Retirement rationale, migration plan, archived records | Why is this ending? What happens to dependencies? |
The Documentation-as-You-Go Principle:
Documentation created later is fundamentally inferior to documentation created during the work:
| Created During | Created After |
|---|---|
| Captures actual reasoning | Reconstructs reasoning (often incorrectly) |
| Includes abandoned paths | Only shows what was chosen |
| Reflects uncertainty and debates | Presents artificial certainty |
| Contemporary evidence | Appears reconstructed for convenience |
| Details remembered | Details forgotten |
Making Documentation Sustainable:
Documentation often fails because it's treated as overhead rather than integral work. Strategies for sustainability:
-
Template-Based: Pre-defined templates reduce the cognitive load of deciding what to document
-
Pipeline-Integrated: Automated capture of metrics, parameters, and lineage as side effects of running code
-
Review-Enforced: Documentation completeness as a criterion for phase gates and deployments
-
Tooling-Supported: Dedicated tools for documentation rather than generic wikis
When documentation is created pre-audit or pre-deployment as a formality, it's reconstruction, not documentation. Reconstructed documentation misses nuance, omits problems, and reflects desired narratives rather than reality. Auditors and investigators can often tell the difference.
Technical Specification Deep Dive
The Technical Specification is the authoritative detailed document for model architecture, training, and behavior. It serves ML engineers who need to understand, debug, or improve the system.
Technical Specification Structure:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
# Technical Specification: [Model Name] v[X.Y.Z] ## 1. Executive Summary- **Purpose:** One-paragraph description of what this model does- **Key Metrics:** Primary performance metrics with values- **Critical Limitations:** Top 3 limitations to keep in mind- **Detailed Model Card:** [Link] ## 2. Architecture ### 2.1 Model Type and Structure- Algorithm family and specific implementation- Architecture diagram (if complex)- Number of parameters/complexity measures ### 2.2 Hyperparameters| Parameter | Value | Rationale ||-----------|-------|-----------|| [name] | [value] | [why this value] | ### 2.3 Dependencies- Software dependencies with versions- External model dependencies- Data dependencies ## 3. Features ### 3.1 Feature Inventory| Feature Name | Type | Source | Description | Importance ||--------------|------|--------|-------------|------------|| [name] | [numeric/categorical/...] | [source system] | [what it means] | [rank/score] | ### 3.2 Feature Engineering Pipeline- Diagram of preprocessing flow- Transformation specifications- Handling of missing values- Encoding methods for categorical features ### 3.3 Feature Interactions- Known important interactions- Interaction constraints (if any) ## 4. Training ### 4.1 Training Data- **Source:** [Data source reference]- **Time Period:** [Date range]- **Volume:** [Number of samples]- **Class Distribution:** [For classification]- **Data Specification:** [Link to Data Documentation] ### 4.2 Training Procedure- Objective function/loss- Optimization algorithm- Learning rate schedule- Regularization- Early stopping criteria- Cross-validation strategy ### 4.3 Training Infrastructure- Hardware used- Training duration- Memory requirements ### 4.4 Reproducibility- Random seeds- Environment specification (requirements.txt, Docker image)- Training script location ## 5. Evaluation ### 5.1 Evaluation Data- Source and construction- Time period and volume- Relationship to training data (leakage prevention) ### 5.2 Metrics| Metric | Value | 95% CI | Note ||--------|-------|--------|------|| [name] | [value] | [interval] | [context] | ### 5.3 Disaggregated Performance- Performance by [factor 1]- Performance by [factor 2]- Intersectional analysis ### 5.4 Calibration- Calibration method (if applied)- Reliability diagram- Calibration metrics ### 5.5 Error Analysis- Common error patterns- Edge case behavior- Confidence vs accuracy relationship ## 6. Inference ### 6.1 Input Specification- Expected input format- Required preprocessing- Input validation ### 6.2 Output Specification- Output format and interpretation- Probability calibration note- Decision threshold (if applicable) ### 6.3 Performance Characteristics- Latency (p50, p95, p99)- Memory footprint- Throughput capacity ## 7. Limitations ### 7.1 Known Failure Modes| Scenario | Behavior | Mitigation ||----------|----------|------------|| [case] | [what happens] | [what to do] | ### 7.2 Out-of-Distribution Behavior- How model behaves on novel inputs- Distribution shift sensitivity ### 7.3 Uncertainty Quantification- Confidence score interpretation- When confidence is unreliable ## 8. Version History | Version | Date | Changes | Author ||---------|------|---------|--------|| [X.Y.Z] | [date] | [what changed] | [who] | ## 9. References - Related documents: [links]- Research papers: [citations]- Code repositories: [links] ## 10. Appendices ### A. Detailed Feature Definitions[Complete feature dictionary] ### B. Training Configuration[Exact configuration files used] ### C. Evaluation Methodology Details[Complete evaluation protocol]Technical specifications should be version-controlled alongside the code. Every model version should have a corresponding specification version. Changes to the model should trigger specification updates. Outdated specifications are worse than no specifications—they actively mislead.
Operational Runbooks
Operational runbooks enable anyone—including on-call engineers who didn't build the model—to operate, monitor, troubleshoot, and maintain ML systems. They're written for someone at 3 AM who needs to determine if a problem is real and what to do about it.
Runbook Design Principles:
- •Action-Oriented: Each section should answer 'what do I do?' not just 'what is this?'
- •Decision Trees: For troubleshooting, provide clear if-then logic: 'If X, then Y'
- •Copy-Paste Ready: Commands should be directly usable, not requiring interpretation
- •Escalation Clear: When and to whom to escalate is unambiguous
- •Tested: Procedures should be periodically tested to ensure they work
- •Updated After Incidents: Post-incident reviews should update runbooks with new knowledge
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
# Operational Runbook: [Model Name] ## Quick Reference | Item | Value ||------|-------|| **Model** | [Name and version] || **Service** | [Service name/URL] || **Dashboard** | [Monitoring dashboard link] || **Logs** | [Log query/location] || **On-Call** | [Team/rotation] || **Escalation** | [Escalation path] || **Last Updated** | [Date] | --- ## 1. Service Overview **What This Does:**[One paragraph description of what the model/service does] **Business Impact:**[What happens to users/business if this fails?] **Health Check:**```bash# Quick health check commandcurl -s https://service/health | jq .``` --- ## 2. Monitoring & Alerts ### 2.1 Key Metrics | Metric | Normal Range | Warning | Critical | Dashboard ||--------|--------------|---------|----------|-----------|| Prediction latency (p95) | < 100ms | > 200ms | > 500ms | [link] || Prediction volume | 1K-10K/min | < 500/min | < 100/min | [link] || Error rate | < 0.1% | > 1% | > 5% | [link] || Model confidence (mean) | 0.6-0.9 | < 0.5 | < 0.3 | [link] || Prediction distribution | [baseline] | drift > 0.1 | drift > 0.2 | [link] | ### 2.2 Active Alerts | Alert | Severity | Meaning | Action ||-------|----------|---------|--------|| HighLatencyAlert | Warning | p95 latency elevated | See §3.1 || LowVolumeAlert | Warning | Prediction volume dropped | See §3.2 || HighErrorRate | Critical | Error rate elevated | See §3.3 || ModelDrift | Warning | Prediction distribution shifted | See §3.4 | --- ## 3. Troubleshooting ### 3.1 High Latency **Symptoms:** HighLatencyAlert firing, slow response times **Diagnosis:**1. Check CPU/memory utilization: [dashboard link]2. Check request queue depth: [metric]3. Check upstream dependency latency: [dashboard link]4. Check for unusual request patterns (size, frequency) **If Cause is...** | Cause | Action ||-------|--------|| High CPU/memory | Scale up replicas: [procedure link] || Dependency slow | Check dependency status; escalate to [team] || Traffic spike | Verify legitimate; consider rate limiting || Memory leak | Restart pods: `kubectl rollout restart...` | ### 3.2 Low Volume **Symptoms:** LowVolumeAlert firing, prediction volume below threshold **Diagnosis:**1. Is upstream service sending traffic? [check]2. Are health checks passing? [check]3. Is there a deployment in progress? [check]4. Is there a broader outage? [check] **Most Common Causes:**1. Upstream service outage2. Network/routing issue3. Deployment misconfiguration [...] ### 3.3 High Error Rate ### 3.4 Model Drift --- ## 4. Common Operations ### 4.1 Rollback to Previous Version **When to Use:** Critical issue with current version; need immediate revert **Procedure:**```bash# 1. Identify last known good versionkubectl get replicasets -n ml-models | grep model-name # 2. Rollbackkubectl rollout undo deployment/model-name -n ml-models # 3. Verify rollbackkubectl get pods -n ml-models | grep model-name # 4. Confirm healthcurl -s https://service/health | jq .``` **Post-Rollback:**- Create incident ticket- Notify [stakeholders]- Schedule root cause analysis ### 4.2 Scale Replicas ### 4.3 Manual Retraining ### 4.4 Feature Store Refresh --- ## 5. Incident Response ### 5.1 Severity Definitions | Severity | Definition | Response Time | Examples ||----------|------------|---------------|----------|| SEV1 | Complete outage | Immediate | Service down; all predictions failing || SEV2 | Major degradation | 15 min | 50%+ requests failing; severe latency || SEV3 | Minor degradation | 1 hour | Elevated errors; some latency || SEV4 | Inconvenience | 24 hours | Minor issues; no user impact | ### 5.2 Escalation Matrix | Issue Type | First Contact | Escalation 1 | Escalation 2 ||------------|---------------|--------------|--------------|| Service outage | On-call ML Eng | ML Team Lead | VP Engineering || Data issues | Data Platform | Data Eng Lead | - || Model accuracy | ML Team | Product Owner | - | ### 5.3 Communication Templates **Incident Start:**> [INCIDENT] [Model Name] - [Brief description]. > Severity: [SEV#]. Impact: [user impact].> Investigating. Updates every [X] minutes. **Incident Resolution:**> [RESOLVED] [Model Name] - [What was wrong]. > Root cause: [brief]. Duration: [X minutes/hours].> Post-mortem scheduled: [date]. --- ## 6. Maintenance Procedures ### 6.1 Scheduled Retraining- **Schedule:** [Weekly/Monthly/etc]- **Procedure:** [Link to retraining SOP]- **Validation Required:** [What checks before deploy?]- **Rollback Criteria:** [When to abort?] ### 6.2 Model Validation- **Frequency:** [Schedule]- **Metrics Checked:** [List]- **Thresholds:** [Values]- **Actions if Failed:** [Procedure] --- ## 7. Contacts | Role | Name | Contact ||------|------|---------|| Primary On-Call | [Rotation] | [PagerDuty/Slack] || ML Team Lead | [Name] | [email/phone] || Data Platform | [Name] | [email/slack] || Product Owner | [Name] | [email/slack] | --- ## Change Log | Date | Author | Change ||------|--------|--------|| [date] | [name] | [what changed] |Decision Logs and Governance
Decision logs capture the reasoning behind key choices—creating institutional memory that survives team transitions and enables learning from past decisions. Combined with governance structures, they ensure accountability and consistency.
Why Decision Documentation Matters:
- •New team members understand why things are the way they are
- •Similar decisions benefit from past reasoning
- •Mistakes aren't repeated—lessons are captured
- •Auditors understand decision-making process
- •Accountability is clear and traceable
- •"Why did we do this?" is unanswerable
- •Each team rediscovers the same constraints
- •Mistakes are repeated across projects
- •Auditors question the decision process
- •No one knows who decided what or when
Architecture Decision Records (ADRs) for ML:
Borrowing from software engineering, Architecture Decision Records can be adapted for ML:
# ADR-042: Selection of XGBoost over Neural Network for Credit Scoring
## Status
Accepted
## Date
2024-01-10
## Context
We need to select a model architecture for the updated credit scoring model.
Constraints include:
- Regulatory requirement for explainability (SR 11-7 compliance)
- Latency requirement < 50ms for real-time scoring
- Accuracy competitive with current model (AUC > 0.82)
- Team capacity to maintain and monitor
## Decision
We will use XGBoost gradient boosted trees rather than neural networks.
## Alternatives Considered
1. **Neural Network (MLP):** Rejected - insufficient interpretability for regulatory
requirements; would require post-hoc explanation methods that are contested.
2. **Logistic Regression:** Rejected - did not meet accuracy threshold in experiments
(AUC 0.79 vs 0.85 for XGBoost).
3. **Random Forest:** Considered acceptable, but XGBoost showed better performance
and has mature SHAP support.
## Consequences
Positive:
- Native feature importance and SHAP explanations
- Met latency requirements (p95 < 20ms)
- Exceeded accuracy threshold (AUC 0.85)
Negative:
- May not capture complex nonlinear patterns as well as neural network
- Hyperparameter tuning more sensitive
## Related Decisions
- ADR-039: Regulatory compliance framework
- ADR-041: Interpretability tooling selection (SHAP)
## Authors
[Names], [Role]
Governance Structures:
Documentation requires governance—roles, responsibilities, and processes that ensure documentation happens and stays current:
| Role | Responsibility |
|---|---|
| Model Owner | Accountable for model documentation completeness and accuracy |
| Documentation Lead | Sets standards, reviews quality, maintains templates |
| Technical Reviewer | Validates technical accuracy of documentation |
| Process Auditor | Periodically verifies documentation compliance |
| Executive Sponsor | Provides authority and resources for documentation program |
Governance Mechanisms:
- Deployment Gates: No production deployment without documentation checkpoints
- Periodic Audits: Random sample of models checked for documentation quality
- Staleness Alerts: Automated detection of outdated documentation
- Ownership Registry: Every model has assigned accountable owner
- Template Enforcement: Tooling that enforces required documentation sections
Governance should enable, not impede. Heavy processes create workarounds. Aim for lightweight mechanisms that are easy to follow and hard to skip—automation helps more than bureaucracy.
Documentation Tooling
Appropriate tooling makes documentation sustainable. Poor tooling makes it burdensome. Here's a landscape of tools that support ML documentation.
| Category | Examples | Use Case |
|---|---|---|
| Experiment Tracking | MLflow, Weights & Biases, Neptune, ClearML | Automatic capture of training runs, parameters, metrics |
| Model Registry | MLflow Registry, SageMaker Model Registry, Vertex AI | Model versioning with attached metadata and documentation |
| Data Catalogs | Apache Atlas, DataHub, Alation, AWS Glue Catalog | Data discovery, lineage, quality documentation |
| Model Cards | Model Card Toolkit, Hugging Face Model Cards | Standardized model documentation generation |
| Documentation Platforms | Confluence, Notion, GitBook, ReadTheDocs | General documentation hosting with collaboration |
| Version Control | Git + Markdown, GitHub/GitLab Wikis | Version-controlled documentation alongside code |
| Feature Stores | Feast, Tecton, Hopsworks | Feature documentation with lineage and statistics |
| Pipeline Tools | Kubeflow, Airflow, Prefect | Pipeline documentation and execution logs |
Integration Strategies:
1. Docs-as-Code
Treat documentation like code:
- Documentation in Git alongside model code
- Same PR/review process for doc changes
- CI checks for documentation completeness
- Automated publishing on merge
Benefits: Version control, review process, lives with code Drawbacks: Requires engineer-friendly tooling; less accessible to non-engineers
2. Centralized Platform
Use a dedicated documentation platform:
- Confluence, Notion, or similar wiki
- All ML documentation in one searchable location
- Rich formatting, embedding, linking
Benefits: Accessible to all; rich editing Drawbacks: Can drift from code; versioning harder
3. Registry-Centric
Model registry as documentation hub:
- Model versioning inherently tracks documentation
- Metadata attached to model artifacts
- Single source of truth for deployed models
Benefits: Documentation tied to artifacts; clear versioning Drawbacks: May not support all documentation types
4. Automated Capture
Maximize automated documentation:
- Experiment tracking captures parameters and metrics automatically
- Pipeline systems log execution details
- Data catalogs capture schema and statistics automatically
Benefits: Low manual effort; contemporaneous Drawbacks: Doesn't capture intent, decisions, or context
Most mature organizations use a hybrid: automated capture for what can be automated, structured templates for what needs human input, and integration points that link different systems. The goal is documentation that's easy to create, easy to find, and easy to trust.
KEEP LEARNING
Keep learning for free.
Read the complete lesson, save your notes and pick up where you left off with a free account. No card needed.