minicpm5-finetune-ms-swift
यह क्या करती है
यह स्किल आपके AI को ms-swift टूलकिट से MiniCPM5 प्रशिक्षित करने का मार्गदर्शन देती है। यह उन लोगों के लिए है जो fine-tuning या preference training चलाने के लिए swift कमांड इस्तेमाल करना चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप MiniCPM5 मॉडल पर swift sft या swift rlhf चलाना चाहते हैं।
- ✓जब आप MiniCPM5-2B को प्रशिक्षित कर रहे हैं और उसका खास ms-swift संस्करण व template चाहिए।
- ✓जब आप प्रशिक्षण के लिए Megatron-SWIFT इस्तेमाल करना चाहते हैं।
Skill का लिंक
https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-finetune-ms-swift/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी messages फ़ाइल पर ms-swift से LoRA के साथ MiniCPM5-1B प्रशिक्षित कीजिए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
स्किल आपके मॉडल के लिए सही ms-swift संस्करण और template चुनती है, उसे इंस्टॉल करती है, और swift कमांड से LoRA प्रशिक्षण शुरू करती है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Fine-tune MiniCPM5-1B and MiniCPM5-2B with ms-swift
Select the version and template that match the model:
| Model | ms-swift version | Arguments |
|---|---|---|
| MiniCPM5-1B | PyPI 4.5.3 |
--model_type llama --template minicpm5 |
| MiniCPM5-2B | >=4.6.0.dev0 |
--model_type llama --template minicpm5_2b |
Both models require transformers>=5.6.
ms-swift 4.x renamed
--train_typeto--tuner_type. Use--tuner_type lorafor LoRA training.
Required input
| Var | Example | Default |
|---|---|---|
BASE_MODEL |
openbmb/MiniCPM5-2B |
required; openbmb/MiniCPM5-1B is also supported |
TEMPLATE |
minicpm5_2b |
use minicpm5 for MiniCPM5-1B |
DATA |
path to messages-format jsonl | required |
OUTPUT_DIR |
./runs/minicpm5_swift |
required |
GPU_ID |
0 |
0 |
Each line of DATA: {"messages": [{"role":"...","content":"..."}, ...]}.
Steps
1. Install (once)
For MiniCPM5-1B:
pip install "ms-swift==4.5.3" "transformers>=5.6"
For MiniCPM5-2B:
git clone https://github.com/modelscope/ms-swift.git
cd ms-swift
git checkout 654e24f17b5d9f40ed4b9ee4c56a723320244db5
pip install -e .
pip install "transformers>=5.6,<5.17"
For Megatron-SWIFT:
pip install mcore-bridge==1.6.4
2. Train (LoRA SFT)
CUDA_VISIBLE_DEVICES=${GPU_ID} swift sft \
--model "${BASE_MODEL}" \
--model_type llama \
--template "${TEMPLATE}" \
--tuner_type lora \
--dataset "${DATA}" \
--output_dir "${OUTPUT_DIR}" \
--num_train_epochs 2 \
--per_device_train_batch_size 4 \
--gradient_accumulation_steps 4 \
--learning_rate 2e-4 \
--lora_rank 16 --lora_alpha 32 --lora_dropout 0.05 \
--target_modules q_proj k_proj v_proj o_proj gate_proj up_proj down_proj \
--max_length 4096 \
--warmup_ratio 0.03 \
--bf16 true \
--logging_steps 10 \
--save_steps 200
Set TEMPLATE=minicpm5 for MiniCPM5-1B or TEMPLATE=minicpm5_2b for MiniCPM5-2B.
3. Validate
Loss should decrease over the first few hundred steps:
{'loss': 4.52, 'token_acc': 0.26, 'epoch': 0.04}
{'loss': 3.57, 'token_acc': 0.35, 'epoch': 1.00}
Adapter is at ${OUTPUT_DIR}/v0-${TIMESTAMP}/checkpoint-${STEP}/.
Merge for serving
swift export \
--model "${BASE_MODEL}" \
--adapters "${OUTPUT_DIR}/v0-${TIMESTAMP}/checkpoint-${STEP}" \
--merge_lora true \
--output_dir ./minicpm5-swift-merged
The merged model is a regular LlamaForCausalLM and serves with any minicpm5-deploy-* skill.
Full SFT / DPO / RLHF
Same flag surface, just swap the trainer:
# Full SFT
swift sft --tuner_type full ...
# DPO
swift rlhf --rlhf_type dpo \
--model "${BASE_MODEL}" --model_type llama --template "${TEMPLATE}" \
--dataset preference.jsonl \
--output_dir ${OUTPUT_DIR} ...
# Megatron-SWIFT SFT
megatron sft \
--model "${BASE_MODEL}" \
--model_type llama \
--template "${TEMPLATE}" \
--dataset "${DATA}" \
--finetune true \
--output_dir "${OUTPUT_DIR}"
Set TEMPLATE=minicpm5 for MiniCPM5-1B or TEMPLATE=minicpm5_2b for MiniCPM5-2B.
For complete training options and configuration details, see the ms-swift command-line parameters and the Megatron-SWIFT quick start.
Multi-GPU
NPROC_PER_NODE=8 swift sft \
--model "${BASE_MODEL}" --model_type llama --template "${TEMPLATE}" \
--tuner_type lora --deepspeed default-zero2 \
...
Common pitfalls
Failed to automatically match model_type: add--model_type llama.Failed to automatically match template_type: use--template minicpm5for MiniCPM5-1B or--template minicpm5_2bfor MiniCPM5-2B.minicpm5_2b is not registered: the active Python environment is using an older ms-swift release. Installms-swift>=4.6.0.dev0; the source installation above pins a known revision for reproducibility.- Conflict with LLaMA-Factory in same env: LLaMA-Factory pins
transformers==4.52, ms-swift wants the latest (currently transformers ≥5.6). Use separate venvs, or setPYTHONNOUSERSITE=1to ignore user-sitetransformers.
Reference
अक्सर पूछे जाने वाले सवाल
कौन सा template किस मॉडल के साथ जाता है?
स्किल MiniCPM5-1B के लिए minicpm5 template, और MiniCPM5-2B के लिए minicpm5_2b template इस्तेमाल करती है।
आर्गुमेंट में क्या बदला है?
स्किल बताती है कि ms-swift 4.x में --tuner_type lora इस्तेमाल होता है, जहाँ पुराने संस्करण --train_type इस्तेमाल करते थे।
कौन सा डेटा फ़ॉर्मेट इस्तेमाल होता है?
हर पंक्ति में role और content फ़ील्ड वाली messages सूची होती है।
जानकारी
लेखक का मूल विवरण
Fine-tune MiniCPM5-1B or MiniCPM5-2B with ms-swift or Megatron-SWIFT. Use when the user mentions "ms-swift", "swift sft", "swift rlhf", or "megatron sft". MiniCPM5-1B uses the PyPI release with `--template minicpm5`; MiniCPM5-2B requires `ms-swift>=4.6.0.dev0` with `--template minicpm5_2b`. Both use `--model_type llama`.
repo: OpenBMB/MiniCPM
लोकप्रियता
- GitHub स्टार
- 12k
- रैंकिंग में स्थान
- #11542
- लाइसेंस
- Apache-2.0
- अपडेट की गई
- 21/9/2026
कमेंट
- …
इस repository की और skills
minicpm5-deploy-litert
12kआपके एजेंट को Google के LiteRT-LM रनटाइम से कंप्यूटर या Android फ़ोन पर MiniCPM5 मॉडल चलाने देती है, एक ही मॉडल फ़ाइल के साथ।
minicpm5-deploy-llama-cpp
12kआपके एजेंट को दिखाती है कि llama.cpp से CPU या घरेलू graphics card पर MiniCPM5 मॉडल कैसे चलाएँ, तैयार GGUF फ़ाइलों के साथ।
minicpm5-deploy-lmstudio
12kआपके एजेंट को LM Studio में MiniCPM5 मॉडल चलाने में मदद करती है, जो चैट विंडो वाला डेस्कटॉप ऐप है, और उसका लोकल OpenAI शैली का server शुरू करती है।
minicpm5-deploy-mlx
12kआपके एजेंट को Apple के MLX फ़्रेमवर्क से Apple Silicon Mac पर MiniCPM5 मॉडल सीधे चलाने देती है, तेज़ लोकल चैट और टेक्स्ट जनरेशन के लिए।
मिलती-जुलती skills
pytorch-patterns
280kआपके एजेंट को machine learning models के लिए PyTorch इस्तेमाल करने में मदद करता है। कुशल model training के best practices लागू करता है और नतीजों को दोहराने लायक रखता है।
evm-token-decimals
280kयह आपके एजेंट को अलग-अलग blockchain networks पर decimal numbers की गलतियों से बचने में मदद करता है। यह transactions और calculations में token values सही रखने का ध्यान रखता है।
ito-inference
280kआपके एजेंट को AI models की उपलब्धता जाँचने देता है। यह compute request को तैयार model service से जोड़ता है।