Model Explainability
Skill Profile
(Select at least one profile to enable specific modules)
- [ ] DevOps
- [x] Backend
- [ ] Frontend
- [ ] AI-RAG
- [ ] Security Critical
Overview
Model Explainability (XAI) is the set of processes and methods that allow human users to comprehend and trust the decisions made by machine learning algorithms. It bridges the gap between high-performing "Black Box" models and human need for transparency.
Core Principle: "Accuracy without explainability is a liability in high-stakes decisions."
This skill provides comprehensive guidance on implementing model explainability and interpretability across different model types.
Why This Matters
- <Benefit>: <short explanation>
- <Benefit>: <short explanation>
- <Benefit>: <short explanation>
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- <e.g., env vars, request payload, file paths, schema>
- Entry Conditions:
- <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>
- Outputs:
- <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>
- Artifacts Required (Deliverables):
- <e.g., Code Diff, Unit Tests, Migration Script, API Docs>
- Acceptance Evidence:
- <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>
- Success Criteria:
- <e.g., p95 < 300ms, coverage ≥ 80%>
Skill Composition
- Depends on: None
- Compatible with: None
- Conflicts with: None
- Related Skills: None
Quick Start
Assumptions
- Model is trained and available
- Feature importance can be computed
- Team has capacity to implement explainability
- Use cases are well-defined
Compatibility
- Works with all ML frameworks
- Compatible with different model types
- Framework-agnostic approach
- Adaptable to different use cases
Test Scenario Matrix
| Scenario | Test Case | Expected Outcome | |----------|-----------|------------------| | Feature importance | Top features identified | Correct ranking | | SHAP explanation | Local decision explained | Global behavior understood | | LIME explanation | Individual prediction explained | User satisfied | | Visualization | Chart generated | Clear insights |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
- [ ] Data Handling: Sanitize all user inputs to prevent Injection attacks. Never log raw PII
- [ ] Secrets Management: No hardcoded API keys. Use Env Vars/Secrets Manager
- [ ] Authorization: Validate user permissions before state changes
2. Performance & Resources
- [ ] Execution Efficiency: Consider time complexity for algorithms
- [ ] Memory Management: Use streams/pagination for large data
- [ ] Resource Cleanup: Close DB connections/file handlers in finally blocks
3. Architecture & Scalability
- [ ] Design Pattern: Follow SOLID principles, use Dependency Injection
- [ ] Modularity: Decouple logic from UI/Frameworks
4. Observability & Reliability
- [ ] Logging Standards: Structured JSON, include trace IDs
request_id - [ ] Metrics: Track
error_rate,latency,queue_depth - [ ] Error Handling: Standardized error codes, no bare except
- [ ] Observability Artifacts:
- Log Fields: timestamp, level, message, request_id
- Metrics: request_count, error_count, response_time
- Dashboards/Alerts: High Error Rate > 5%
Agent Directives
- Explain before deploy - Never deploy without explainability
- Provide context - Always explain with decision boundaries
- Use multiple methods - Different techniques for different use cases
- Measure effectiveness - Track user satisfaction
- Maintain calibration - Ensure confidence scores are meaningful
Definition of Done
Model explainability implementation is complete when:
- [ ] Explainability methods implemented
- [ ] Feature importance computed
- [ ] Visualization dashboard created
- [ ] User satisfaction tracked
- [ ] Calibration procedures in place
- [ ] Team trained on explainability tools
- [ ] Documentation complete and up-to-date
- [ ] Continuous improvement process established
Anti-patterns
- Deploying without explainability - Black box models in production
- Single explanation method - Using only one technique for all cases
- Ignoring calibration - Not adjusting confidence scores
- No user feedback - Not measuring explanation quality
- Over-engineering - Complex explainability for simple use cases
- Poor visualization - Charts that don't provide insights
Reference Links
Versioning
This skill follows semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Breaking changes to procedures or standards
- MINOR: New explainability methods or significant enhancements
- PATCH: Bug fixes or documentation updates
Scan to join WeChat group