मुख्य सामग्री पर जाएँ
Skillpedia
मशीन लर्निंग12k · #11541

minicpm5-finetune-llamafactory

यह क्या करती है

यह स्किल आपके AI को LLaMA-Factory से MiniCPM5 fine-tune करने का मार्गदर्शन देती है, जो config फ़ाइलों से चलने वाला लोकप्रिय training टूल है। यह उन लोगों के लिए है जो मॉडल को अच्छी तरह दस्तावेज़ित, config-आधारित तरीके से प्रशिक्षित करना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब आप LLaMA-Factory या llamafactory-cli से MiniCPM5 fine-tune करना चाहते हैं।
  • ✓जब आप Python कोड लिखने के बजाय YAML config फ़ाइल से प्रशिक्षण करना चाहते हैं।
  • ✓जब आप मॉडल प्रशिक्षित करने के लिए LLaMA-Factory का वेब इंटरफ़ेस इस्तेमाल करना चाहते हैं।

Skill का लिंक

https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-finetune-llamafactory/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-finetune-llamafactory/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरी chat उदाहरण फ़ाइल पर LLaMA-Factory से MiniCPM5-2B fine-tune करने में मदद कीजिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

स्किल LLaMA-Factory को अपने वातावरण में इंस्टॉल करती है, आपका डेटासेट रजिस्टर करती है, YAML training config लिखती है, और training run शुरू करती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Fine-tune MiniCPM5-1B and MiniCPM5-2B with LLaMA-Factory

YAML-driven SFT / DPO with WebUI. Most-documented community framework.

Required input

Var Example Default
BASE_MODEL openbmb/MiniCPM5-2B required; openbmb/MiniCPM5-1B also works
DATA_DIR dir containing dataset_info.json + jsonl required
DATASET_NAME name registered in dataset_info.json required
OUTPUT_DIR ./runs/minicpm5_lf required
GPU_ID 0 0

Steps

1. Install (once, in its own venv to avoid breaking vLLM)

python -m venv .venv-lf && source .venv-lf/bin/activate
# `template: minicpm5` landed after v0.9.5 (the latest PyPI release) — install from source.
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
pip install -e LLaMA-Factory

⚠️ LLaMA-Factory requires transformers>=4.55.0,<=5.8.0 (excluding 4.57.0 and 5.6.0), which can clash with a serving stack such as vLLM. Always install it into its own venv.

2. Register the dataset (sharegpt / messages format)

${DATA_DIR}/dataset_info.json:

{
  "${DATASET_NAME}": {
    "file_name": "your_data.jsonl",
    "formatting": "sharegpt",
    "columns": {"messages": "messages"},
    "tags": {
      "role_tag": "role", "content_tag": "content",
      "user_tag": "user", "assistant_tag": "assistant", "system_tag": "system"
    }
  }
}

Each line of your_data.jsonl:

{"messages": [{"role":"system","content":"..."}, {"role":"user","content":"..."}, {"role":"assistant","content":"..."}]}

3. Write the training YAML

Save as ${OUTPUT_DIR}/lora_sft.yaml:

### model
model_name_or_path: ${BASE_MODEL}
trust_remote_code: false

### method
stage: sft
do_train: true
finetuning_type: lora
lora_rank: 16
lora_alpha: 32
lora_target: all                      # all linear layers

### dataset
dataset: ${DATASET_NAME}
dataset_dir: ${DATA_DIR}
template: minicpm5                    # 🔑 MANDATORY for MiniCPM5 — ChatML + XML tool calling
cutoff_len: 4096
max_samples: 100000
overwrite_cache: true
preprocessing_num_workers: 8

### output
output_dir: ${OUTPUT_DIR}
logging_steps: 10
save_steps: 200
plot_loss: true
overwrite_output_dir: true

### train
per_device_train_batch_size: 4
gradient_accumulation_steps: 4
learning_rate: 2.0e-4
num_train_epochs: 2.0
lr_scheduler_type: cosine
warmup_ratio: 0.03
bf16: true
ddp_timeout: 180000000

🔑 template: minicpm5 is MANDATORY. It reproduces the model's own chat_template.jinja byte-for-byte — ChatML with MiniCPM5-2B Think mode, MiniCPM5-1B Think / No-think modes, plus XML tool calling.

Do NOT use template: empty. LLaMA-Factory does not delegate to the tokenizer's jinja; empty is a genuinely empty template (bare {{content}} slots, no role markers, no EOS replacement, ReAct-style tools) that trains on a layout the model has never seen. llama3 / qwen / etc. are equally wrong. Requires LLaMA-Factory from source — see step 1.

4. Train

CUDA_VISIBLE_DEVICES=${GPU_ID} llamafactory-cli train ${OUTPUT_DIR}/lora_sft.yaml

For multi-GPU: prepend FORCE_TORCHRUN=1 and set NPROC_PER_NODE=8.

5. Validate

Loss should decrease monotonically; you should see lines like:

{'loss': 4.19, 'learning_rate': 0.000192, 'epoch': 0.2}
{'loss': 3.62, 'learning_rate': 0.000001, 'epoch': 1.0}

After training, the LoRA adapter is at ${OUTPUT_DIR}/. Sanity-check inference:

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()
tok = AutoTokenizer.from_pretrained("${BASE_MODEL}")
inputs = tok.apply_chat_template([{"role":"user","content":"1+1=?"}], add_generation_prompt=True, enable_thinking=True, return_tensors="pt", return_dict=True).to(model.device)
print(tok.decode(model.generate(**inputs, max_new_tokens=32, do_sample=False)[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

Coherent answer ⇒ ✅. Gibberish ⇒ check template: minicpm5 in the YAML. (A clean loss curve does not confirm the template is right — a mismatched template trains just as smoothly.)

Merge LoRA for serving

cat > ${OUTPUT_DIR}/merge.yaml <<EOF
model_name_or_path: ${BASE_MODEL}
adapter_name_or_path: ${OUTPUT_DIR}
template: minicpm5
finetuning_type: lora
export_di
अक्सर पूछे जाने वाले सवाल

इसे कौन सा डेटा फ़ॉर्मेट चाहिए?

यह sharegpt या messages फ़ॉर्मेट इस्तेमाल करती है, जहाँ हर पंक्ति में एक बातचीत होती है।

अलग वातावरण क्यों इस्तेमाल करें?

स्किल चेतावनी देती है कि LLaMA-Factory vLLM जैसे serving टूल से टकरा सकता है, इसलिए उसका अपना वातावरण होना चाहिए।

क्या यह DPO भी सपोर्ट करती है?

हाँ। स्किल बताती है कि LLaMA-Factory SFT और DPO दोनों training सपोर्ट करता है।

जानकारी

लेखक का मूल विवरण

Fine-tune MiniCPM5-1B or MiniCPM5-2B with LLaMA-Factory (YAML-driven SFT / DPO / WebUI). Use when the user wants to fine-tune via LLaMA-Factory, llamafactory-cli, mentions YAML configs, WebUI, or asks for the most-documented community framework.

repo: OpenBMB/MiniCPM

लोकप्रियता

GitHub स्टार
12k
रैंकिंग में स्थान
#11541
लाइसेंस
Apache-2.0
अपडेट की गई
21/9/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

minicpm5-deploy-litert

12k

आपके एजेंट को Google के LiteRT-LM रनटाइम से कंप्यूटर या Android फ़ोन पर MiniCPM5 मॉडल चलाने देती है, एक ही मॉडल फ़ाइल के साथ।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

minicpm5-deploy-llama-cpp

12k

आपके एजेंट को दिखाती है कि llama.cpp से CPU या घरेलू graphics card पर MiniCPM5 मॉडल कैसे चलाएँ, तैयार GGUF फ़ाइलों के साथ।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

minicpm5-deploy-lmstudio

12k

आपके एजेंट को LM Studio में MiniCPM5 मॉडल चलाने में मदद करती है, जो चैट विंडो वाला डेस्कटॉप ऐप है, और उसका लोकल OpenAI शैली का server शुरू करती है।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

minicpm5-deploy-mlx

12k

आपके एजेंट को Apple के MLX फ़्रेमवर्क से Apple Silicon Mac पर MiniCPM5 मॉडल सीधे चलाने देती है, तेज़ लोकल चैट और टेक्स्ट जनरेशन के लिए।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

मिलती-जुलती skills