Text Generation
Transformers
Safetensors
llama
minicpm
compressed-tensors
vllm
quantized
fp8
conversational
text-generation-inference
Instructions to use axteam/MiniCPM5-2B-FP8-dynamic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use axteam/MiniCPM5-2B-FP8-dynamic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="axteam/MiniCPM5-2B-FP8-dynamic") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("axteam/MiniCPM5-2B-FP8-dynamic") model = AutoModelForCausalLM.from_pretrained("axteam/MiniCPM5-2B-FP8-dynamic", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use axteam/MiniCPM5-2B-FP8-dynamic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "axteam/MiniCPM5-2B-FP8-dynamic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "axteam/MiniCPM5-2B-FP8-dynamic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/axteam/MiniCPM5-2B-FP8-dynamic
- SGLang
How to use axteam/MiniCPM5-2B-FP8-dynamic with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "axteam/MiniCPM5-2B-FP8-dynamic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "axteam/MiniCPM5-2B-FP8-dynamic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "axteam/MiniCPM5-2B-FP8-dynamic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "axteam/MiniCPM5-2B-FP8-dynamic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use axteam/MiniCPM5-2B-FP8-dynamic with Docker Model Runner:
docker model run hf.co/axteam/MiniCPM5-2B-FP8-dynamic
|
Download README.md from axteam/MiniCPM5-2B-FP8-dynamic: direct link, hf CLI and curl.
- Browser
- Download file 10.7 kB
-
https://huggingface.co/axteam/MiniCPM5-2B-FP8-dynamic/resolve/main/README.md
- Command line
-
hf download hf://axteam/MiniCPM5-2B-FP8-dynamic/README.md
-
curl -L -o README.md https://huggingface.co/axteam/MiniCPM5-2B-FP8-dynamic/resolve/main/README.md
10.7 kB
| base_model: openbmb/MiniCPM5-2B | |
| base_model_relation: quantized | |
| library_name: transformers | |
| license: apache-2.0 | |
| pipeline_tag: text-generation | |
| tags: | |
| - minicpm | |
| - compressed-tensors | |
| - vllm | |
| - quantized | |
| - fp8 | |
| # MiniCPM5-2B ยท FP8 (dynamic) | |
| 8-bit quantization of [`openbmb/MiniCPM5-2B`](https://huggingface.co/openbmb/MiniCPM5-2B) for **vLLM serving**. Quantized by **axteam**. | |
| | | | | |
| |---|---| | |
| | **Base model** | [`openbmb/MiniCPM5-2B`](https://huggingface.co/openbmb/MiniCPM5-2B) | | |
| | **Method** | FP8 (dynamic) | | |
| | **Format** | compressed-tensors `float-quantized` (scheme `FP8_DYNAMIC`) | | |
| | **Weights / activations** | W8A8 โ FP8 E4M3 weights (per-channel), dynamic per-token FP8 activations | | |
| | **Architecture** | Dense (Llama-architecture) ยท text-only | | |
| | **Size on disk** | ~3.1 GB | | |
| | **Calibration** | None (data-free) | | |
| | **License** | Apache-2.0 | | |
| ## Quantization details | |
| - **Scheme** โ W8A8 โ FP8 E4M3 weights (per-channel), dynamic per-token FP8 activations, stored as compressed-tensors `float-quantized` (scheme `FP8_DYNAMIC`). | |
| - **Kept in BF16** โ token embeddings, the LM head, and all RMSNorms (about 21% of all parameters in this build). | |
| - Post-training quantization (no retraining). Tokenizer / `chat_template` identical to the original. | |
| ## Benchmarks (measured) | |
| Every column was measured with the same harness and settings โ [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) on vLLM, greedy, completion-style prompts without a chat template (0- or 5-shot, as listed in each row). MMLU here is lm-eval's generative variant (`mmlu_generative`: the model writes the answer letter and only an exact match on the first line counts), so it is not directly comparable with MMLU scores measured another way (e.g. log-likelihood scoring). Percentages are recovery vs. the BF16 original. | |
| | Benchmark | BF16 (original) | **FP8-dynamic (this repo)** | AWQ-8bit | NVFP4A16 | NVFP4 | AWQ-4bit | | |
| |---|---|---|---|---|---|---| | |
| | MMLU (5-shot, generative) | 59.74 | **59.56 (99.7%)** | 59.86 (100.2%) | 56.81 (95.1%) | 53.50 (89.5%) | 56.31 (94.3%) | | |
| | GSM8K (5-shot, strict) | 73.01 | **71.27 (97.6%)** | 73.01 (100.0%) | 65.20 (89.3%) | 55.04 (75.4%) | 65.96 (90.3%) | | |
| | ARC-Challenge (0-shot) | 43.94 | **44.20 (100.6%)** | 43.86 (99.8%) | 43.43 (98.8%) | 40.10 (91.3%) | 44.88 (102.1%) | | |
| | Winogrande (5-shot) | 64.40 | **63.22 (98.2%)** | 64.40 (100.0%) | 62.75 (97.4%) | 59.04 (91.7%) | 62.12 (96.4%) | | |
| | KMMLU (5-shot, direct) | 37.65 | **38.38 (101.9%)** | 38.27 (101.7%) | 35.56 (94.4%) | 34.06 (90.5%) | 30.73 (81.6%) | | |
| | HAE-RAE (0-shot) | 39.05 | **38.13 (97.7%)** | 39.14 (100.2%) | 35.38 (90.6%) | 30.16 (77.2%) | 36.94 (94.6%) | | |
| | **Average** | **52.97** | **52.46 (99.0%)** | **53.09 (100.2%)** | **49.85 (94.1%)** | **45.32 (85.6%)** | **49.49 (93.4%)** | | |
| ## Evaluation (measured) | |
| Fidelity to the BF16 original on an internal mixed EN/KO set (100 prompts, BF16 greedy answers scored under each build). | |
| | Metric | This model | BF16 original | | |
| |---|---|---| | |
| | Perplexity (lower = closer) | 1.6494 | 1.5988 (**+3.2%**) | | |
| | Top-1 next-token agreement | 92.9% | 98.9% | | |
| ## Requirements | |
| | | | | |
| |---|---| | |
| | **Runtime** | vLLM โ the architecture is in vLLM; **tested here with vLLM 0.32.0**. | | |
| | **vLLM install** | vLLM 0.32 itself needs Python 3.11โ3.14, torch 2.13 (CUDA 13.0 build, so an NVIDIA driver with CUDA 13 support), transformers โฅ5.16.1,<5.20 and compressed-tensors 0.17.0 (both pinned by vLLM; 0.17.0 reads this checkpoint, which was saved with 0.19.0 โ do not upgrade it separately). | | |
| | **GPU** | NVIDIA Turing (sm75, e.g. T4) or newer. FP8 math runs on Ada / Hopper / Blackwell (sm89+); on Turing and Ampere vLLM switches to weight-only FP8 automatically. V100 (sm70) is not supported. (Kernel choice per GPU from vLLM 0.32's selection code; only B200 was run here.) | | |
| | **Memory** | Weights: **3.1 GB**. Add KV cache (grows with context length ร concurrent requests) and a few GB for activations / CUDA graphs; use `--tensor-parallel-size N` when the weights do not fit one GPU. | | |
| | **Transformers (without vLLM)** | `transformers>=4.56.0` + `compressed-tensors>=0.15.0` (checked 4.56.2 / 4.57.6 with FP8, AWQ-4bit and NVFP4A16, and 4.56.0 with AWQ-4bit; on transformers 4.x the tokenizer also returns `token_type_ids`, which the model does not accept, so drop it from the tokenizer output before calling `generate`, as these checks did). | | |
| | **trust_remote_code** | not needed | | |
| ## Usage (vLLM) | |
| Start an OpenAI-compatible server: | |
| ```bash | |
| vllm serve axteam/MiniCPM5-2B-FP8-dynamic --max-model-len 32768 | |
| ``` | |
| Query it: | |
| ```bash | |
| curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{ | |
| "model": "axteam/MiniCPM5-2B-FP8-dynamic", | |
| "messages": [{"role": "user", "content": "๋ํ๋ฏผ๊ตญ์ ์๋๋ ์ด๋์ธ๊ฐ์?"}], | |
| "temperature": 1.0, "top_p": 0.95, "max_tokens": 512 | |
| }' | |
| ``` | |
| Offline inference in Python: | |
| ```python | |
| from vllm import LLM, SamplingParams | |
| llm = LLM(model="axteam/MiniCPM5-2B-FP8-dynamic", max_model_len=32768) | |
| params = SamplingParams(temperature=1.0, top_p=0.95, max_tokens=1024) | |
| out = llm.chat([{"role": "user", "content": "Explain model quantization in two sentences."}], params) | |
| print(out[0].outputs[0].text) | |
| ``` | |
| > Recommended sampling (from the original `generation_config.json`): `temperature=1.0`, `top_p=0.95`. | |
| > Thinking mode is on by default in the chat template; to turn it off pass `chat_template_kwargs={"enable_thinking": False}` (Python `llm.chat(..., chat_template_kwargs=...)`, or `"chat_template_kwargs": {"enable_thinking": false}` in the request body). | |
| ## Reducing KV-cache memory (optional, serve-time) | |
| The KV cache is kept in BF16 by default. KV-cache precision is a **runtime** choice, independent of the | |
| weight quantization above; for long contexts or large batches FP8 roughly halves KV-cache memory: | |
| ```bash | |
| vllm serve axteam/MiniCPM5-2B-FP8-dynamic --kv-cache-dtype fp8 | |
| ``` | |
| ## License | |
| Quantized derivative of [`openbmb/MiniCPM5-2B`](https://huggingface.co/openbmb/MiniCPM5-2B) (Apache-2.0). Original weights & tokenizer belong to OpenBMB. | |
| --- | |
| ## ํ๊ตญ์ด ์์ฝ | |
| **[`openbmb/MiniCPM5-2B`](https://huggingface.co/openbmb/MiniCPM5-2B)์ FP8 (W8A8) ์์ํ ๋น๋** ยท ์ ์ axteam | |
| ### ๊ฐ์ | |
| | ํญ๋ชฉ | ๋ด์ฉ | | |
| |---|---| | |
| | ์๋ณธ ๋ชจ๋ธ | [`openbmb/MiniCPM5-2B`](https://huggingface.co/openbmb/MiniCPM5-2B) | | |
| | ์์ํ ๋ฐฉ์ | FP8 ๋์ ์์ํ (W8A8) | | |
| | ์ ์ฅ ํ์ | compressed-tensors `float-quantized` (scheme `FP8_DYNAMIC`) | | |
| | ๋ชจ๋ธ ๊ตฌ์กฐ | Dense (Llama ๊ตฌ์กฐ) ยท ํ ์คํธ ์ ์ฉ | | |
| | ์ฉ๋ | ์ฝ 3.1 GB | | |
| | ๋ณด์ ๋ฐ์ดํฐ | ์์ (๊ฐ์ค์น ์ค์ผ์ผ์ ๊ฐ์ค์น๋ง์ผ๋ก ๊ณ์ฐ, ํ์ฑํ ์ค์ผ์ผ์ ์คํ ์ ๊ณ์ฐ) | | |
| ### ์์ํ ์์ธ | |
| - **๊ฐ์ค์น**: FP8(E4M3), ์ถ๋ ฅ ์ฑ๋๋ณ ์ค์ผ์ผ | |
| - **ํ์ฑํ**: ์คํ ์ ํ ํฐ๋ณ ๋์ FP8 | |
| - **์์ํ ์ ์ฐจ**: PTQ(ํ์ต ํ ์์ํ, ์ฌํ์ต ์์), ๊ฐ์ค์น ์ค์ผ์ผ์ ๋ฏธ๋ฆฌ ๊ณ์ฐํ๊ณ ํ์ฑํ ์ค์ผ์ผ์ ์คํ ์ ํ ํฐ๋ง๋ค ๊ณ์ฐ | |
| - **BF16 ์ ์ง**: ํ ํฐ ์๋ฒ ๋ฉ, LM ํค๋, ๋ชจ๋ RMSNorm โ ์ ์ฒด ํ๋ผ๋ฏธํฐ์ ์ฝ 21% | |
| - **์๋ณธ ํ์ผ**: ํ ํฌ๋์ด์ ยทchat template์ ์๋ณธ๊ณผ ๋์ผ | |
| ### ํ์ง (์ค์ธก) | |
| - **์๋ณธ ๋๋น ์ถฉ์ค๋**: PPL 1.6494 (์๋ณธ 1.5988, +3.2%, ๋ฎ์์๋ก ์๋ณธ์ ๊ฐ๊น์), ๋ค์ ํ ํฐ top-1 ์ผ์น์จ 92.9% (์๋ณธ ์์ฒด ๊ธฐ์ค๊ฐ 98.9%) โ ๋ด๋ถ ์์ดยทํ๊ตญ์ด ํผํฉ ํ๋กฌํํธ 100๊ฐ, ์๋ณธ(BF16)์ greedy ๋ต๋ณ์ ๊ธฐ์ค ํ ์คํธ๋ก ์ธก์ | |
| - **๋ฒค์น๋งํฌ ํ๊ท **: 52.46 (์๋ณธ 52.97, 99.0%) โ MMLU(์์ฑํ)ยทGSM8KยทARC-ChallengeยทWinograndeยทKMMLUยทHAE-RAE 6์ข ํ๊ท , lm-evaluation-harness + vLLM, chat template ์๋ ์์ฑํ ํ๋กฌํํธ(๊ณผ์ ๋ณ 0ยท5-shot, ํ ์ฐธ๊ณ )ยทgreedy, ๋ชจ๋ ๋น๋๋ฅผ ๊ฐ์ ์ค์ ์ผ๋ก ์ธก์ | |
| - **ํ๊ตญ์ด ๋ฒค์น๋งํฌ**: KMMLU 38.38 (์๋ณธ 37.65, 101.9%) ยท HAE-RAE 38.13 (์๋ณธ 39.05, 97.7%) | |
| - **MMLU ๋ฐฉ์**: lm-eval ์์ฑํ ๋ณํ(`mmlu_generative`) โ ๋ชจ๋ธ์ด ๋ต ๊ธ์๋ฅผ ์์ฑํ๊ณ ์ฒซ ์ค์ด ์ ํํ ์ผ์นํด์ผ ์ ๋ต์ผ๋ก ์ฑ์ ํ๋ฏ๋ก, ๋ค๋ฅธ ๋ฐฉ์(์: log-likelihood ์ฑ์ )์ผ๋ก ์ฐ MMLU ์ ์์ ์ง์ ๋น๊ต ๋ถ๊ฐ | |
| ### ์๊ตฌ์ฌํญ | |
| - **์คํ ์์ง**: vLLM, ์ด ๋น๋๋ vLLM 0.32.0์์ ์คํ ํ์ธ | |
| - **vLLM 0.32 ์ค์น ์กฐ๊ฑด**: Python 3.11~3.14, torch 2.13(CUDA 13.0 ๋น๋, CUDA 13 ์ง์ ๋๋ผ์ด๋ฒ ํ์), transformers 5.16.1 ์ด์ 5.20 ๋ฏธ๋ง, compressed-tensors 0.17.0 โ transformersยทcompressed-tensors๋ vLLM์ด ๋ฒ์ ์ ๊ณ ์ ํ๋ฏ๋ก compressed-tensors๋ฅผ ๋ฐ๋ก ์ ๊ทธ๋ ์ด๋ํ์ง ๋ง ๊ฒ (์ด ์ฒดํฌํฌ์ธํธ๋ 0.19.0์ผ๋ก ์ ์ฅ๋์ง๋ง 0.17.0์์๋ ๋ก๋๋จ) | |
| - **GPU**: NVIDIA Turing(sm75, ์: T4) ์ด์, V100(sm70) ๋ฏธ์ง์ โ FP8 ์ฐ์ฐ์ AdaยทHopperยทBlackwell(sm89 ์ด์)์์ ์ํ, TuringยทAmpere๋ vLLM์ด ๊ฐ์ค์น ์ ์ฉ FP8๋ก ์๋ ์ ํ (GPU๋ณ ์ง์ ์ฌ๋ถ๋ vLLM 0.32 ์ปค๋ ์ ํ ์ฝ๋ ๊ธฐ์ค, ์ค์ ์คํ์ B200์์๋ง ํ์ธ) | |
| - **๋ฉ๋ชจ๋ฆฌ**: ๊ฐ์ค์น 3.1 GB + KV ์บ์(์ปจํ ์คํธ ๊ธธ์ด ร ๋์ ์์ฒญ ์์ ๋น๋ก) + ํ์ฑํยทCUDA graph์ฉ ์ GB โ GPU ํ ์ฅ์ ๋ค ๋ค์ด๊ฐ์ง ์์ผ๋ฉด `--tensor-parallel-size N`์ผ๋ก ๋ถ์ฐ | |
| - **Transformers๋ก ์ง์ ์ฌ์ฉ**: transformers 4.56.0 ์ด์ + compressed-tensors 0.15.0 ์ด์ (4.56.2ยท4.57.6์์ FP8ยทAWQ-4bitยทNVFP4A16, 4.56.0์์ AWQ-4bit ํ์ธ, transformers 4.x์์๋ ํ ํฌ๋์ด์ ๊ฐ `token_type_ids`๋ ๋๋ ค์ฃผ๋๋ฐ ๋ชจ๋ธ์ด ๋ฐ์ง ์์ผ๋ฏ๋ก `generate` ํธ์ถ ์ ์ ํ ํฌ๋์ด์ ์ถ๋ ฅ์์ ๋นผ์ผ ํจ โ ํ์ธ ๋๋ ๋บ) | |
| - **trust_remote_code**: ๋ถํ์ | |
| ### ์ฌ์ฉ๋ฒ | |
| - **์๋ฒ ์คํ**: `vllm serve axteam/MiniCPM5-2B-FP8-dynamic --max-model-len 32768` โ OpenAI ํธํ API | |
| - **Python**: `LLM(model="axteam/MiniCPM5-2B-FP8-dynamic", max_model_len=32768).chat(...)` โ ์ ์ฒด ์์๋ ์ ์์ด ๋ณธ๋ฌธ 'Usage (vLLM)' ์ ์ฐธ๊ณ | |
| - **๊ถ์ฅ ์ํ๋ง**: `temperature=1.0`, `top_p=0.95` (์๋ณธ `generation_config.json` ๊ธฐ์ค) | |
| - **thinking ๋ชจ๋**: ๊ธฐ๋ณธ ์ผ์ง โ ๋๋ ค๋ฉด `chat_template_kwargs={"enable_thinking": False}` ์ ๋ฌ(Python์ `llm.chat()` ์ธ์, HTTP๋ ์์ฒญ ๋ณธ๋ฌธ์ `"chat_template_kwargs": {"enable_thinking": false}`) | |
| - **KV ์บ์ ์ ๊ฐ(์ ํ)**: `vllm serve`์ `--kv-cache-dtype fp8` ์ถ๊ฐ โ ๊ธฐ๋ณธ BF16์ธ KV ์บ์๋ฅผ FP8๋ก ์ ์ฅํด KV ์บ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฝ ์ ๋ฐ์ผ๋ก ์ค์ (๊ธด ์ปจํ ์คํธยท๋์ ์์ฒญ์ด ๋ง์ ๋ ์ ๋ฆฌ, ๊ฐ์ค์น ์์ํ์ ๋ณ๊ฐ์ธ ์คํ ์ต์ ) | |
| ### ๋ผ์ด์ ์ค | |
| - **๋ผ์ด์ ์ค**: Apache-2.0 โ ์๋ณธ ๋ชจ๋ธ์ ๋ผ์ด์ ์ค๋ฅผ ๊ทธ๋๋ก ๋ฐ๋ฆ | |
| - **๊ถ๋ฆฌ**: ์๋ณธ ๊ฐ์ค์นยทํ ํฌ๋์ด์ ๋ OpenBMB ์์ , ์ด ๋ฆฌํฌ๋ ์์ํ ํ์๋ฌผ | |