Pocket LLaMA: Standalone CPU-Bound Edge AI Appliance in Rust
Standalone Edge AI Inference Engine
Pocket LLaMA is a high-performance, air-gapped, zero-dependency Edge AI appliance designed for execution of sub-4B parameter quantized GGUF models on standard CPU hardware. View Project on GitHub
Built entirely in Rust using Hugging Face's candle ecosystem, Pocket LLaMA delivers a premium, single-binary execution environment that bypasses heavy virtualization and Python runtime overhead. It can be run directly from an external thumb drive, serving both an embedded dark-theme Web interface and a Google Gemini-compatible REST API.
.gguf format (we highly recommend TinyLlama-1.1B-Chat-v1.0.Q4_K_M.gguf from Hugging Face for testing). - System Memory Recommendation: Running local model inference on standard CPU hardware is resource-intensive. It is highly recommended to run this appliance on a modern computer with at least 16GB of RAM to ensure smooth execution, prevent aggressive disk swapping, and bypass the built-in 80% RAM safety lockout.Core Capabilities
#### 1. "Double-Click" Desktop Application UX
By evaluating CLI arguments, Pocket LLaMA intercepts zero-parameter invocations (e.g., when a user double-clicks pocket-cli.exe directly on a Windows thumb drive).
- Instantly spins up a background API and web server on standard port
8080. - Launches the user's system-default web browser pointing directly to the local HUD portal.
- Renders a premium, glassmorphic dark-theme console served straight from the binary's RAM without any Disk I/O.
#### 2. Hugging Face Candle Inference Engine
- Integrates Hugging Face's
candle-core,candle-transformers, andcandle-nnenvironments. - Bridges synchronous matrix calculation pipelines to asynchronous Tokio runtimes via thread-safe
mpsctoken channels, ensuring real-time UI typewriter transitions.
#### 3. Strict Zero-Panic Error Policy
- Features an explicit
PocketErrorenum mapped throughthiserror, completely replacing rawunwrap()orexpect()sequences. - Guarantees high availability: network timeouts, model load failures, or invalid JSON payloads are handled safely without terminating the process.
#### 4. Gemini-Compatible REST API Schema
To enable immediate drop-in replacement for existing AI tools, Pocket LLaMA hosts a lightweight Axum REST service emulating the Google Gemini JSON schema:
- Endpoint:
POST /v1beta/models/:model(e.g.POST /v1beta/models/pocket:generateContent) - Supports structured message histories (
{"contents": [{"role": "user", "parts": [{"text": "..."}]}]}) and maps context turns to maintain state across HTTP client cycles.
Supported Model Architectures
While Pocket LLaMA accepts general .gguf file formats, the internal tensor parsing engine is currently optimized and tested specifically for TinyLlama (wired via candle_transformers::models::quantized_llama::ModelWeights).
Please check your model's base architecture before loading it into the local engine:
#### 🟢 Supported Models (Green Light)
- TinyLlama (specifically tested with
TinyLlama-1.1B-Chat-v1.0)
#### 🔴 Unsupported Models (Red Light)
Attempting to load larger parameter models or other architectures (like LLaMA 2, LLaMA 3, Mistral, Gemma, or Phi) has not been verified and may trigger a safe PocketError::EngineError or resource exhaustion:
- Meta LLaMA 2 / 3 & Mistral (Unverified/untested at this time)
- Microsoft Phi-3 (Phi architectures construct attention layers differently)
- Google Gemma & Gemma 2 (Gemma containers utilize custom scaling and normalization layouts)
- Qwen 2 / Qwen 2.5 (Qwen formats require distinct multi-head attention routing)
🛡️ Pre-Flight Hardware Guardrail
Executing local LLMs on standard CPU hardware can be highly intensive. To protect user systems from memory exhaustion and OS freezing, Pocket LLaMA implements a strict Pre-Flight Hardware interlock:
sysinfo crate to verify the system's available physical RAM. If loading the requested GGUF model would exceed 80% of total physical RAM capacity, the engine will halt immediately and prevent model loading. This guardrail protects your operating system from aggressive disk swap cycles and freezing. To bypass, append the --force-ram CLI flag on launch.💻 Command Reference
#### 1. The Interactive CLI REPL
Run local CPU model inference directly inside your terminal with high-performance real-time streaming:
.\pocket-cli.exe --model "H:\models\tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf" --tokenizer "H:\models\tokenizer.json"
#### 2. The Web HUD (Double-Click Simulator)
Launches the Axum server on port 8080 and opens the web-based chat console in your default browser:
# Zero arguments initiates default Desktop Appliance mode
.\pocket-cli.exe
#### 3. API Server Mode
Host the Gemini-compatible REST server without launching the browser (perfect for headless/background services):
.\pocket-cli.exe --serve --model "H:\models\tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf" --tokenizer "H:\models\tokenizer.json"
🛠️ Build and Compilation Instructions
To build a highly optimized production binary containing all embedded HTML/CSS/JS assets inside a single .exe file:
cargo build --release
Copy the compiled release executable at target/release/pocket-cli.exe to your target environment, and your zero-dependency edge AI portal is ready for offline execution!