A private AI chatbot that lives in your browser tab. No server. No API key. No sign-up. Your messages never leave your device.
Live demo Β· Quick start Β· How it works Β· Troubleshooting
PocketLLM is a chat web app that downloads a small open-source language model into your browser and runs it on your own GPU using WebLLM and WebGPU. You type, the model answers, and the conversation stays on your device.
It's built as a learning project: a clean, dependency-free example of local inference, streaming UI, async JavaScript, error handling and separation of concerns, with no framework and no build step.
| π Private by design | Chat text is processed on-device. There is no backend and no inference server. |
| πΈ Free to run | No paid API or key. You only need bandwidth for the first model download. |
| β‘ Streaming replies | Text appears word by word as the model generates it. |
| π Live loading progress | See download and compile progress; the model is cached for next time. |
| π Stop and clear | Interrupt a long answer any time, or wipe the conversation in one click. |
| π§― Friendly errors | Missing WebGPU, out-of-memory and generation failures show a clear message and a Retry button. |
| π§± Clean architecture | UI, chat state and model logic are separate modules. |
| π Light and dark themes | Follows your system setting, responsive down to phone size. |
| βΏ Accessible basics | Keyboard-friendly, visible focus, live status updates, reduced-motion support. |
flowchart LR
U([You]) -->|type prompt| UI[chat-ui.js<br/>render and inputs]
UI --> APP[app.js<br/>controller]
APP -->|validate, add message| ST[chat-state.js<br/>history and context]
APP -->|context messages| MS[model-service.js<br/>WebLLM wrapper]
MS -->|WebGPU| GPU[(Your GPU<br/>Llama 3.2 1B)]
GPU -->|token stream| MS
MS -->|chunks| APP
APP -->|update bubble| UI
- Start-up.
app.jsasksmodel-service.jsto initialise. It checks for WebGPU, confirms the chosen model is in WebLLM's list, then downloads (first run only) and compiles the model, reporting progress to the UI. - Ready. The status light turns green and the input unlocks.
- Send. The controller rejects empty or duplicate submissions, stores your message, and sends the system prompt plus the last 12 messages to the model.
- Stream. Tokens arrive as an async stream and are written into the assistant bubble.
- Finish or fail. Controls are restored either way. Errors appear in the page and you can try again.
PocketLLM is plain HTML, CSS and JavaScript, so there is nothing to install or build. It only needs to be served over http://localhost or https (ES modules and WebGPU don't work from file://).
git clone https://Hashim-stack/PocketLLM/.git
cd pocketllm
VS Code "Live Server" extensionOpen http://localhost:8000 in a recent desktop Chrome or Edge, wait for the light to turn green, and say hello.
First run: the model downloads once (roughly 0.7β0.9 GB) and is cached by your browser. Later visits load much faster.
Because PocketLLM is fully static and GitHub Pages serves over HTTPS, it can be hosted for free. The model still runs on each visitor's own device, so you pay nothing for compute.
This repo includes a ready workflow at .github/workflows/pages.yml:
- Push the repo to GitHub.
- Go to Settings β Pages.
- Under Build and deployment β Source, choose GitHub Actions.
- Push to
main(or run the workflow manually). Your site appears athttps://YOUR_USERNAME.github.io/pocketllm/.
Any other static host (Netlify, Cloudflare Pages, Vercel static) works too. Just serve the repo root over HTTPS.
pocketllm/
βββ index.html Page markup and font links
βββ styles.css Theme (design tokens at the top)
βββ src/
β βββ app.js Controller: validation, flow, error handling
β βββ chat-ui.js DOM rendering only
β βββ chat-state.js Conversation data and context trimming
β βββ model-service.js WebLLM init, streaming, stop
βββ .github/workflows/
β βββ pages.yml Deploy to GitHub Pages
βββ CONTRIBUTING.md
βββ LICENSE
βββ README.md
| What | Where | Default |
|---|---|---|
| Model | MODEL_ID in src/model-service.js |
Llama-3.2-1B-Instruct-q4f16_1-MLC |
| WebLLM version | import URL in src/model-service.js |
pinned @mlc-ai/web-llm@0.2.79 |
| System prompt | SYSTEM_PROMPT in src/chat-state.js |
short, helpful, concise |
| Memory length | MAX_CONTEXT_MESSAGES in src/chat-state.js |
last 12 messages |
| Creativity | temperature in src/model-service.js |
0.7 |
| Colors and fonts | :root in styles.css |
cobalt device theme |
Trying another model: pick an ID from WebLLM's supported list, paste it into MODEL_ID, and check its size, memory needs and license first. Bigger models answer better but need more GPU memory and a longer first download. The app verifies the ID exists and tells you if it doesn't.
Updating WebLLM: bump the version in the import URL and test; model IDs can change between releases.
- Browser: a current desktop Chromium browser (Chrome or Edge) is the safest choice. WebGPU support in other browsers varies, so check current compatibility.
- GPU and memory: the default model reports needing roughly 0.9 GB of GPU memory, so it targets modest hardware. Larger models need much more.
- Network: needed for the first load (library, model weights, fonts). After caching it may work offline, but verify this before relying on it.
- β Your prompts and the model's answers are processed in your browser and are not sent to any server operated by this project.
- β Nothing is saved. History lives in page memory and disappears when you reload or click Clear chat.
β οΈ "Local" does not mean "zero network". The browser still contacts external hosts to fetch:- the WebLLM library (jsDelivr),
- the model weights (Hugging Face),
- the page fonts (Google Fonts, optional: delete the three font
<link>tags inindex.htmlto avoid it).
- π Need strict offline behaviour? Open DevTools β Network and confirm what's requested after the first cached load.
- π Check the license and model card of whichever model you choose.
| Problem | Likely cause and fix |
|---|---|
| "WebGPU isn't available" | Use a recent desktop Chrome or Edge. Make sure the page is served from localhost or https, not file://. |
| "No compatible GPU adapter found" | Update your GPU drivers and browser, or try another device. |
| Model "is not in WebLLM's supported list" | Your MODEL_ID is outdated or mistyped. Choose a current one from the WebLLM site. |
| Loading is very slow | It's the first-time download. Later loads use the browser cache. |
| Crashes or errors on a low-memory device | Close other tabs, or switch to a smaller model. |
| Blank page, console shows a module error | You opened index.html directly. Serve it with a local server instead. |
| Answers are wrong or odd | Small models hallucinate. Treat output as a draft, not a fact source. |
- A prompt returns a real model response on a supported device
- Empty input never triggers inference
- Loading and generating states are visible
- A failed model load shows an error and a working Retry, not a dead page
- Clear chat removes all visible messages
- README explains downloads, device needs and privacy
- Streaming responses
- Stop generation
- Light and dark themes
- Regenerate last answer
- Markdown and code-block rendering
- Named conversations
- Optional, opt-in local saving (IndexedDB)
- Export and import chats
- Model picker in the UI
- Settings panel (temperature, system prompt)
- Installable PWA
Small on-device models are far less capable than large hosted ones. Expect shorter reasoning, occasional mistakes and invented facts. Speed depends heavily on your GPU. This project is for learning and prototyping, not for medical, legal or financial advice.
HTML5 Β· CSS (custom properties, no framework) Β· JavaScript ES modules Β· WebLLM Β· WebGPU Β· GitHub Pages
Ideas and pull requests are welcome. See CONTRIBUTING.md.
MIT for this project's code. WebLLM and each model have their own licenses; check them before redistributing or using commercially.
- WebLLM / MLC AI for in-browser inference
- WebGPU samples and MDN for learning resources