File size: 2,323 Bytes
17b0632
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# GGUF build (MiniCPM5-1B toolcall)

Builds `f16`, `Q8_0`, and `Q4_K_M` GGUF files from the merged
`DevGwardo/minicpm5-1b-toolcall` LoRA via `pipeline/make_gguf.ps1`.

## Prerequisites

- `pipeline/merge_local.py` (merges the LoRA into the base, writes `.\merged`)
- `llama.cpp-src\convert_hf_to_gguf.py` (llama.cpp master checkout)
- `llama-bin\llama-quantize.exe` (release b12931)
- `.venv\Scripts\python.exe` with `torch`, `transformers`, `peft`, `gguf`, `numpy`

## Commands

Full pipeline (merge + convert + quantize), run from the project root:

```powershell
powershell -NoProfile -File pipeline\make_gguf.ps1
```

Convert + quantize only (requires `.\merged\config.json` to already exist):

```powershell
powershell -NoProfile -File pipeline\make_gguf.ps1 -SkipMerge
```

Custom directories (both relative to the project root unless absolute):

```powershell
powershell -NoProfile -File pipeline\make_gguf.ps1 -OutDir gguf -MergedDir merged
```

Manual equivalents of what the script runs:

```powershell
# 1) Merge (skipped automatically when merged\config.json exists)
.venv\Scripts\python.exe pipeline\merge_local.py

# 2) Convert merged dir -> f16 GGUF
.venv\Scripts\python.exe llama.cpp-src\convert_hf_to_gguf.py merged --outfile gguf\minicpm5-1b-toolcall-f16.gguf --outtype f16

# 3) Quantize
llama-bin\llama-quantize.exe gguf\minicpm5-1b-toolcall-f16.gguf gguf\minicpm5-1b-toolcall-Q8_0.gguf Q8_0
llama-bin\llama-quantize.exe gguf\minicpm5-1b-toolcall-f16.gguf gguf\minicpm5-1b-toolcall-Q4_K_M.gguf Q4_K_M
```

The script is idempotent: re-running it reuses `.\merged` when
`merged\config.json` exists and overwrites the GGUF outputs.

## Expected outputs and sizes

| File | Approx. size |
| ---- | ------------ |
| `gguf\minicpm5-1b-toolcall-f16.gguf` | ~2.2 GB |
| `gguf\minicpm5-1b-toolcall-Q8_0.gguf` | ~1.2 GB |
| `gguf\minicpm5-1b-toolcall-Q4_K_M.gguf` | ~0.8 GB |

The script prints a file/size table at the end and exits non-zero on
any failure (native calls are checked via `$LASTEXITCODE`).

## Serve

```powershell
.\llama-bin\llama-server.exe -m .\gguf\minicpm5-1b-toolcall-Q4_K_M.gguf -c 4096 --jinja --port 8080
```

> Runtime note: use a llama.cpp build **>= b9833**, which contains the
> native MiniCPM5 tool-call parser. Older builds will serve the model
> but cannot parse its tool calls.