<< All versions

Skill v1.0.0

currentAutomated scan100/100
darknecrocities/skillbuilder/local-llm
──Details
PublishedNovember 24, 2026 at 04:32 PM
Content Hashsha256:5ef5c33ae112e174...
Git SHA170d96d79d4e
──Files
Files (1 file, 3.2 KB)
SKILL.md3.2 KBactive
SKILL.md · 51 lines · 3.2 KB

name: local-llm description: Local LLM architecture, quantized inference (GGUF Q4_K_M/Q8_0), Ollama, llama.cpp, Apple Silicon MLX, vLLM, SGLang, WebLLM/Transformers.js, KV-cache tuning, GBNF structured grammars, in-process local RAG, and 3-tier hybrid routing. metadata: version: "1.0.0"


Local LLM & Edge Inference (/local-llm)

Philosophy: Compute exact VRAM + KV-cache budgets before loading weights, enforce GBNF/schema grammars at logit sampling, keep RAG in-process, and never silently leak local prompts to cloud APIs.

1. Progressive Disclosure References

ResourcePurpose
references/quantized-inference-and-gguf.mdQ4_K_M/Q5_K_M/Q8_0 sizing math, Apple MLX, Ollama SSE cancellation & health probes.
references/serving-engines-and-kv-cache.mdvLLM / SGLang PagedAttention, Transformers.js WebGPU, q8_0 KV-cache, prefix caching, speculative decoding.
references/gbnf-grammars-and-local-rag.mdGBNF logit-level JSON schemas, sqlite-vec & DuckDB vss in-process hybrid RAG.
scripts/verify_local_llm_hygiene.pyAudits degraded Q2/Q3 quantizations, missing timeouts, -ngl 0, unconstrained JSON prompts, and unbounded num_ctx.

2. Heterogeneous Inference Runtime Matrix

RuntimeFormatsBest TargetKey Capabilities
`llama.cpp` (`llama-server`)GGUF (Q4_K_M+)Linux / Docker / CUDAContinuous batching (-cb), -ngl 999, GBNF grammars, -fa.
`Ollama`GGUFWorkstations / Local DevDeclarative Modelfile, OpenAI /v1, format JSON schema.
Apple Silicon `MLX`MLX 4-bit / 8-bitmacOS M1–M4 UMAZero-PCIe-copy Metal execution (80–130+ tok/s).
`vLLM` / `SGLang`FP8 / AWQ / GPTQMulti-user GPU serversPagedAttention, RadixAttention prefix reuse, high concurrency.
`WebLLM` / `Transformers.js`Wasm + WebGPUClient Browsers100% private in-browser execution inside Web Workers.

3. Core Quantization, RAG & Hybrid Routing Invariants

  1. VRAM Budget Formula: $\text{VRAM}_{\text{req}} = (\text{Params} \times \text{Bpw} / 8) + \text{KV Cache} + \text{Scratch (0.4–1.0 GB)}$. Default to Q4_K_M (chat/routing), Q5_K_M (code/logic), or Q8_0 (embeddings); reject Q2/Q3 collapse. Pin num_ctx (8192 default) and enable -fa + q8_0 KV cache for long contexts.
  2. Deterministic GBNF / Schema Grammars: Constrain local 3B–8B JSON output at token logit sampling (grammar in llama.cpp, format in Ollama) so markdown fences and malformed JSON cannot be sampled.
  3. In-Process Local RAG: Use sqlite-vec or DuckDB vss (doc_hash + embedding_model version tracking, top_k <= 6) instead of heavyweight external vector DB containers.
  4. 3-Tier Hybrid Cascade: Route Tier 1 (3B edge <150ms) -> Tier 2 (32B–70B local) -> Tier 3 (Gemini Frontier) ONLY with 3s/15s timeouts and explicit AI_PRIVACY_MODE=hybrid_consent (/ai-integration).

4. Automated Local LLM Hygiene Audit

bash
python3 skills/local-llm/scripts/verify_local_llm_hygiene.py --path .
All versions