model-optimization-guide

model-optimization-guide is a skill for Claude Code, Codex from khalilbenaz/claude-skills-collection. It costs 126 tokens per session (2,716 once invoked), scanned A, original, MIT.

A practical guide to making machine-learning models smaller and faster when they run, using methods such as quantization, pruning, distillation, and ONNX export.

In plain words
What is it for?
Use it to measure a model’s current performance, select an optimization approach, export it between frameworks, and apply the process with ready-to-copy code examples.
Why use it?
It helps choose an optimization method based on hardware, speed, memory, and acceptable quality loss instead of relying on trial and error.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to measure a model’s current performance, select an optimization approach, export it between frameworks, and apply the process with ready-to-copy code examples.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/khalilbenaz/claude-skills-collection/model-optimization-guide
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add khalilbenaz/claude-skills-collection --skill model-optimization-guide
Clone the repo
git clone --depth 1 https://github.com/khalilbenaz/claude-skills-collection

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for model-optimization-guide

README.md
[![agentmods](https://agentmods.dev/badge/skills/khalilbenaz/claude-skills-collection/model-optimization-guide/github.svg)](https://agentmods.dev/skills/khalilbenaz/claude-skills-collection/model-optimization-guide)
Your own site
<a href="https://agentmods.dev/skills/khalilbenaz/claude-skills-collection/model-optimization-guide"><img src="https://agentmods.dev/badge/skills/khalilbenaz/claude-skills-collection/model-optimization-guide/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for model-optimization-guide

Your own site · 80×15
<a href="https://agentmods.dev/skills/khalilbenaz/claude-skills-collection/model-optimization-guide"><img src="https://agentmods.dev/badge/skills/khalilbenaz/claude-skills-collection/model-optimization-guide.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 126 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,716 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00126 $0.02716
Opus 5 $0.00063 $0.01358
Sonnet 5 $0.00025 $0.00543
Haiku 4.5 $0.00013 $0.00272

Measured 9d ago against content hash 1c7af8cfa789, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

model-optimization-guide scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

ai-ml-skills/model-optimization-guide/SKILL.md · 300 lines

How it starts

The opening of the file, as written. The whole thing — 300 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Model Optimization Guide

Guide opérationnel pour réduire la taille et accélérer l'inférence d'un modèle ML sans régresser les métriques métier.

Critères de décision rapides

Contrainte principale Technique recommandée
Déploiement sans GPU, CPU seul PTQ INT8 + ONNX Runtime (OpenVINO EP)
Latence < 20 ms sur GPU NVIDIA TensorRT FP16 ou INT8
Modèle trop gros pour mémoire edge Pruning structuré + TFLite/CoreML
LLM > 7B à servir sur 1 GPU GPTQ 4-bit ou AWQ
Contrainte de qualité stricte (< 0,5 % drop) QAT ou distillation
Pipeline cross-framework ONNX export + ORT

Workflow en 7 étapes

1. Profiler et fixer les objectifs

Avant toute optimisation, mesurer la baseline sur le hardware de production.

# PyTorch Profiler (CPU+GPU)
import torch
from torch.profiler import profile, ProfilerActivity

with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA],
             record_shapes=True, profile_memory=True) as prof:
    model(inputs)

print(prof.key_averages().table(sort_by="cuda_time_total", row_limit=15))
prof.export_chrome_trace("trace.json")  # ouvrir dans chrome://tracing

Grille d'objectifs à remplir avant de commencer :

Métrique Valeur actuelle Cible Tolérance dégradation
Latence P95 (ms) ? ? +0 %
Taille modèle (MB) ? ?
Accuracy / F1 ? -0,5 % max
VRAM / RAM (MB) ? ?

2. Quantification (technique la plus rapide)

PTQ INT8 — PyTorch (sans réentraînement)

import torch.quantization as tq

model.eval()
model.qconfig = tq.get_default_qconfig('fbgemm')   # CPU x86
# ou 'qnnpack' pour ARM/mobile
tq.prepare(model, inplace=True)

# Calibration : passer ~100-500 exemples représentatifs
for batch in calibration_loader:
    model(batch)

tq.convert(model, inplace=True)
torch.save(model.state_dict(), "model_int8.pt")

PTQ FP16 — ONNX Runtime (le plus portable)

from onnxruntime.quantization import quantize_dynamic, QuantType

quantize_dynamic(
    "model.onnx",
    "model_int8.onnx",
    weight_type=QuantType.QInt8
)

Read the full file on GitHub · 300 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 300 lines · 126 tokens per session scan A 1c7af8cfa789

Subscribe to this mod's changes

model-optimization-guide is a skill published in the GitHub repository khalilbenaz/claude-skills-collection (22 stars, last pushed 15d ago), licensed MIT. It adds 126 tokens to every session and 2,716 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.