minicpm5-deploy-transformers

minicpm5-deploy-transformers is a skill for Claude Code, Codex from OpenBMB/MiniCPM. It costs 90 tokens per session (939 once invoked), scanned A, original, Apache-2.0.

Instructions for running MiniCPM5-1B, a small language model, with Hugging Face Transformers in a one-shot Python script. It supports GPU or CPU execution and optional thinking mode.

In plain words
What is it for?
Installing the required packages, loading the model and tokenizer, preparing chat input, and generating a response on a GPU or CPU.
Why use it?
It provides a direct way to generate text locally without setting up a model server or adding unnecessary dependencies.

Skill for Claude CodeCodex

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

Good fit Installing the required packages, loading the model and tokenizer, preparing chat input, and generating a response on a GPU or CPU.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/openbmb/minicpm/minicpm5-deploy-transformers
About the project

MiniCPM is a family of compact language models, including MiniCPM5-1B, designed to run locally on devices with limited resources. Developers use it for on-device assistants, reasoning, code, tool use, deployment, and fine-tuning, while the repository also includes a desktop-pet example. The catalogue entries support deployment and fine-tuning workflows for the models.

OpenBMB/MiniCPM · 10,478 stars · on GitHub

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 OpenBMB/MiniCPM --skill minicpm5-deploy-transformers
Clone the repo
git clone --depth 1 https://github.com/OpenBMB/MiniCPM

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 minicpm5-deploy-transformers

README.md
[![agentmods](https://agentmods.dev/badge/skills/openbmb/minicpm/minicpm5-deploy-transformers.svg)](https://agentmods.dev/skills/openbmb/minicpm/minicpm5-deploy-transformers)
Your own site
<a href="https://agentmods.dev/skills/openbmb/minicpm/minicpm5-deploy-transformers"><img src="https://agentmods.dev/badge/skills/openbmb/minicpm/minicpm5-deploy-transformers.svg" alt="Measured on agentmods" height="20"></a>
Per session 90 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 939 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.00090 $0.00939
Opus 5 $0.00045 $0.00469
Sonnet 5 $0.00018 $0.00188
Haiku 4.5 $0.00009 $0.00094

Measured today against content hash 4e6e21fad965, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

minicpm5-deploy-transformers 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 today.

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.

skills/minicpm5-deploy-transformers/SKILL.md · 95 lines

How it starts

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

Deploy MiniCPM5-1B and MiniCPM5-2B with HF Transformers

One-shot Python generation. No server. Works on a single GPU (bfloat16) or CPU only (fp32).

Required input

Var Example Default
MODEL_PATH openbmb/MiniCPM5-2B or local dir required; openbmb/MiniCPM5-1B also works
MODE think or nothink (nothink is 1B-only) think

Steps

1. Install (once)

pip install -U "transformers>=5.6,<6" "torch>=2.11" accelerate     # latest (CUDA 13.x driver hosts)
# pip install -U "transformers==4.57.3" "torch==2.7.1" accelerate  # fallback for CUDA 12.x driver hosts

2. Run

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_path = "${MODEL_PATH}"      # ← replace
tok = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
    model_path,
    torch_dtype=torch.bfloat16,    # CPU users: torch.float32 + device_map="cpu"
    device_map="auto",
).eval()

messages = [{"role": "user", "content": "用一句话解释什么是 GQA。"}]
inputs = tok.apply_chat_template(
    messages,
    add_generation_prompt=True,
    enable_thinking=True,
    return_tensors="pt",
    return_dict=True,
).to(model.device)

with torch.no_grad():
    out = model.generate(
        **inputs,
        max_new_tokens=1024,
        do_sample=True,
        temperature=1.0,
        top_p=0.95,
    )

prompt_len = inputs["input_ids"].shape[-1]
print(tok.decode(out[0][prompt_len:], skip_special_tokens=True))

For CPU only: change torch_dtype=torch.float32, device_map="cpu". Keep enable_thinking=True and temperature=1.0 for MiniCPM5-2B; use enable_thinking=False and temperature=0.7 only for MiniCPM5-1B No-think mode.

Sampling defaults

Mode enable_thinking temperature top_p
MiniCPM5-2B Think True 1.0 0.95
MiniCPM5-1B Think True 0.9 0.95
MiniCPM5-1B No-think False 0.7 0.95

Validate

A coherent answer to 1+1=? (e.g. "2" or "答案是 2").

Read the full file on GitHub · 95 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. today Changed · +4 lines · +8 tokens per session 4e6e21fad965
  2. 8d ago First seen · 91 lines · 82 tokens per session scan A e42ebb2045bc

Subscribe to this mod's changes

minicpm5-deploy-transformers is a skill published in the GitHub repository OpenBMB/MiniCPM (10,478 stars, last pushed today), licensed Apache-2.0. It adds 90 tokens to every session and 939 once invoked, about $0.0005 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.

Related

Other skills, from other repositories