Download make_gguf.ps1 from DevGwardo/minicpm5-toolcall-code: direct link, hf CLI and curl.
- Browser
- Download file 3.92 kB
-
https://huggingface.co/datasets/DevGwardo/minicpm5-toolcall-code/resolve/main/make_gguf.ps1
- Command line
-
hf download hf://datasets/DevGwardo/minicpm5-toolcall-code/make_gguf.ps1
-
curl -L -o make_gguf.ps1 https://huggingface.co/datasets/DevGwardo/minicpm5-toolcall-code/resolve/main/make_gguf.ps1
3.92 kB
| param( | |
| [string]$AdapterRepo = "DevGwardo/minicpm5-1b-toolcall", | |
| [string]$OutDir = "gguf", | |
| [string]$MergedDir = "merged", | |
| [switch]$SkipMerge | |
| ) | |
| $ErrorActionPreference = 'Stop' | |
| # Project root = parent of this script's directory (pipeline\). | |
| $ProjectRoot = if ($PSScriptRoot) { Split-Path $PSScriptRoot -Parent } else { (Get-Location).Path } | |
| function Resolve-FromRoot([string]$p) { | |
| if ([System.IO.Path]::IsPathRooted($p)) { return $p } | |
| return (Join-Path $ProjectRoot $p) | |
| } | |
| $Python = Resolve-FromRoot '.venv\Scripts\python.exe' | |
| $MergeScript = Resolve-FromRoot 'pipeline\merge_local.py' | |
| $ConvertScript = Resolve-FromRoot 'llama.cpp-src\convert_hf_to_gguf.py' | |
| $Quantize = Resolve-FromRoot 'llama-bin\llama-quantize.exe' | |
| $MergedFull = Resolve-FromRoot $MergedDir | |
| $OutFull = Resolve-FromRoot $OutDir | |
| # NOTE: $AdapterRepo is informational. pipeline/merge_local.py currently | |
| # hardcodes BASE="openbmb/MiniCPM5-1B" and ADAPTER="DevGwardo/minicpm5-1b-toolcall", | |
| # so a non-default -AdapterRepo value is accepted but NOT forwarded to the merge. | |
| if ($AdapterRepo -ne 'DevGwardo/minicpm5-1b-toolcall') { | |
| Write-Host ("WARNING: -AdapterRepo '{0}' is ignored by pipeline/merge_local.py (hardcoded adapter)." -f $AdapterRepo) -ForegroundColor Yellow | |
| } | |
| if ($MergedDir -ne 'merged') { | |
| Write-Host 'WARNING: pipeline/merge_local.py always writes to .\merged; a custom -MergedDir only affects convert/quantize inputs.' -ForegroundColor Yellow | |
| } | |
| # 1) Sanity-check paths; create $OutDir. | |
| $required = @($Python, $MergeScript, $ConvertScript, $Quantize) | |
| foreach ($p in $required) { | |
| if (-not (Test-Path $p)) { throw "Missing required file: $p" } | |
| } | |
| New-Item -ItemType Directory -Force -Path $OutFull | Out-Null | |
| Write-Host "Project root : $ProjectRoot" | |
| Write-Host "Merged dir : $MergedFull" | |
| Write-Host "Output dir : $OutFull" | |
| Push-Location $ProjectRoot | |
| try { | |
| # 2) Merge (idempotent: skip when merged\config.json already exists). | |
| $mergedConfig = Join-Path $MergedFull 'config.json' | |
| if (Test-Path $mergedConfig) { | |
| Write-Host 'Merged model found, skipping merge.' -ForegroundColor Green | |
| } | |
| elseif ($SkipMerge) { | |
| Write-Host 'ERROR: merged model not found.' -ForegroundColor Red | |
| Write-Host (" Expected: {0}" -f $mergedConfig) | |
| Write-Host ' Run the merge first (one of):' | |
| Write-Host ' powershell -NoProfile -File pipeline\make_gguf.ps1' | |
| Write-Host ' .venv\Scripts\python.exe pipeline\merge_local.py' | |
| exit 1 | |
| } | |
| else { | |
| Write-Host 'Merging LoRA into base (pipeline\merge_local.py) ...' | |
| & $Python $MergeScript | |
| if ($LASTEXITCODE -ne 0) { throw "merge_local.py failed with exit code $LASTEXITCODE." } | |
| if (-not (Test-Path $mergedConfig)) { throw "Merge finished but config.json still missing: $mergedConfig" } | |
| } | |
| # 3) Convert merged HF dir -> f16 GGUF. | |
| $f16 = Join-Path $OutFull 'minicpm5-1b-toolcall-f16.gguf' | |
| $q8 = Join-Path $OutFull 'minicpm5-1b-toolcall-Q8_0.gguf' | |
| $q4 = Join-Path $OutFull 'minicpm5-1b-toolcall-Q4_K_M.gguf' | |
| Write-Host 'Converting to f16 GGUF ...' | |
| & $Python $ConvertScript $MergedFull --outfile $f16 --outtype f16 | |
| if ($LASTEXITCODE -ne 0) { throw "convert_hf_to_gguf.py failed with exit code $LASTEXITCODE." } | |
| # 4) Quantize. | |
| Write-Host 'Quantizing Q8_0 ...' | |
| & $Quantize $f16 $q8 Q8_0 | |
| if ($LASTEXITCODE -ne 0) { throw "llama-quantize Q8_0 failed with exit code $LASTEXITCODE." } | |
| Write-Host 'Quantizing Q4_K_M ...' | |
| & $Quantize $f16 $q4 Q4_K_M | |
| if ($LASTEXITCODE -ne 0) { throw "llama-quantize Q4_K_M failed with exit code $LASTEXITCODE." } | |
| # 5) Report outputs + sizes. | |
| Write-Host '' | |
| Write-Host 'GGUF outputs:' | |
| Get-ChildItem $OutFull -Filter '*.gguf' | | |
| Select-Object Name, | |
| @{ Name = 'SizeMB'; Expression = { '{0:N1}' -f ($_.Length / 1MB) } }, | |
| @{ Name = 'Bytes'; Expression = { $_.Length } } | | |
| Format-Table -AutoSize | Out-String | Write-Host | |
| } | |
| finally { | |
| Pop-Location | |
| } | |