This Hugging Face Space runs Pi's real agent core, just-bash and MiniCPM5-2B entirely in your browser. Chat with Pi, inspect and edit files, and execute shell commands in a persistent virtual workspace. A browser worker runs the agent loop, local WebGPU inference and every tool — no inference API, API key or shell server is involved.
Try: What's our total sales revenue?
Key Features
- Fully local: the model runs on WebGPU and tools run in a browser worker; chat and virtual files are saved in IndexedDB on the site, and files never leave your device (export anything you want to keep).
- Download once, reuse: the first download is about 1.84 GB; files are SHA-256 verified and cached in OPFS, so weights are reused after reloading. The loader uses bounded byte ranges, retries and cancellation, with separate download / GPU setup / warm-up phases.
- Agent tools: Pi has
bash,read,writeandedittools. just-bash supports shell scripts, pipes, redirects,awk,jq,sed,grepand other text commands; Node.js, Python, npm, native binaries, SQLite and network commands are unavailable. - Pi's real terminal UI: the left column uses xterm.js with Pi's actual terminal renderer, editor and message components (reusing Pi's TUI, without the full Node CLI and its extensions). The shell has live Bash syntax coloring, multiline commands, session history and colored errors/exit states.
- Live status: the top bar shows the model, its load status, and a live token-speed sparkline labeled WebGPU for inference or JavaScript for tool execution.
Requirements and limits: WebGPU with FP16 (shader-f16) in a browser worker, OPFS, and sufficient storage and device memory. There is an 8,192-token prompt-plus-output budget, up to 2,048 generated tokens per model call, and a 12-turn limit per request. Desktop and narrow-screen layouts are included, but physical Android/iOS devices have not been tested. If your browser blocks storage inside Hugging Face's embedded view, use the app's Open workspace in a new tab button or open the app directly.
Model Conversion
The bundled q4f16 model was converted directly from the official OpenBMB MiniCPM5-2B BF16 checkpoint, not from community-converted weights:
- Source revision
abe115e887989b14f05e64a3b260648329324c3f, with the official weight SHA-256 verified before conversion. - ONNX Runtime GenAI 0.15.2; symmetric int4, block size 32; FP16 activations and KV cache.
- Fused QKV, GQA, RoPE and normalization operations.
- Last-position logits selected before the output projection.
- Lossless splitting of the 510 MiB embedding allocation into four 127.5 MiB tensors.
- Seven external-data shards; corrected tool-history serialization and Jinja compatibility.
The weights are hosted in the companion model repo Mike0021/MiniCPM5-2B-ONNX; the app pins revision 04a6c49fcba3a65a0351c92644c3a7e9d4343059, and the manifest lists file sizes and SHA-256 hashes. The Space contains an independently converted and quantized derivative; no weights were retrained.
Validation
Six prompts with prefill and cached decoding give 41 tested prediction positions. These are scoped conversion checks, not a broad quality evaluation.
| Comparison | Top-token agreement | Mean KL divergence |
|---|---|---|
| FP16 ONNX vs FP16 PyTorch | 41/41 | 0.00000815 |
| Int4 ONNX vs official BF16 PyTorch | 36/41 | 0.125916 |
| Packaged int4 vs original int4 export | 41/41; all logits bit-identical | 0 |
| Browser WebGPU vs native packaged ONNX | 41/41 | 0.002517 |
Local Chromium tests on an AMD Radeon 8060S covered streaming, stopping, thinking mode, XML tool-call generation, and a retrieval fixture at 3,888 prompt tokens. Inference also passed with the GPU capped at a 128 MiB storage binding limit and 256 MiB buffer limit (this does not emulate a phone's memory pressure or thermals). Warm decode medians were about 35–42 tokens/s; at 1,890 prompt tokens, first-token latency improved about 9.5% over an identical-weight control with all-position logits and unsplit embeddings.
Browser-Agent Verification
With networking disabled, the production bundle passed five real-model agent workflows: reading an unseen random file value, computing CSV revenue and writing a report, creating and executing a shell script, editing that script, and recovering from a missing-file error — with zero network requests. All five also passed from the public Space URL, with zero weight downloads on reload. In the actual Hugging Face embed, MiniCPM loaded from cache in 3.644 seconds and produced and verified a $144 sales report through Pi's tools. The xterm.js terminal passed all 12 interaction checks (keyboard editing, search, history, Unicode/large clipboard paste, shell execution, a 390px layout, and more).
Limitations
- Four-bit quantization has measurable quality loss: a multi-turn audit reproduced ineffective HTML/CDN edits and long, inconclusive reasoning with this export, while the original BF16 model completed the reference workflow.
- The base model also makes mistakes: one Chinese arithmetic prompt produced an incorrect answer in both the official BF16 model and the conversion.
- Integration tests do not establish broad coding-agent reliability; the author does not claim the 4-bit model matches BF16 or that multi-turn inference is fully optimized.
- The agent uses the 2B model's supported thinking mode with actual nucleus sampling (temperature 1, top-p 0.95, no top-k/min-p filter, repetition penalty 1); completed thinking is kept separately in history and collapsed in the UI.
Runtime
Pi Agent / Pi AI 0.85.1, just-bash 3.4.2, Transformers.js 4.2.0, ONNX Runtime Web 1.26.0-dev.20260416-b7804b056c. Attribution: base model by OpenBMB (Apache-2.0); agent by Pi / earendil-works; shell by just-bash / Vercel; inference via Hugging Face Transformers.js and Microsoft ONNX Runtime.
Links
- Hugging Face Space: victor/MiniCPM5-2B-WebGPU-Pi
- Open the app directly: townbox-minicpm5-2b-webgpu-pi.static.hf.space
- ONNX weights: Mike0021/MiniCPM5-2B-ONNX
