跳到正文
Skillpedia
部署与云(DevOps)12k · #11533

minicpm5-deploy-mlx

它能做什么

这个技能指导你的 AI 使用苹果的 MLX 框架,在 Apple 芯片 Mac 上运行 MiniCPM5。适合希望在自己的机器上获得最快本地运行方式的 Mac 用户。

适用场景

  • ✓你有 M 系列芯片的 Mac,想在本地运行 MiniCPM5 的时候。
  • ✓你想用 mlx_lm 从命令行生成文本的时候。
  • ✓你有一个 Hugging Face 模型,想在 Mac 上将其转换为 MLX 格式的时候。

技能链接

https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-deploy-mlx/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-deploy-mlx/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我用 MLX 在我的 Mac 上运行 MiniCPM5,并检查它对 1+1 是否给出正确答案。”

每周 5 个新技能,1 分钟读完。

工作原理

这个技能安装 mlx-lm 工具,使用现成的 MLX 模型运行测试提示,也可以把你已有的模型转换为 MLX 格式。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Deploy MiniCPM5-1B and MiniCPM5-2B with MLX (Apple Silicon)

Apple's on-device tensor framework. Highest throughput on M-series. Stays inside one Python process — no separate server, no llama.cpp build chain.

Required input

Var Example Default
MLX_REPO openbmb/MiniCPM5-2B-MLX (pre-converted 4-bit affine) required; openbmb/MiniCPM5-1B-MLX also works
OR HF_REPO + QUANT openbmb/MiniCPM5-2B, 4bit or bf16 for local conversion
MAX_TOKENS 200 200

Steps

1. Install (once)

pip install "mlx-lm>=0.31" "gguf"

2A. Use a pre-converted MLX repo (recommended when available)

mlx_lm.generate --model "${MLX_REPO}" \
    --prompt "<|im_start|>user
1+1=?<|im_end|>
<|im_start|>assistant
" \
    --max-tokens ${MAX_TOKENS} --temp 1.0 --top-p 0.95

2B. Convert from a HF checkpoint locally (advanced)

Use mlx_lm.convert only if you have a self-trained HF fp16 checkpoint:

HF=/path/to/your-fp16-hf

# Convert: bf16
mlx_lm.convert --hf-path "$HF" --mlx-path ./minicpm5-mlx-bf16

# Convert: 4-bit (smaller / faster)
mlx_lm.convert --hf-path "$HF" --mlx-path ./minicpm5-mlx-q4 -q --q-bits 4

Then run as in 2A.

3. Validate

The reply should contain "2" for 1+1=?.

OpenAI-compatible server (mlx-lm)

mlx_lm.server --model "${MLX_REPO}" --host 127.0.0.1 --port 8000

curl http://127.0.0.1:8000/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "default",
        "messages": [{"role":"user","content":"1+1=?"}],
        "temperature": 1.0, "top_p": 0.95, "max_tokens": 64
    }'

Common pitfalls

  • Slow first generate: MLX JIT-compiles kernels on first call (~5-10 s); subsequent calls hit the warm cache.
  • Model runs past <|im_end|>: only happens on mlx-lm < 0.31 (older versions ignore multi-id eos_token_id lists). Upgrade, or pass --extra-eos-token "<|im_end|>" as a manual override — <|im_end|> is token id 130073 and is already listed in generation_config.json on 0.31+.

When NOT to use

  • Not on Apple Silicon → minicpm5-deploy-llama-cpp (CPU/CUDA) or minicpm5-deploy-vllm (CUDA)
  • Want a desktop GUI → minicpm5-deploy-lmstudio (LM Studio bundles an MLX runtime)
  • Want one-line CLI run → minicpm5-deploy-ollama

Reference

docs/deployment/mlx.md

常见问题

我需要自己转换模型吗?

通常不需要。如果存在现成的 MLX 仓库,这个技能会推荐使用它。

我怎么知道它是否正常工作?

这个技能说明,对于 1+1 这个问题,回复应包含数字 2。

它可以运行本地服务器吗?

可以。这个技能通过 mlx_lm.server 提供兼容 OpenAI 的服务器。

详情

作者的原始描述

Run MiniCPM5-1B or MiniCPM5-2B natively on Apple Silicon with Apple's MLX framework. Use when the user has an Apple Silicon Mac and asks for "MLX", "mlx_lm", "mlx_lm.convert", "mlx_lm.generate", or wants the fastest path on Apple Silicon.

repo: OpenBMB/MiniCPM

热度

GitHub 星标
12k
排名
#11533
许可证
Apache-2.0
更新时间
2026/9/21

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能