본문으로 건너뛰기
Skillpedia
배포 및 클라우드 (DevOps)12k · #11536

minicpm5-deploy-transformers

하는 일

이 스킬은 하나의 Python 스크립트에서 Hugging Face Transformers 라이브러리로 MiniCPM5를 실행하도록 AI를 안내합니다. 서버를 설정하지 않고 빠르게 테스트하려는 사람을 위한 스킬입니다.

사용하는 경우

  • ✓MiniCPM5로 텍스트를 생성하는 짧은 Python 스크립트가 필요할 때.
  • ✓GPU 한 개가 있고 bfloat16으로 모델을 실행하고 싶을 때.
  • ✓GPU가 없어서 CPU에서 모델을 실행해야 하는 경우.

스킬 링크

https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-deploy-transformers/SKILL.md

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

사용 방법

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

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

Use this skill to help me: https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-deploy-transformers/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를 실행해서 질문 하나에 답하는 짧은 Python 스크립트를 작성해 주세요.”

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

작동 방식

이 스킬은 라이브러리를 설치하고, 모델과 토크나이저를 불러오고, 채팅 프롬프트를 만든 뒤, 하나의 스크립트에서 답변을 생성합니다.

기술 내용 (원본 SKILL.md)

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

Deploy MiniCPM5-1B and MiniCPM5-2B with HF Transformers

One-shot Python generation. No server. Works on a single GPU (bfloat16) or CPU only (fp32).

Required input

Var Example Default
MODEL_PATH openbmb/MiniCPM5-2B or local dir required; openbmb/MiniCPM5-1B also works
MODE think or nothink (nothink is 1B-only) think

Steps

1. Install (once)

pip install -U "transformers>=5.6,<6" "torch>=2.11" accelerate     # latest (CUDA 13.x driver hosts)
# pip install -U "transformers==4.57.3" "torch==2.7.1" accelerate  # fallback for CUDA 12.x driver hosts

2. Run

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_path = "${MODEL_PATH}"      # ← replace
tok = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
    model_path,
    torch_dtype=torch.bfloat16,    # CPU users: torch.float32 + device_map="cpu"
    device_map="auto",
).eval()

messages = [{"role": "user", "content": "用一句话解释什么是 GQA。"}]
inputs = tok.apply_chat_template(
    messages,
    add_generation_prompt=True,
    enable_thinking=True,
    return_tensors="pt",
    return_dict=True,
).to(model.device)

with torch.no_grad():
    out = model.generate(
        **inputs,
        max_new_tokens=1024,
        do_sample=True,
        temperature=1.0,
        top_p=0.95,
    )

prompt_len = inputs["input_ids"].shape[-1]
print(tok.decode(out[0][prompt_len:], skip_special_tokens=True))

For CPU only: change torch_dtype=torch.float32, device_map="cpu". Keep enable_thinking=True and temperature=1.0 for MiniCPM5-2B; use enable_thinking=False and temperature=0.7 only for MiniCPM5-1B No-think mode.

Sampling defaults

Mode enable_thinking temperature top_p
MiniCPM5-2B Think True 1.0 0.95
MiniCPM5-1B Think True 0.9 0.95
MiniCPM5-1B No-think False 0.7 0.95

Validate

A coherent answer to 1+1=? (e.g. "2" or "答案是 2").

LoRA inference

from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, "/path/to/adapter").eval()

Adapters from any of the minicpm5-finetune-* skills load directly with no surgery.

When NOT to use

  • Need an OpenAI-compatible HTTP server → minicpm5-deploy-vllm or minicpm5-deploy-sglang
  • Apple Silicon → minicpm5-deploy-mlx is faster
  • CPU-only or low-VRAM laptop → minicpm5-deploy-llama-cpp with Q4_K_M is faster

Reference

docs/deployment/transformers.md

자주 묻는 질문

GPU 없이도 실행할 수 있나요?

네. CPU에서는 float32를 쓰고 장치를 cpu로 설정하라고 이 스킬은 말합니다.

thinking 모드를 지원하나요?

네. enable_thinking 설정이 포함되어 있으며, nothink 모드는 1B 모델에만 해당한다고 설명합니다.

어떤 버전이 필요한가요?

transformers는 5.6 이상 6 미만, torch는 2.11 이상이 필요하다고 이 스킬은 요구합니다.

상세 정보

작성자의 원본 설명

Run MiniCPM5-1B or MiniCPM5-2B with Hugging Face Transformers for one-shot Python generation on GPU (bfloat16) or CPU (float32). Use when the user wants a quick Python script, no server, no extra deps, or asks for "Transformers", "AutoModelForCausalLM", "model.generate" with MiniCPM5.

repo: OpenBMB/MiniCPM

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬