一键导入
neural-model-optimization
Learn how to compress machine learning models using distillation, pruning, and quantization for real-world deployment.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Learn how to compress machine learning models using distillation, pruning, and quantization for real-world deployment.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
This skill should be used when users need help with Git, GitHub workflows, pull requests, branching strategies, repository contributions, and open source collaboration.
FastAPI Python backend for LLM Arena game server. Use when working on API endpoints, LLM provider integration via LiteLLM, game move processing, prompt engineering for AI players, error handling, or backend testing.
React 19 + Vite frontend for LLM Arena game visualization. Use when working on UI components, game board rendering, state management with hooks, API integration, Tailwind CSS v4 styling, Framer Motion animations, or frontend build configuration.
Full-stack LLM Arena application for AI vs AI game battles. Use when working on project-wide configurations, deployment, architecture decisions, or coordinating between frontend and backend. Covers Tic-Tac-Toe and Reversi games with OpenAI, Anthropic, and Google Gemini support.
Audits mobile app codebases for pre-release readiness across iOS (Swift/SwiftUI/UIKit), Android (Kotlin/Jetpack Compose), Flutter (Dart), and React Native. Produces a ship / ship-with-caveats / block verdict backed by findings in six layers — privacy & permissions, accessibility, localization, crash-prone code, store metadata, and release-build hygiene. Use when given a mobile app repo (or parts of one) and asked to review, audit, pre-flight, check if ready to ship, prepare for App Store or Play Store submission, run a release checklist, do an accessibility or privacy compliance review, or diagnose a likely store rejection. Also use when user mentions TestFlight, beta submission, privacy manifest, PrivacyInfo.xcprivacy, Data Safety form, ATT prompt, content rating, age rating, export compliance, Info.plist audit, AndroidManifest audit, or "why will this get rejected".
Assistant for designing, building, and optimizing Power BI semantic models. Helps with data architecture decisions, DAX formula development, relationship configuration, performance tuning, and implementation of analytics best practices. Triggers on questions about model design patterns, metric calculations, schema optimization, data integrity, security frameworks, and documentation standards.
| name | Neural Model Optimization |
| description | Learn how to compress machine learning models using distillation, pruning, and quantization for real-world deployment. |
| tags | ["machine-learning","pytorch","optimization","deployment"] |
| version | 3.1.0 |
Welcome! In this skill, you’ll learn how modern AI systems transform large models into efficient, deployable systems used in real-world applications.
Why large models are inefficient
How to compress models using:
How to design real-world optimization pipelines
Recognize why large models fail in real-world deployment.
💡 Insight A model that is 99% accurate but too slow is unusable in production.
👉 Task
Understand how knowledge is transferred from large to small models.
Distillation trains a student model to mimic a teacher model.
graph LR
A[Teacher Model] --> B[Soft Targets]
B --> C[Student Model]
💡 Insight Distillation preserves knowledge, not just predictions.
👉 Task Why is learning probabilities better than learning labels?
Understand the training mechanism behind distillation.
Teacher outputs soft probabilities
Student learns using temperature scaling
Loss combines:
💡 Insight Higher temperature smooths probability distribution → richer learning.
👉 Task What happens if temperature is too low?
Apply distillation in a real ML workflow.
import torch.nn.functional as F
def distillation_loss(student_logits, teacher_logits, labels, T=4, alpha=0.7):
soft_loss = F.kl_div(
F.log_softmax(student_logits/T, dim=1),
F.softmax(teacher_logits/T, dim=1),
reduction='batchmean'
) * (T*T)
hard_loss = F.cross_entropy(student_logits, labels)
return alpha * soft_loss + (1 - alpha) * hard_loss
💡 Insight Distillation often improves generalization due to regularization.
👉 Task Why can a student outperform a teacher model?
Understand how models remove redundancy.
Pruning removes weights with minimal contribution.
💡 Insight Neural networks are often over-parameterized.
👉 Task Why can large portions of a network be removed without major accuracy loss?
Differentiate pruning strategies.
graph TD
A[Full Model] --> B{Pruning}
B --> C[Unstructured]
B --> D[Structured]
💡 Insight Hardware prefers structured sparsity.
👉 Task Which pruning type is better for GPUs and why?
Apply pruning using real frameworks.
import torch.nn.utils.prune as prune
prune.ln_structured(model.conv1, name="weight", amount=0.4, dim=0)
💡 Insight Pruning must be followed by fine-tuning.
👉 Task What happens if you prune without retraining?
Understand precision reduction.
graph LR
A[FP32] --> B[Quantization]
B --> C[INT8]
💡 Insight Lower precision reduces memory and compute cost.
👉 Task Why does reducing precision improve speed?
Apply quantization in practice.
import torch.quantization as quant
model.qconfig = quant.get_default_qconfig('fbgemm')
quant.prepare(model, inplace=True)
quant.convert(model, inplace=True)
💡 Insight Quantization introduces noise—training must adapt.
👉 Task What errors can quantization introduce?
Understand trade-offs.
| Method | Speed | Accuracy |
|---|---|---|
| PTQ | Fast | Lower |
| QAT | Slower | High |
💡 Insight QAT simulates quantization during training.
👉 Task When would you choose PTQ over QAT?
Combine all optimization techniques.
graph TD
A[Teacher] --> B[Distillation]
B --> C[Pruning]
C --> D[Quantization]
D --> E[Optimized Model]
💡 Insight Order determines final performance.
👉 Task Why should pruning come before quantization?
Measure optimization impact.
| Metric | Original | Optimized |
|---|---|---|
| Size | 31 MB | 3 MB |
| Latency | 42 ms | 11 ms |
| Memory | 122 MB | 28 MB |
💡 Insight Optimization is about trade-offs, not perfection.
👉 Task Which metric matters most for:
Apply concepts in production.
💡 Insight Modern AI systems are memory-bound.
👉 Task Why is memory bandwidth more critical than compute?
Design a complete optimized ML system.
Requirements:
You learned:
👉 These together enable scalable AI systems.
You’re now thinking like an ML systems engineer—go build efficient intelligence.