[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JPMX26ES7Z5GJNT64AT8Y4":3,"skill-same:01M6JPMX26ES7Z5GJNT64AT8Y4":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":14,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M6JPMX26ES7Z5GJNT64AT8Y4","ml-model-deployment",null,"Deploy ML models to production — serving infrastructure, monitoring, drift detection, safe rollouts. Triggers: deploy model, serve model, model API, model monitoring, data drift, concept drift, model degradation, A\u002FB test model, canary model, inference endpoint, prediction API, retrain trigger.","SWEStash\u002Fswe-workflow-skills","SWEStash","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F272895713?v=4","01M6JNRQ84JN5WFK9S1V5H4G46","SWE Stash","01M6JNRQCM45X8WPNHY30TSAB0",1,"MIT","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fml\u002Fskills\u002Fml-model-deployment\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"ml model deployment","ml","model deployment","deployment","model","canary","drift detection","concept","trigger","triggers","drift","rollouts","api","safe","endpoint","data","monitoring","infrastructure","deploy model","test","2026-11-10 10:12:30",false,"---\nname: ml-model-deployment\ndescription: \"Deploy ML models to production — serving infrastructure, monitoring, drift detection, safe rollouts. Triggers: deploy model, serve model, model API, model monitoring, data drift, concept drift, model degradation, A\u002FB test model, canary model, inference endpoint, prediction API, retrain trigger.\"\n---\n\n# ML Model Deployment\n\nDeploy models to production with serving infrastructure that is reliable, observable, and safely updatable. Deploying a model is not the finish line — it's the beginning of the operational lifecycle.\n\n## Key Difference from Software Deployment\n\nSoftware deployment is primarily concerned with \"does the code work?\" Model deployment adds: \"does the model still work *well* on real-world data that changes over time?\" Models degrade silently — they keep returning predictions, just increasingly wrong ones.\n\n## Workflow\n\n### Step 1: Package the Model\n\nBefore deployment, the model must be a self-contained, versioned artifact:\n\n- **Serialize the model**: Use framework-native formats (joblib\u002Fpickle for sklearn, SavedModel for TF, TorchScript for PyTorch, ONNX for cross-framework)\n- **Pin dependencies**: Exact versions of libraries used during training\n- **Include preprocessing**: The serving pipeline must apply the same feature transformations as training. Feature skew (different preprocessing in training vs serving) is the #1 cause of silent model failure\n- **Version it**: Tag with model registry version, git commit, training data version, and training metrics\n\n### Step 2: Choose the Serving Pattern\n\n| Pattern | When to Use | Latency | Complexity |\n|---------|-------------|---------|------------|\n| **REST API** (Flask\u002FFastAPI + model) | Low traffic, simple models | Medium (50-200ms) | Low |\n| **Dedicated serving** (TF Serving, Triton, Seldon) | High traffic, GPU inference | Low (5-50ms) | Medium |\n| **Batch prediction** (scheduled job) | High volume, latency-tolerant | N\u002FA (scheduled) | Low |\n| **Streaming** (Kafka + model) | Real-time event processing | Low | High |\n| **Edge \u002F embedded** | Offline, privacy-sensitive | Very low | High |\n\nFor most teams starting out: REST API with FastAPI is the right default. Optimize for lower latency only when measured need justifies complexity.\n\n### Step 3: Build the Serving Application\n\nThe serving app needs:\n\n```\nRequest → Validate input → Preprocess → Predict → Postprocess → Response\n```\n\nKey requirements:\n- **Input validation**: Reject malformed requests before they reach the model. With FastAPI\n  this is a Pydantic request model on the predict endpoint — declare the feature schema with\n  types and ranges, and return 422 on a bad payload (see `references\u002Fserving-patterns.md`).\n  **Under a high-throughput requirement this is the first thing people cut, and it is the\n  wrong cut.** Trimming pandas, fixing column order, and batching are the latency wins;\n  the request schema is not one. An unvalidated fraud endpoint scores garbage features\n  silently instead of rejecting them — a wrong prediction costs more than the microseconds\n  the check takes.\n- **Feature preprocessing**: Apply the same transformations used in training\n- **Error handling**: Model errors should return 500 with diagnostic info, not crash the service\n- **Logging**: Log every prediction request\u002Fresponse for monitoring and debugging\n- **Health check**: Endpoint that verifies the model is loaded and responsive\n\nSee [references\u002Fserving-patterns.md](references\u002Fserving-patterns.md) for implementation templates.\n\n### Step 4: Deploy Safely\n\nModels should be deployed with the same caution as any production service — more, given their non-deterministic nature:\n\n**Shadow mode**: Deploy the new model alongside the current one. Both receive traffic, but only the current model's predictions are used. Compare predictions to evaluate the new model on real data.\n\n**Canary deployment**: Route a small percentage of traffic (5-10%) to the new model. Monitor metrics. Gradually increase if performance is acceptable.\n\n**A\u002FB testing**: Split traffic between model versions to measure business impact (conversion rate, click-through, etc.), not just ML metrics.\n\n**Blue-green**: Deploy new model to a separate environment, switch all traffic at once after validation. Fastest rollback.\n\n### Step 5: Monitor in Production\n\nAfter deployment, monitor continuously. See [references\u002Fserving-patterns.md](references\u002Fserving-patterns.md) for implementation details.\n\n**Model performance monitoring:**\n- Track prediction accuracy against ground truth (when available)\n- Monitor prediction distribution (are predictions shifting?)\n- Track business KPIs that the model influences\n\n**Data drift detection:**\n- Compare input feature distributions against the training data baseline\n- Use statistical tests: Population Stability Index (PSI), Kolmogorov-Smirnov (KS) test, Jensen-Shannon divergence\n- Alert when drift exceeds thresholds\n\n**System monitoring:**\n- Prediction latency (P50, P95, P99)\n- Request throughput and error rates\n- Resource utilization (CPU, memory, GPU)\n- Model loading time\n\n**Retraining triggers:**\n- Accuracy drops below threshold\n- Data drift exceeds threshold\n- Scheduled retraining (weekly\u002Fmonthly depending on domain)\n- New labeled data becomes available\n\n### Step 6: Plan Rollback\n\nEvery model deployment needs a rollback plan:\n- Previous model version tagged and ready in the registry\n- One-command rollback through CI\u002FCD or model registry stage transition\n- Automated rollback on monitoring alert (if confidence is high)\n\n## Principles Applied\n\n- **KISS**: Start with REST API + batch monitoring. Add real-time drift detection when scale justifies it.\n- **YAGNI**: Don't build an A\u002FB testing framework for your first model. Shadow mode is enough.\n- **Defense in depth**: Validate inputs, monitor outputs, detect drift, and have rollback ready.\n- **Functional Independence**: Serving, monitoring, and retraining should be independent components, not monolithic.\n","# ML Model Deployment\n\nDeploy models to production with serving infrastructure that is reliable, observable, and safely updatable. Deploying a model is not the finish line — it's the beginning of the operational lifecycle.\n\n## Key Difference from Software Deployment\n\nSoftware deployment is primarily concerned with \"does the code work?\" Model deployment adds: \"does the model still work *well* on real-world data that changes over time?\" Models degrade silently — they keep returning predictions, just increasingly wrong ones.\n\n## Workflow\n\n### Step 1: Package the Model\n\nBefore deployment, the model must be a self-contained, versioned artifact:\n\n- **Serialize the model**: Use framework-native formats (joblib\u002Fpickle for sklearn, SavedModel for TF, TorchScript for PyTorch, ONNX for cross-framework)\n- **Pin dependencies**: Exact versions of libraries used during training\n- **Include preprocessing**: The serving pipeline must apply the same feature transformations as training. Feature skew (different preprocessing in training vs serving) is the #1 cause of silent model failure\n- **Version it**: Tag with model registry version, git commit, training data version, and training metrics\n\n### Step 2: Choose the Serving Pattern\n\n| Pattern | When to Use | Latency | Complexity |\n|---------|-------------|---------|------------|\n| **REST API** (Flask\u002FFastAPI + model) | Low traffic, simple models | Medium (50-200ms) | Low |\n| **Dedicated serving** (TF Serving, Triton, Seldon) | High traffic, GPU inference | Low (5-50ms) | Medium |\n| **Batch prediction** (scheduled job) | High volume, latency-tolerant | N\u002FA (scheduled) | Low |\n| **Streaming** (Kafka + model) | Real-time event processing | Low | High |\n| **Edge \u002F embedded** | Offline, privacy-sensitive | Very low | High |\n\nFor most teams starting out: REST API with FastAPI is the right default. Optimize for lower latency only when measured need justifies complexity.\n\n### Step 3: Build the Serving Application\n\nThe serving app needs:\n\n```\nRequest → Validate input → Preprocess → Predict → Postprocess → Response\n```\n\nKey requirements:\n- **Input validation**: Reject malformed requests before they reach the model. With FastAPI\n  this is a Pydantic request model on the predict endpoint — declare the feature schema with\n  types and ranges, and return 422 on a bad payload (see `references\u002Fserving-patterns.md`).\n  **Under a high-throughput requirement this is the first thing people cut, and it is the\n  wrong cut.** Trimming pandas, fixing column order, and batching are the latency wins;\n  the request schema is not one. An unvalidated fraud endpoint scores garbage features\n  silently instead of rejecting them — a wrong prediction costs more than the microseconds\n  the check takes.\n- **Feature preprocessing**: Apply the same transformations used in training\n- **Error handling**: Model errors should return 500 with diagnostic info, not crash the service\n- **Logging**: Log every prediction request\u002Fresponse for monitoring and debugging\n- **Health check**: Endpoint that verifies the model is loaded and responsive\n\nSee [references\u002Fserving-patterns.md](references\u002Fserving-patterns.md) for implementation templates.\n\n### Step 4: Deploy Safely\n\nModels should be deployed with the same caution as any production service — more, given their non-deterministic nature:\n\n**Shadow mode**: Deploy the new model alongside the current one. Both receive traffic, but only the current model's predictions are used. Compare predictions to evaluate the new model on real data.\n\n**Canary deployment**: Route a small percentage of traffic (5-10%) to the new model. Monitor metrics. Gradually increase if performance is acceptable.\n\n**A\u002FB testing**: Split traffic between model versions to measure business impact (conversion rate, click-through, etc.), not just ML metrics.\n\n**Blue-green**: Deploy new model to a separate environment, switch all traffic at once after validation. Fastest rollback.\n\n### Step 5: Monitor in Production\n\nAfter deployment, monitor continuously. See [references\u002Fserving-patterns.md](references\u002Fserving-patterns.md) for implementation details.\n\n**Model performance monitoring:**\n- Track prediction accuracy against ground truth (when available)\n- Monitor prediction distribution (are predictions shifting?)\n- Track business KPIs that the model influences\n\n**Data drift detection:**\n- Compare input feature distributions against the training data baseline\n- Use statistical tests: Population Stability Index (PSI), Kolmogorov-Smirnov (KS) test, Jensen-Shannon divergence\n- Alert when drift exceeds thresholds\n\n**System monitoring:**\n- Prediction latency (P50, P95, P99)\n- Request throughput and error rates\n- Resource utilization (CPU, memory, GPU)\n- Model loading time\n\n**Retraining triggers:**\n- Accuracy drops below threshold\n- Data drift exceeds threshold\n- Scheduled retraining (weekly\u002Fmonthly depending on domain)\n- New labeled data becomes available\n\n### Step 6: Plan Rollback\n\nEvery model deployment needs a rollback plan:\n- Previous model version tagged and ready in the registry\n- One-command rollback through CI\u002FCD or model registry stage transition\n- Automated rollback on monitoring alert (if confidence is high)\n\n## Principles Applied\n\n- **KISS**: Start with REST API + batch monitoring. Add real-time drift detection when scale justifies it.\n- **YAGNI**: Don't build an A\u002FB testing framework for your first model. Shadow mode is enough.\n- **Defense in depth**: Validate inputs, monitor outputs, detect drift, and have rollback ready.\n- **Functional Independence**: Serving, monitoring, and retraining should be independent components, not monolithic.\n",{"name":5,"description":7},"main","800dc9ad0ca2914d6ad15b8c5159d9b57bb104c2","plugins\u002Fml\u002Fskills\u002Fml-model-deployment","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills","https:\u002F\u002Fgithub.com\u002FSWEStash","A stash of things we felt like building","2026-11-12 00:14:33",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add SWEStash\u002Fswe-workflow-skills --skill ml-model-deployment",{"tool":57,"command":58},"bunx","bunx skills add SWEStash\u002Fswe-workflow-skills --skill ml-model-deployment",{"tool":60,"command":61},"pnpm","pnpm dlx skills add SWEStash\u002Fswe-workflow-skills --skill ml-model-deployment","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fml\u002Fskills\u002Fml-model-deployment\u002FSKILL.md",true,[65,71],{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"evals\u002Fevals.json","REFERENCE","参考文档",3168,"https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fml\u002Fskills\u002Fml-model-deployment\u002Fevals\u002Fevals.json",{"path":72,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fserving-patterns.md",5033,"https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fml\u002Fskills\u002Fml-model-deployment\u002Freferences\u002Fserving-patterns.md",[76,102,128,151,177,202],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":39},"01M6JQFADV3T1MS9V1BNZS1232","writing-skills","Use when authoring, editing, or reviewing a skill in this library — a new SKILL.md, one that under-triggers, or hardening an existing one. Covers description and listing-budget rules, frontmatter, progressive disclosure, the 3-eval rule, and pressure-testing against rationalizations.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[83,84,85,86,87,88,89,90,91,92,93,94,28,95,96,97,98,99,100,101],"writing","writing skills","testing","eval","write","edit","Budget","authoring","new skill","library","frontmatter","editing","use","Existing","Rules","write a skill","when","listing","progressive disclosure",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":39},"01M6JQF5DGMXPMQQVZBP8DH9SY","working-agreement","Define and validate how a multi-session project is run — where plans, status and decisions live, session routines, new work, milestone close. README\u002FCONTRIBUTING → project-documentation.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fworking-agreement\u002FSKILL.md",[],[109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,28,127],"working agreement","project","definition of done","done","milestone","documentation","work","progress","how","contributing","close","run","sync","status","live","do","README","session","routines",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":39},"01M6JQF0SMRHN82RBSWMABC4J0","verification-before-completion","Evidence gate before any claim that work is done, fixed, passing, or deployed. Route here when a message declares the work finished or asks to commit, push, merge, ship, or close it out, including a brief sign-off, and before git-workflow or release-management act on it. Writing the commit message or PR text itself → git-workflow.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fverification-before-completion\u002FSKILL.md",[],[135,136,137,138,139,140,83,141,112,142,143,144,115,145,119,146,147,148,149,150],"verification","verification before completion","brief","ready","fix","claim","workflow","commit","text","route","message","merge","release","git","act","ship",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":39},"01M6JQEVGE9NJZ11DV60AE6VWC","ui-ux-design","Design user experiences from an engineer's perspective — user flows, wireframes, interaction patterns, responsive strategy, navigation, loading\u002Ferror\u002Fempty states. Triggers: design the UI, user flow, wireframe, how should this screen look, loading state, error state, empty state, responsive design, navigation, page layout, form design, mockup.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fui-ux-design\u002FSKILL.md",[],[158,159,160,161,162,163,164,165,166,167,168,169,117,170,171,172,173,174,175,176],"design","ux","ui","ui ux design","error","states","loading","flows","engineer","interaction","layout","responsive design","screen","flow","patterns","mockup","responsive","form","page",{"skillNo":178,"name":179,"nameZh":6,"description":180,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":181,"categories":182,"keywords":183,"publishedAt":39},"01M6JQEN4HVFTZWQYWGTDS76K9","threat-modeling","Design-time security analysis of a system or feature before it's built — trust boundaries, attack surface, STRIDE per element, abuse cases, prioritized mitigations that become security requirements. Triggers: threat model, STRIDE, trust boundary, attack surface, what could go wrong security-wise, security design review, abuse case, secure this design, security requirements. Reviewing EXISTING code\u002Fconfig for vulnerabilities → security-audit; use this skill while the design is still on the whiteboard.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fthreat-modeling\u002FSKILL.md",[],[184,185,186,23,187,188,158,189,190,191,192,193,194,195,196,197,198,199,200,201],"modeling","threat modeling","threat","time","element","whiteboard","security analysis","analysis","code","review","threat model","audit","security-audit","secure","config","go","security","trust",{"skillNo":203,"name":204,"nameZh":6,"description":205,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":206,"categories":207,"keywords":208,"publishedAt":39},"01M6JQEFT7VT3FQM16170EG9FW","test-suite-design","Design comprehensive test suites for existing code — strategy across unit\u002Fintegration\u002Fe2e, fixtures, factories, helpers. Triggers: add tests, write tests for, increase coverage, test this module, testing strategy, test plan, what tests do I need, test infrastructure, test helpers, this has no tests. Not for TDD — use tdd-workflow.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Ftest-suite-design\u002FSKILL.md",[],[158,209,38,210,211,212,85,213,214,141,192,215,216,87,217,36,124,218,219,28],"test suite","test suite design","coverage","unit","write tests","testing strategy","across","plan","add","test plan","for"]