본문으로 건너뛰기
Skillpedia
머신러닝12k · #11540

minicpm5-finetune-gguf-lora

하는 일

이 스킬은 MiniCPM5-1B용 LoRA 어댑터를 만들고 GGUF 형식으로 변환하도록 AI를 안내합니다. MiniCPM5를 GGUF 모델로 실행하며 맞춤형 버전을 원하는 사람을 위한 스킬입니다.

사용하는 경우

  • ✓학습된 LoRA 어댑터가 있고 이를 llama-server에 불러오고 싶을 때.
  • ✓convert_lora_to_gguf 스크립트로 LoRA 어댑터를 변환하고 싶을 때.
  • ✓MiniCPM Desk Pet 앱에 맞춤형 페르소나나 스킨을 업로드하고 싶은 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-finetune-gguf-lora/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“학습한 MiniCPM5-1B용 LoRA 어댑터를 llama-server가 불러올 수 있는 GGUF 파일로 바꿔 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 어댑터가 기본 모델과 맞는지 확인하고, llama.cpp 변환 스크립트로 어댑터 파일을 GGUF로 바꾸고, 실행할 때 불러오는 방법을 보여 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

자주 묻는 질문

기본 모델이 일치해야 하나요?

네. 이 스킬은 어댑터가 변환 기준으로 삼는 것과 같은 기본 모델에서 나와야 한다고 말합니다.

어댑터를 먼저 학습해야 하나요?

네. 이 스킬은 다른 MiniCPM5 미세 조정 스킬로 만든 PEFT 어댑터에서 시작합니다.

어댑터는 어디에서 불러오나요?

llama-server의 lora 옵션으로 불러오거나, MiniCPM Desk Pet 앱에 업로드할 수 있습니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
12k
순위
#11540
라이선스
Apache-2.0
업데이트
2026. 9. 21.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬