Instructions to use PureTensorAI/MiniCPM5-2B-NVFP4A16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PureTensorAI/MiniCPM5-2B-NVFP4A16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="PureTensorAI/MiniCPM5-2B-NVFP4A16") 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("PureTensorAI/MiniCPM5-2B-NVFP4A16") model = AutoModelForCausalLM.from_pretrained("PureTensorAI/MiniCPM5-2B-NVFP4A16", 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 PureTensorAI/MiniCPM5-2B-NVFP4A16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PureTensorAI/MiniCPM5-2B-NVFP4A16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PureTensorAI/MiniCPM5-2B-NVFP4A16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/PureTensorAI/MiniCPM5-2B-NVFP4A16
- SGLang
How to use PureTensorAI/MiniCPM5-2B-NVFP4A16 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 "PureTensorAI/MiniCPM5-2B-NVFP4A16" \ --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": "PureTensorAI/MiniCPM5-2B-NVFP4A16", "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 "PureTensorAI/MiniCPM5-2B-NVFP4A16" \ --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": "PureTensorAI/MiniCPM5-2B-NVFP4A16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use PureTensorAI/MiniCPM5-2B-NVFP4A16 with Docker Model Runner:
docker model run hf.co/PureTensorAI/MiniCPM5-2B-NVFP4A16
MiniCPM5-2B NVFP4A16 (GPTQ, weights only)
NVFP4 quantization of openbmb/MiniCPM5-2B, made by PureTensor from the official BF16 weights. Weights are 4-bit; activations stay 16-bit (W4A16). The file is 2.18 GB against 5.03 GB for BF16.
This is a test release. It is not affiliated with or endorsed by OpenBMB.
Read this first: this checkpoint is measurably below BF16: 2.7 points on MMLU and 4.0 on GSM8K, both statistically significant. In exchange it served about 40% faster than BF16 for a single stream on vLLM in our test. Numbers below.
What was done
| Source | openbmb/MiniCPM5-2B, BF16 |
| Format | compressed-tensors nvfp4-pack-quantized, scheme NVFP4A16: 4-bit E2M1 values, one FP8 E4M3 scale per group of 16, one FP32 scale per tensor |
| Quantized | the weights of every Linear layer in the 42 transformer blocks |
| Kept in BF16 | token embeddings, output head, all norms, all activations |
| Method | GPTQ (block_size 128, dampening_frac 0.01, actorder static) |
| Calibration | the first 512 samples of mlabonne/open-perfectblend, up to 2,048 tokens each |
| Tools | llm-compressor 0.15.0, compressed-tensors 0.20.1, transformers 5.21.0, torch 2.14.1 |
from llmcompressor import oneshot
from llmcompressor.modifiers.quantization import GPTQModifier
recipe = GPTQModifier(targets="Linear", scheme="NVFP4A16", ignore=["lm_head"])
oneshot(model=model, processor=tokenizer, recipe=recipe, dataset="perfectblend",
splits="train[:512]", num_calibration_samples=512, max_seq_length=2048)
model.save_pretrained(out_dir, save_compressed=True)
Measured quality
Measured by us in one harness with the BF16 model as reference. The saved checkpoint reloaded from disk to logits identical to the in-memory quantized model.
| BF16 | This checkpoint | Change | Paired test | |
|---|---|---|---|---|
| MMLU, accuracy (14,042 questions) | 57.29 | 54.60 | -2.69 | 1,176 lost, 799 gained, p = 2e-17 |
| GSM8K, exact match (1,319 problems) | 72.48 | 68.46 | -4.02 | 130 lost, 77 gained, p = 3e-4 |
| WikiText-2 perplexity (131,072 tokens) | 15.64 | 16.27 | +0.63 |
| Text | Tokens | Mean KL divergence | 99th percentile KL | Same top token as BF16 |
|---|---|---|---|---|
| WikiText-2 test | 131,072 | 0.064 | 0.52 | 87.5% |
Chat (HuggingFaceH4/ultrachat_200k, test_sft, 256 conversations) |
224,534 | 0.068 | 0.97 | 90.2% |
- MMLU and GSM8K: default
mmluandgsm8kconfigurations of lm-evaluation-harness 0.4.13, no chat template, GSM8K flexible-extract. The paired test is an exact McNemar test on per-question correctness. - KL divergence: full next-token distribution, teacher-forced, windows of 1,024 tokens.
- Calibration caveat: 180 of the 512 calibration samples are math word problems (MetaMathQA and Orca-Math), and 75 come from UltraChat, the dataset family our chat evaluation set is drawn from. MetaMathQA is built from the GSM8K and MATH training sets. The GSM8K and chat rows may therefore flatter this checkpoint; the MMLU and WikiText rows are unrelated to the calibration data.
On a real serving engine
Served with vLLM 0.34.0 on one NVIDIA Blackwell workstation GPU (compute capability 12.0). vLLM runs this checkpoint with its weight-only FP4 kernel (MarlinNvFp4LinearKernel).
| BF16 | This checkpoint | |
|---|---|---|
| GSM8K through the completions API (flexible-extract) | 72.10 | 68.23 |
| Throughput, single stream | 1.00x | 1.40x |
| Throughput, 8 concurrent | 1.00x | 1.53x |
| Throughput, 32 concurrent | 1.00x | 1.28x |
The served GSM8K score matches the offline one (68.23 against 68.46), so the offline numbers above describe what the engine does. Throughput is fixed 256-token generations, greedy, and will differ on other hardware.
How it compares with other 4-bit builds of this model
All scored by us in the same harness. Public builds are described by method.
| Build | Activations | MMLU | GSM8K | KL, wiki | KL, chat |
|---|---|---|---|---|---|
| BF16 reference | 16-bit | 57.29 | 72.48 | 0 | 0 |
| This checkpoint: GPTQ, dampening 0.01 | 16-bit | 54.60 | 68.46 | 0.064 | 0.068 |
| A public GPTQ build, dampening 0.1 | 16-bit | 55.92 | 62.93 | 0.069 | 0.099 |
| A public AWQ build with searched scales | 16-bit | 50.45 | 61.71 | 0.103 | 0.149 |
| Our GPTQ build with 4-bit activations (not published) | 4-bit | 49.88 | 59.59 | 0.167 | 0.205 |
| A public AWQ build with 4-bit activations | 4-bit | 47.14 | 52.92 | 0.208 | 0.286 |
This checkpoint is the closest to BF16 on token-level agreement and on GSM8K. The public GPTQ build with heavier dampening is 1.3 points better on MMLU, which is inside the noise: when we repeated our own recipe with different calibration samples, MMLU moved by about 2 points from build to build (51.9 to 56.2 over eight builds), while GSM8K stayed within 66.1 to 69.6 and KL divergence barely moved. Treat MMLU differences of a point or two between rows as ties. With 4-bit activations this model loses 7 to 10 MMLU points, which is why we publish the weights-only form.
Usage
vLLM:
vllm serve PureTensorAI/MiniCPM5-2B-NVFP4A16
Transformers (requires pip install compressed-tensors):
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "PureTensorAI/MiniCPM5-2B-NVFP4A16"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16).to("cuda")
msgs = [{"role": "user", "content": "Summarise the water cycle in two sentences."}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt", return_dict=True).to("cuda")
out = model.generate(**ids, max_new_tokens=128)
print(tok.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True))
Limitations
- Quality is below BF16, as measured above. If you need the base model's quality, use BF16.
- In Transformers the weights are expanded back to 16-bit at load, so there the saving is disk and download size only. The speed gain needs an engine with an FP4 weight kernel, such as vLLM.
- English-language benchmarks only. One calibration draw, no repeated seeds. No safety, multilingual, or long-context evaluation was run on the quantized model.
License
Apache-2.0, as the base model. Changes from the base release: the Linear weights are quantized to NVFP4 and stored packed, and config.json gains a quantization_config block.
- Downloads last month
- 50
Model tree for PureTensorAI/MiniCPM5-2B-NVFP4A16
Base model
openbmb/MiniCPM5-2B