#!/bin/bash # Reproduce every file in this repo from the original weights. # Needs llama.cpp (convert_hf_to_gguf.py + llama-quantize + llama-perplexity) and wikitext-2-raw/wiki.test.raw. set -e hf download openbmb/MiniCPM5-2B --revision f97400052a43d642bbc6e9975e2397e3ae6a6b52 --local-dir hf # 1. BF16 reference and plain Q8_0, straight from the safetensors python3 convert_hf_to_gguf.py hf --outtype bf16 --outfile MiniCPM5-2B-BF16.gguf python3 convert_hf_to_gguf.py hf --outtype q8_0 --outfile MiniCPM5-2B-Q8_0.gguf # 2. Q8_0-XL: every block in Q8_0, token embeddings + output head kept in BF16 llama-quantize --token-embedding-type bf16 --output-tensor-type bf16 \ MiniCPM5-2B-BF16.gguf MiniCPM5-2B-Q8_0-XL.gguf Q8_0 # 3. Fidelity vs BF16: KLD / PPL / top-1 agreement, wikitext-2 test, 64 chunks x 2048 llama-perplexity -m MiniCPM5-2B-BF16.gguf -f wiki.test.raw -c 2048 --chunks 64 -ngl 99 --kl-divergence-base kld_base.dat for q in Q8_0 Q8_0-XL; do llama-perplexity -m MiniCPM5-2B-$q.gguf -c 2048 --chunks 64 -ngl 99 --kl-divergence-base kld_base.dat --kl-divergence done