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.
npx skills add majiayu000/spellbook --skill model-inference-optimizegit clone --depth 1 https://github.com/majiayu000/spellbookWrote 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.
[](https://agentmods.dev/skills/majiayu000/spellbook/model-inference-optimize)<a href="https://agentmods.dev/skills/majiayu000/spellbook/model-inference-optimize"><img src="https://agentmods.dev/badge/skills/majiayu000/spellbook/model-inference-optimize/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.
<a href="https://agentmods.dev/skills/majiayu000/spellbook/model-inference-optimize"><img src="https://agentmods.dev/badge/skills/majiayu000/spellbook/model-inference-optimize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00157 | $0.02694 |
| Opus 5.5 | $0.00063 | $0.01078 |
| Sonnet 5.5 | $0.00031 | $0.00539 |
| Haiku 4.5 | $0.00016 | $0.00269 |
Grade A, and why
model-inference-optimize 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 28d 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.
How it starts
The opening of the file, as written. The whole thing — 97 lines — stays where its author put it; the contents beside it link to each section on GitHub.
模型推理优化系统
把明确的推理工作负载优化到可验证的结果。沿用同一任务定义、实验记录和验收标准,按瓶颈选择专项,不把所有优化技术轮流试一遍。
入口与资料
| 当前问题 | 从哪里开始 | 按需读取 |
|---|---|---|
| 模型尚未跑通、迁移后效果不对 | 任务 → 正确性对齐 | 专项方法 的「复现与后端迁移」 |
| 延迟高、GPU 利用率低、显存不足 | 任务 → 基线 → profile | 专项方法的「测量」「显存与数据流」 |
| 换 attention/kernel、FP8 或 compile | 先证明热点和实际运行路径 | 专项方法的「算子与编译」 |
| 减少 steps、换蒸馏模型或近似 decoder | 先定义允许的质量变化 | 专项方法的「近似推理」 |
| 复用同类优化经验 | 按当前瓶颈选案例 | 脱敏案例,只读相关小节 |
| 已有优化要接入服务或证明真实收益 | 质量回归 → 完整请求 → 服务验收 | 专项方法的「质量评测」「服务与成本」 |
需要记录时复制 实验模板 到本轮产物目录,删去不适用的字段;普通 bug 修复可缩成一张对比表。
模型质量/性能对比沿用本技能。纯托管 API、Prompt、token/cache 命中或 agent 工具调用优化不进入下述 GPU 实验流程:先检查当前可用技能列表,仅在外部技能 llm-app-optimize 已安装时转交;未安装时,在当前对话中固定代表请求,记录端到端延迟、用量/费用和输出质量,一次修改一个因素,并复用应用已有的回归检查验收。
全产品竞品研究仅在外部技能 peerscope 已安装时转交;未安装时,在当前对话中明确产品对比问题,从官方资料收集功能、价格和使用限制,附来源与日期,并将未实测能力标为待验证。这两个外部技能均不是 Spellbook 安装前提,不要求为完成当前任务安装它们。
Operating Contract
- Direct actions: 在请求范围内读代码、分析现有日志、修改本地实现并运行已授权的检查和实验。
- Escalate before: 超出既有授权的收费运行、凭证修改、占用其他任务设备、生产变更或发布。已有授权覆盖时继续执行。
- Evidence-backed pushback: profile 显示拟优化部分占比很低或任务规格被改变时,给出 trace/输出证据和更小的替代实验。
- Feedback loop: 记录失败假设、质量回归和撤回原因;续跑先核对旧基线是否仍有效,再选择下一项实验。
1. 锁定任务和实际运行路径
- 核对目标仓库、cwd、worktree、commit、未提交改动和实际服务入口。不要把当前目录默认当成模型仓库。缺少目标模型或路径时只询问影响开工的缺口,同时整理已有证据。
- 从真实请求追到权重/adapter、scheduler、预处理、推理、后处理、编码和响应,记录实际加载的实现。核对参数是否被读取、provider/kernel 是否实际运行;import 成功或开关存在不算命中。
- 固定输入集合与哈希、输出尺寸/帧数/FPS/时长/音频、精度、seed、模型版本、GPU 型号与数量、软件栈、并发和计时边界。相同 seed 不保证跨后端或跨进程逐位一致。
- 写明主目标和质量约束,例如「同一 2K 视频热态请求更快,构图与颜色不退化」。区分允许数值误差、允许感知变化、允许更换模型/输出规格的范围。
- 使用已授权设备、时间和费用范围;不占用其他任务的 GPU、不重启现有服务或自动部署。已有授权不重复询问。没有 GPU 时完成静态定位和实验准备,性能结论留为未测。
2. 建立可信基线
- 复用仓库 runner、数据集、profiler 和检查命令;没有可复现入口时只补当前任务需要的最小入口,不搭建通用平台。
- 先保存真实输出并核验规格和基本质量。输入或参考未对齐时先修正确性,再优化性能。
- 分列下载/加载、engine build/compile、首次推理、同一常驻进程热态请求和文件/API 返回。每次重启进程不算模型热态。
- 保存逐次数据、失败/OOM、原始日志与同步方法。CUDA event 测 GPU 区间,同步后的 wall time 测实际完成时间;profiler 用于归因,无 profiler 运行用于最终成绩。
- 资源允许时 warmup 后至少三次重复作为初步判断。收益接近波动时增加交错 A/B 或 ABBA,不挑最优一次。少量样本报原始值、中位数和范围,不称生产 p95。
What ships with it
4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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.
- 28d ago Changed 8b21e3b7756c
- 1mo ago First seen · 97 lines · 157 tokens per session scan A 6419c9a5bd8a
model-inference-optimize is a skill published in the GitHub repository majiayu000/spellbook (301 stars, last pushed yesterday), licensed MIT. It adds 157 tokens to every session and 2,694 once invoked, about $0.0006 per session on Opus 5.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-10-08.
model-inference-optimize compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| model-inference-optimizemajiayu000/spellbook | Skill | 301 | yesterday | MIT | A | 157 | Codex |
| dspy-parallellebsral/DSPy-Programming-not-prompting-LMs-skills | Skill | 13 | 5mo ago | none | A | 171 | Claude Code |
| arboretoK-Dense-AI/scientific-agent-skills | Skill | 59k | yesterday | MIT | A | 55 | Claude Code, Codex |
| deepspot-mK-Dense-AI/scientific-agent-skills | Skill | 59k | yesterday | MIT | A | 70 | Claude Code |
| torchdrugK-Dense-AI/scientific-agent-skills | Skill | 59k | yesterday | MIT | A | 64 | Claude Code |
| pyhealthK-Dense-AI/scientific-agent-skills | Skill | 59k | yesterday | MIT | A | 84 | Claude Code, Codex |
| evo2aipoch/open-science | Skill | 5.6k | yesterday | Apache-2.0 | A | 83 | Claude Code, Codex |