infer

infer is a command for coding agents from xiaobei930/cc-best. It costs 5 tokens per session (688 once invoked), scanned A, original, MIT.

A command for running a trained machine-learning model to produce predictions from input data.

In plain words
What is it for?
Use it to load PyTorch, Hugging Face, ONNX, or TensorRT models, process one or many inputs, run a prediction service, and apply listed speed or memory options.
Why use it?
It gathers the practical checks needed before and during prediction, such as GPU availability, model files, and installed libraries. It also covers single-file, batch, and API-based runs.

Command

Part of the cc-best plugin — 3 skills, 44 commands, 8 agents, 20 hooks shipped together

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.

agentmods
npx agentmods add commands/xiaobei930/cc-best/infer
Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best

Or install cc-best, the plugin that ships this one along with the rest of its 3 skills, 44 commands, 8 agents, 20 hooks.

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 infer

README.md
[![agentmods](https://agentmods.dev/badge/commands/xiaobei930/cc-best/infer.svg)](https://agentmods.dev/commands/xiaobei930/cc-best/infer)
Your own site
<a href="https://agentmods.dev/commands/xiaobei930/cc-best/infer"><img src="https://agentmods.dev/badge/commands/xiaobei930/cc-best/infer.svg" alt="Measured on agentmods" height="20"></a>
Per session 5 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 688 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00005 $0.00688
Opus 5 $0.00003 $0.00344
Sonnet 5 $0.00001 $0.00138
Haiku 4.5 $0.00001 $0.00069

Measured 4d ago against content hash 00721c2a4028, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

infer 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 4d 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.

commands/infer.md · 119 lines

What it actually says

/infer - 模型推理

运行机器学习/深度学习模型推理。

适用场景

  • 模型预测
  • 批量推理
  • 实时服务

通用推理流程

1. 环境检查

# GPU 检查
python -c "import torch; print(f'CUDA: {torch.cuda.is_available()}')"

# 模型文件检查
ls -la models/

# 依赖检查
pip list | grep -E "torch|onnx|tensorrt"

2. 模型加载

# PyTorch 示例
model = torch.load("models/model.pt")
model.eval()

# Hugging Face 示例
from transformers import AutoModel
model = AutoModel.from_pretrained("models/my-model")

3. 推理执行

# 单文件推理
python infer.py --input data/input.txt --output results/

# 批量推理
python infer.py --input-dir data/batch/ --output-dir results/

# API 服务模式
python serve.py --model models/model.pt --port 8000

性能优化

加速选项

方法 命令/配置
半精度推理 --fp16torch.float16
批量处理 --batch-size 32
ONNX 转换 torch.onnx.export()
TensorRT trtexec --onnx=model.onnx

显存优化

# 梯度检查点
torch.cuda.empty_cache()

# 推理模式
with torch.no_grad():
    output = model(input)

常用框架

框架 推理命令
PyTorch python infer.py
Hugging Face python -m transformers.pipelines
ONNX Runtime python onnx_infer.py
TensorRT trtexec --loadEngine=model.trt

输出格式

保存结果

# JSON 格式
import json
with open("results.json", "w") as f:
    json.dump(results, f)

# CSV 格式
import pandas as pd
df.to_csv("results.csv", index=False)

注意事项

  • 首次运行需要加载模型权重(可能较慢)
  • 确保输入数据格式与训练时一致
  • 检查 GPU 显存是否充足
  • 大批量推理建议分批处理

项目定制

根据项目需要修改此文件,添加具体的:

  • 模型路径和类型
  • 输入/输出格式
  • 推理参数
  • 后处理逻辑

记住: 推断必须有来源——上下文、代码、文档。无依据的推断就是猜测,应标记 TBD。

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. 4d ago First seen · 119 lines · 5 tokens per session scan A 00721c2a4028

Subscribe to this mod's changes

infer is a command published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 5 tokens to every session and 688 once invoked, about $0.0000 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.