Skills

Minicpm5 Finetune Llamafactory

Fine-tune MiniCPM5-1B or MiniCPM5-2B with LLaMA-Factory (YAML-driven SFT / DPO / WebUI).

Install

npx skills add OpenBMB/MiniCPM --skill minicpm5-finetune-llamafactory -g -a claude-code -y
Repository
OpenBMB/MiniCPM11.8k
Category
Engineering
Updated
1mo ago
License
Apache-2.0
Context cost
Lightabout 1,237 tokens
Runs scripts
No, instructions only

What it does

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.

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

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

Required input

VarExampleDefault
BASE_MODELopenbmb/MiniCPM5-2Brequired; openbmb/MiniCPM5-1B also works
DATA_DIRdir containing dataset_info.json + jsonlrequired
DATASET_NAMEname registered in dataset_info.jsonrequired
OUTPUT_DIR./runs/minicpm5_lfrequired
GPU_ID00

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
Read the whole SKILL.md on GitHub

More in Engineering