Professional Windows deployment automation for a local llama.cpp server using Hugging Face GGUF models. This project now uses a profile-driven workflow centered on installing_ggufs_hf.ps1, letting you run either built-in profiles or arbitrary Hugging Face GGUF repositories with safe defaults.
The deployment script automates the following:
- Creates required directories:
C:\llama_cppC:\AI_Models
- Detects the latest
llama.cppWindows CUDA x64 release from GitHub - Downloads the selected release ZIP
- Extracts the binaries into
C:\llama_cpp - Resolves the exact model file from Hugging Face metadata
- Downloads a model from either:
- a local profile in
models/*.json - direct parameters
-HfRepoand-HfFile
- a local profile in
- Creates desktop launchers:
Start-AI-Server.bat(3-endpoint stack)Start-AI-Server-3B.bat(3B wrapper)Start-AI-Server-0.5B.bat(0.5B wrapper)
- Starts
llama-server.exewith predefined runtime arguments on all required llama-vscode endpoints
Built-in starter profiles:
- Profile:
models/qwen2.5-3b.json - Profile:
models/qwen2.5-0.5b.json - Server port:
8009 - Safe default context size:
3072(3B),2048(0.5B) - Safe default GPU layers:
16(3B),8(0.5B) - Safe default threads:
6(3B),4(0.5B)
- Automatic GitHub release discovery for
llama.cpp - Automatic Hugging Face model file resolution
- ZIP integrity validation before extraction
- File existence and non-empty download validation
- Periodic model download progress reporting
- Desktop launcher generation for one-click startup
- Structured helper functions and defensive error handling
LLAMA-VSCODE/
├─ models/model-profile.schema.json
├─ models/qwen2.5-3b.json
├─ models/qwen2.5-0.5b.json
├─ scripts/Configure-LlamaVscode.ps1
├─ scripts/Validate-ModelProfile.ps1
├─ scripts/Find-HuggingFaceGGUF.ps1
├─ tests/InstallerBehavior.Tests.ps1
├─ tests/ModelProfileValidation.Tests.ps1
├─ Start-AI-Server.bat
├─ Start-AI-Server-3B.bat
├─ Start-AI-Server-0.5B.bat
├─ installing_ggufs_hf.ps1
├─ USER-GUIDE.md
└─ README.md
Before running the script, ensure the following are available:
- Windows
- PowerShell 5.1 or newer
- Internet access
- Sufficient disk space for:
- extracted
llama.cppbinaries - the GGUF model file
- extracted
- NVIDIA GPU recommended
- CUDA-compatible environment expected by the selected
llama.cppWindows CUDA build
The script writes to:
C:\llama_cppC:\AI_Models%USERPROFILE%\Desktop
If your system restricts writes to these locations, run PowerShell with appropriate permissions or adjust the script paths.
Open PowerShell and run:
Set-ExecutionPolicy -Scope Process Bypass
.\installing_ggufs_hf.ps1Install by profile name:
.\installing_ggufs_hf.ps1 -Profile qwen2.5-3bInstall any GGUF model directly from Hugging Face:
.\installing_ggufs_hf.ps1 -HfRepo "TheBloke/Mistral-7B-Instruct-v0.2-GGUF" -HfFile "mistral-7b-instruct-v0.2.Q4_K_M.gguf" -ProfileName "mistral-7b"After completion, use the generated desktop shortcut batch file:
Start-AI-Server.bat
This launcher starts:
tools -> http://localhost:8009
chat -> http://localhost:8011
completion -> http://localhost:8012
The generated launcher uses conservative defaults for Windows laptops:
LLAMA_PORT=8009LLAMA_CTX_SIZE=3072LLAMA_GPU_LAYERS=16LLAMA_THREADS=6
Each run also applies a llama-vscode bootstrap in user settings so agent/model selection does not require manual reconfiguration.
For the tiny fallback model, use:
.\installing_ggufs_hf.ps1 -Tiny -ModelOnlyThen launch with:
Start-AI-Server-0.5B.bat
You can override them per launch before starting the batch file, for example:
$env:LLAMA_GPU_LAYERS = '28'
$env:LLAMA_CTX_SIZE = '3072'
$env:LLAMA_THREADS = '8'
./Start-AI-Server.batStart using a profile at runtime:
Start-AI-Server.bat -Profile qwen2.5-3bStart watcher using a profile:
Start-AI-Server-AutoWatcher.bat -Profile qwen2.5-3bRegister scheduled task for a profile:
cd .\scripts
.\Register-LlamaServerTask.ps1 -Profile qwen2.5-3bDiscover GGUF repositories and files:
cd .\scripts
.\Find-HuggingFaceGGUF.ps1 -Query "phi 3 mini instruct" -Author "microsoft"
.\Find-HuggingFaceGGUF.ps1 -Query "mistral instruct gguf" -Author "TheBloke"
.\Find-HuggingFaceGGUF.ps1 -Query "mistral" -Repository "TheBloke/Mistral-7B-Instruct-v0.2-GGUF"You can onboard any Hugging Face GGUF model without editing scripts or JSON by hand:
Step 1 — Discover the model and exact filename
.\scripts\Find-HuggingFaceGGUF.ps1 -Query "mistral 7b instruct" -Author "TheBloke"
# or list files for a known repo:
.\scripts\Find-HuggingFaceGGUF.ps1 -Query "mistral" -Repository "TheBloke/Mistral-7B-Instruct-v0.2-GGUF"Step 2 — Install the model
.\installing_ggufs_hf.ps1 `
-HfRepo "TheBloke/Mistral-7B-Instruct-v0.2-GGUF" `
-HfFile "mistral-7b-instruct-v0.2.Q4_K_M.gguf" `
-ProfileName "mistral-7b"This downloads the GGUF, selects safe runtime defaults based on file size, saves a reusable profile to models/mistral-7b.json, generates a launcher, and auto-configures llama-vscode settings.
Warning: Models larger than 7 GB have ultra-conservative defaults applied automatically (ctx=1024, ngl=6, threads=4). They may cause instability on laptop hardware. Prefer quantizations under 7 GB.
Step 3 — Launch
.\Start-AI-Server.bat -Profile mistral-7bAll three llama-vscode endpoints start immediately:
tools -> http://localhost:8009
chat -> http://localhost:8011
completion -> http://localhost:8012
Profile files are validated before use.
- JSON schema:
models/model-profile.schema.json - Validation script:
scripts/Validate-ModelProfile.ps1
Validate one profile:
. .\scripts\Validate-ModelProfile.ps1
Test-ModelProfileFile -ProfilePath .\models\qwen2.5-3b.json -SchemaPath .\models\model-profile.schema.jsonValidate all profiles:
. .\scripts\Validate-ModelProfile.ps1
Get-ChildItem .\models -Filter *.json |
Where-Object { $_.Name -ne 'model-profile.schema.json' } |
ForEach-Object { Test-ModelProfileFile -ProfilePath $_.FullName -SchemaPath .\models\model-profile.schema.json }Run Pester tests:
Invoke-Pester -Path .\testsRun script parse check:
Get-ChildItem -Recurse -Filter *.ps1 |
Where-Object { $_.FullName -notmatch '\\.history\\' } |
ForEach-Object {
$tokens = $null
$errors = $null
[void][System.Management.Automation.Language.Parser]::ParseFile($_.FullName, [ref]$tokens, [ref]$errors)
if ($errors) { throw "Parse failed: $($_.FullName)" }
}PR CI runs these checks automatically via .github/workflows/powershell-quality.yml.
For full operator instructions, see USER-GUIDE.md.
The script encapsulates deployment locations in a DeploymentPaths class and standardizes output through helper functions.
It queries:
https://api.github.com/repos/ggml-org/llama.cpp/releases/latest
Then selects a matching asset using this pattern:
^llama-.*-bin-win-cuda-.*-x64\.zip$Instead of hardcoding a direct model download link, it queries:
https://huggingface.co/api/models/Qwen/Qwen2.5-Coder-3B-Instruct-GGUF
This reduces failures caused by stale URLs or repository-side changes.
The script checks whether downloaded files:
- exist
- are non-empty
- are valid ZIP archives before extraction
The generated batch launcher:
- changes into the
llama.cppdirectory - verifies
llama-server.exeexists - verifies the model file exists
- starts the server with the configured options
| Item | Path |
|---|---|
| llama.cpp directory | C:\llama_cpp |
| model directory | C:\AI_Models |
| downloaded ZIP | C:\llama_cpp\llama-win.zip |
| model file (default) | C:\AI_Models\qwen2.5-coder-3b-instruct-q4_k_m.gguf |
| model file (tiny fallback) | C:\AI_Models\qwen2.5-coder-0.5b-instruct-q2_k.gguf |
| launcher | %USERPROFILE%\Desktop\Start-AI-Server.bat |
The script is solidly structured, but deployment success still depends on external conditions.
The script explicitly selects a Windows CUDA build of llama.cpp. Systems without compatible NVIDIA/CUDA support may not run the downloaded binaries successfully.
The binary selection depends on the GitHub asset naming convention matching:
^llama-.*-bin-win-cuda-.*-x64\.zip$If upstream naming changes, the script may fail to locate a valid artifact.
The script currently uses fixed paths:
C:\llama_cppC:\AI_Models
This is convenient for a single-machine setup but may be unsuitable in managed, portable, or low-permission environments.
The desktop launcher expects llama-server.exe to be present directly in the deployment directory after extraction. If upstream packaging changes folder layout, the launcher may need adjustment.
The server is configured to use port 8009. If another application already uses that port, startup will fail.
The model download may take a significant amount of time depending on bandwidth and storage performance. The script includes a background progress job, but transient network issues can still interrupt the process.
Some Windows configurations block script execution by default. Running with a temporary process-scoped execution policy bypass is often sufficient.
Enterprise security tools may interfere with:
- direct file downloads
- ZIP extraction
- executable launch from user-created directories
Use:
Set-ExecutionPolicy -Scope Process BypassCheck:
- internet connectivity
- GitHub API availability
- Hugging Face availability
- local disk space
- endpoint security restrictions
Possible causes:
- incomplete download
- corrupted archive
- antivirus lock
- insufficient filesystem permissions
This usually indicates an upstream packaging layout change in the downloaded llama.cpp release.
Confirm the expected file exists:
C:\AI_Models\qwen2.5-coder-3b-instruct-q4_k_m.gguf
You can adapt the script by editing these values near the top of installing_ggufs_hf.ps1:
- deployment directories
- model filename
- launcher filename
- Hugging Face repository
- server arguments such as port, context size, and GPU layers
- The script pulls binaries from GitHub releases and model files from Hugging Face at runtime.
- It relies on live upstream metadata rather than vendored artifacts.
- Review downloaded sources and runtime flags before production or sensitive-environment use.
This project is best suited for:
- local Windows AI experimentation
- rapid
llama.cppserver deployment - GGUF-based coding assistant backends
- developer workstations with NVIDIA GPUs
No license file is currently included in this repository. Add one if you intend to publish or distribute the project.