Chuyển đến nội dung
Skillpedia
Học máy12k · #11540

minicpm5-finetune-gguf-lora

Skill này làm gì

Skill này hướng dẫn AI tạo một adapter LoRA cho MiniCPM5-1B và chuyển nó sang định dạng GGUF. Skill dành cho người chạy MiniCPM5 dưới dạng GGUF và muốn một phiên bản tùy chỉnh.

Khi nào nên dùng

  • ✓Khi bạn đã có một adapter LoRA đã huấn luyện và muốn tải nó vào llama-server.
  • ✓Khi bạn muốn chuyển một adapter LoRA bằng script convert_lora_to_gguf.
  • ✓Khi bạn muốn tải một persona hoặc giao diện tùy chỉnh lên ứng dụng MiniCPM Desk Pet.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-finetune-gguf-lora/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Chuyển adapter LoRA đã huấn luyện cho MiniCPM5-1B của tôi thành file GGUF mà llama-server có thể tải.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill kiểm tra adapter có khớp với model gốc không, chuyển các file adapter sang GGUF bằng script chuyển đổi của llama.cpp, và chỉ cách tải nó khi chạy.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Fine-tune MiniCPM5-1B → GGUF LoRA adapter

The framework skills (minicpm5-finetune-*) all emit a PEFT adapter (adapter_model.safetensors + adapter_config.json). But llama.cpp / llama-server — and the MiniCPM Desk Pet app's custom-LoRA upload — load a GGUF LoRA adapter (--lora some-adapter.gguf). This skill is the bridge: train a PEFT LoRA, then convert it to GGUF and run/upload it.

This is the path you want when the base model is served as GGUF (Desk Pet, Ollama, LM Studio, plain llama-server). If you serve the fp16 HF base with vLLM / transformers, you don't need GGUF — load the PEFT adapter directly.

Pipeline overview

  train (any minicpm5-finetune-* skill)        this skill
 ┌────────────────────────────────────┐   ┌──────────────────────────────────┐
 BASE (fp16 HF) ─► adapter_model.safetensors ─► convert_lora_to_gguf.py ─► adapter.gguf
                   adapter_config.json                                          │
                                                                  llama-server --lora / Desk Pet upload

Required input

Var Example Default
ADAPTER_DIR ./runs/minicpm5_unsloth/adapter_final required — a PEFT dir with adapter_config.json + adapter_model.safetensors
BASE_MODEL openbmb/MiniCPM5-1B (HF id) or a local fp16 HF dir required — must be the same base the adapter was trained on
OUTTYPE f16 (recommended) / q8_0 / bf16 / f32 f16
OUT_GGUF ./minicpm5-mylora.gguf <ADAPTER_DIR>/adapter_model.f16.gguf

Don't have an adapter yet? First run a training skill — start from the router minicpm5-finetune (or go straight to minicpm5-finetune-unsloth for single-GPU LoRA). Come back here with ADAPTER_DIR pointing at its output.

Steps

1. Get llama.cpp (has the converter)

git clone --depth=1 https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
pip install -r requirements.txt          # converter deps: torch, safetensors, gguf, transformers

convert_lora_to_gguf.py lives at the repo root. You only need the Python script for conversion; build the C++ binaries (step 4) only if you want to test locally.

2. Convert the PEFT adapter → GGUF

python convert_lora_to_gguf.py "$ADAPTER_DIR" \
    --base "$BASE_MODEL" \
    --outtype f16 \
    --outfile "$OUT_GGUF"
  • --base only needs the base model's config (config.json, tokenizer.json) — not the weights. A local fp16 HF dir or an HF id both work.
  • If the base is only on the Hub, use --base-model-id openbmb/MiniCPM5-1B instead of --base (it pulls just the config).
  • Output is a single .gguf of roughly the same size as the input .safetensors (a 22 MB r=16 adapter → ~22 MB GGUF).

🔑 The #1 gotcha — base_model_name_or_path points at the training machine. PEFT writes the absolute path of the base used during training into adapter_config.json (e.g. /user/.../MiniCPM5-models-fixed/official). On any other machine the converter can't find it. Always pass --base (or --base-model-id) explicitly to override it — don't rely on whatever is baked into the config. The base you pass MUST match the one you trained on, or the adapter math is meaningless.

3. (Optional) Sanity-check the GGUF metadata

python -c "import gguf,sys; r=gguf.GGUFReader('$OUT_GGUF'); print('tensors:', len(r.tensors)); print('arch:', r.get_field('general.architecture').parts[-1].tobytes().decode() if r.get_field('general.architecture') else '?')"

Expect general.type = adapter and a nonzero tensor count. MiniCPM5-1B is a Llama-architecture model, so the converter treats it as llama — this is correct, not an error.

4. Test with llama-server before shipping

You need a GGUF base model too (the adapter is applied on top of it). Grab the released base:

huggingface-cli download openbmb/MiniCPM5-1B-GGUF MiniCPM5-1B-Q8_0.gguf --local-dir .

Then:

# CLI
llama-cli -m MiniCPM5-1B-Q8_0.gguf --lora "$OUT_GGUF" \
    -p "你好" -n 128 --temp 0.7 --top-p 0.95

# OpenAI-compatible server
llama-server -m MiniCPM5-1B-Q8_0.gguf --lora "$OUT_GGUF" --port 8080 --jinja

If the persona/behavior you trained shows up, the GGUF is good. If output is identical to the base, the adapter didn't load (check the --lora path and that --base matched in step 2).

Quant compatibility: a GGUF LoRA built from an fp16 adapter applies

Câu hỏi thường gặp

Model gốc có cần khớp không?

Có. Skill nói adapter phải đến từ cùng một model gốc mà bạn chuyển đổi.

Tôi có cần huấn luyện adapter trước không?

Có. Skill bắt đầu từ một adapter PEFT được tạo bởi một trong các skill fine-tune MiniCPM5 khác.

Adapter được tải ở đâu?

Có thể tải bằng tùy chọn lora của llama-server, hoặc tải lên ứng dụng MiniCPM Desk Pet.

Chi tiết

Mô tả gốc của tác giả

Fine-tune MiniCPM5-1B into a LoRA adapter and convert it to a GGUF adapter that loads directly into llama.cpp / llama-server and the MiniCPM Desk Pet app's custom-LoRA upload. Use when the user wants "GGUF LoRA", "convert LoRA to GGUF", "convert_lora_to_gguf", a custom persona/skin for the desktop pet, "桌宠自定义 LoRA", "上传 LoRA 到桌宠", or asks how to take a trained adapter and run it on a GGUF base.

repo: OpenBMB/MiniCPM

Độ phổ biến

Sao GitHub
12k
Vị trí xếp hạng
#11540
Giấy phép
Apache-2.0
Cập nhật
21/9/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự