minicpm5-finetune
它能做什么
这个技能根据你的目标和硬件,帮你的 AI 为 MiniCPM5-1B 选择训练框架,然后按照对应的指南操作。适合想训练或调整该模型、但尚未选定工具的人员。
适用场景
- ✓你想微调 MiniCPM5,但还没有选定框架的时候。
- ✓你想知道 LoRA、DPO 或 QLoRA 是否适合你的硬件的时候。
- ✓你让 AI 基于你的数据训练或继续训练 MiniCPM5 的时候。
技能链接
https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-finetune/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想用客户聊天记录微调 MiniCPM5-1B。我们应该使用哪个训练工具?”
每周 5 个新技能,1 分钟读完。
工作原理
这个技能询问基础模型、你的数据、目标和硬件,然后将它们匹配到一个框架指南,并按该指南操作。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Fine-tune MiniCPM5-1B — framework router
You're being asked to fine-tune MiniCPM5-1B. Pick exactly one framework skill below and invoke that skill rather than improvising — every framework has at least one MiniCPM5-specific gotcha that the dedicated skill knows about.
1. Required input from the user
| Variable | Example | Notes |
|---|---|---|
BASE_MODEL |
HF id openbmb/MiniCPM5-1B (post-release) or a local path |
see cluster paths below |
DATA |
path to JSONL in messages format | [{"messages": [{"role":"user","content":"..."}, {"role":"assistant","content":"..."}]}] |
OUTPUT_DIR |
where to write checkpoints | mkdir if missing |
| Goal | "LoRA SFT" / "full SFT" / "DPO" / "QLoRA on consumer GPU" / "continue-pretrain at scale" | drives skill choice |
| Hardware | 1× GPU / multi-node | drives skill choice |
Default base model
If BASE_MODEL is not pinned, default to the Hugging Face fp16 release:
openbmb/MiniCPM5-1B
Any local directory containing config.json + model.safetensors + tokenizer.json also works.
2. Decision matrix — pick exactly one
| User says / wants | Best fit | → Skill to invoke |
|---|---|---|
| YAML / WebUI driven SFT, broad community support | LLaMA-Factory | minicpm5-finetune-llamafactory |
| ChatML template + ModelScope-native SFT/DPO/KTO/ORPO | ms-swift | minicpm5-finetune-ms-swift |
| Bare-metal Python, assistant-only loss, minimal abstractions | TRL + PEFT | minicpm5-finetune-trl |
| Single-GPU LoRA / QLoRA, tight VRAM (24 GB or less) | unsloth | minicpm5-finetune-unsloth |
| mmengine config-driven SFT, OpenMMLab stack | xtuner | minicpm5-finetune-xtuner |
Decision shortcuts
- First time fine-tuning MiniCPM5: pick
minicpm5-finetune-llamafactory— most documented, fewest surprises. - Need DPO / KTO / ORPO: pick
minicpm5-finetune-ms-swift(best out-of-the-box) orminicpm5-finetune-trl(most control). - Single 24 GB consumer GPU: pick
minicpm5-finetune-unslothwithload_in_4bit=True. - Target is llama.cpp / Ollama / LM Studio / MiniCPM Desk Pet (GGUF): train with any skill above, then convert the adapter with
minicpm5-finetune-gguf-lora(PEFT adapter → GGUF LoRA).
3. Invocation contract
Each sub-skill expects BASE_MODEL, DATA, OUTPUT_DIR and outputs an LoRA adapter (or full checkpoint) at OUTPUT_DIR/. Read the picked sub-skill in full before running — every framework has at least one MiniCPM5-specific gotcha:
| Framework | Gotcha (skill handles it for you) |
|---|---|
| LLaMA-Factory | template: minicpm5 (needs LLaMA-Factory from source; NOT template: empty / llama3) |
| ms-swift | mandatory --model_type llama --template chatml flags |
| TRL | training-only chat template patch for assistant_only_loss=True |
| unsloth | transformers==4.57.3 pin if vLLM is in the same env |
| xtuner | prompt_template=PROMPT_TEMPLATE.qwen_chat (ChatML), use openai_map_fn for messages-format data, start_factor ≥ 1e-2 |
4. Universal sanity check after training
Regardless of framework:
# 1. Verify adapter (or full ckpt) was saved
ls "$OUTPUT_DIR" # adapter_model.safetensors + adapter_config.json (LoRA) OR a full HF directory
# 2. Quick inference check (HF-side, works for both LoRA and full)
python -c "
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained('$BASE_MODEL', torch_dtype=torch.bfloat16, device_map='auto').eval()
model = PeftModel.from_pretrained(base, '$OUTPUT_DIR').eval() # skip this line for full SFT
tok = AutoTokenizer.from_pretrained('$BASE_MODEL')
inputs = tok.apply_chat_template([{'role':'user','content':'1+1=?'}], add_generation_prompt=True, enable_thinking=False, return_tensors='pt').to(model.device)
out = model.generate(inputs, max_new_tokens=32, do_sample=False)
print(tok.decode(out[0][inputs.shape[-1]:], skip_special_tokens=True))
"
Expected: a coherent answer (e.g. "2"). If it's gibberish or empty, training broke (most likely chat template misalignment — ⮕ check the framework's gotcha row above).
5. Don't reinvent: link to the cookbook
Each sub-skill is paired with a one-page cookbook in docs/finetune/. The skill is the machine-readable shortcut; the cookbook is the human-readable reference.
6. Next step — deploying the adapter
The adapter at `OUTPUT_D
常见问题
默认使用哪个基础模型?
如果你没有指定,这个技能使用 Hugging Face 上的 openbmb/MiniCPM5-1B 版本。
需要哪种数据格式?
这个技能需要 JSONL 文件,每行保存一个 messages 列表。
它会选择多个框架吗?
不会。这个技能设置为每个请求只选择一个框架指南。
详情
作者的原始描述
Pick the right fine-tuning framework for a MiniCPM5-1B base checkpoint and route to a framework-specific cookbook skill. Use when the user wants to SFT / LoRA / DPO / continue-pretrain MiniCPM5 and has not yet committed to a specific framework, or when they say "fine-tune MiniCPM5", "train MiniCPM5", "MiniCPM5 微调", "LoRA MiniCPM5", "继续训练 MiniCPM5".
repo: OpenBMB/MiniCPM
热度
- GitHub 星标
- 12k
- 排名
- #11546
- 许可证
- Apache-2.0
- 更新时间
- 2026/9/21
评论
- …
同一仓库的更多技能
minicpm5-deploy-litert
12k帮你的智能体使用谷歌的 LiteRT-LM 运行时,在电脑或 Android 手机上运行 MiniCPM5 模型,只需一个模型文件。
minicpm5-deploy-llama-cpp
12k向你的智能体展示如何使用 llama.cpp,借助现成的 GGUF 文件,在 CPU 或家用显卡上运行 MiniCPM5 模型。
minicpm5-deploy-lmstudio
12k帮你的智能体在 LM Studio 中运行 MiniCPM5 模型,这是一款带聊天窗口的桌面应用,并启动其本地 OpenAI 风格服务器。
minicpm5-deploy-mlx
12k帮你的智能体使用苹果的 MLX 框架,在 Apple 芯片 Mac 上原生运行 MiniCPM5 模型,实现快速的本地聊天和文本生成。