A 1.5B-Parameter Reasoning Model Running Locally in Your Browser with WebGPU
Running a 1.5B-parameter model locally in the browser eliminates the two structural problems of remote APIs: per-token costs that become uncontrollable at scale, and the security risk of sending user context over HTTP. WebGPU support in browsers has matured to the point where a four-file React project can serve as a complete inference runtime, making on-device AI accessible through a link rather than a native install.
A single-page application built with React, Vite, TypeScript, and TailwindCSS loads the ONNX version of DeepSeek-R1-Distill-Qwen-1.5B and executes it locally through the browser's WebGPU runtime. The architecture uses four files — `index.html`, `main.tsx`, `App.tsx`, and `index.css` — to create a complete inference pipeline that never sends user data to a remote server.
The state machine inside `App.tsx` handles WebGPU capability detection, model download progress tracking, error display, and a progressive-enhancement fallback for unsupported browsers. TailwindCSS utility classes inline all styling decisions, eliminating the need for a separate stylesheet beyond a single `@import` directive.
The project demonstrates that the browser is becoming a viable first-party runtime for AI inference. A 1.5-billion-parameter distilled reasoning model, converted to ONNX and loaded through Transformers.js, can run entirely on the user's GPU with zero installation — just a URL.
The project's architecture is deliberately minimal — four files with unidirectional dependencies — proving that WebGPU inference does not require a complex build pipeline or backend server.
Defensive initialization of `loadingMessage` to `'出错了'` (Error occurred) rather than `'加载中...'` (Loading...) is a small but sharp design choice: if a code path fails to update the message before display, the user sees a meaningful error instead of a misleading loading state.
TailwindCSS's atomic class names (`flex`, `items-center`, `justify-end`) map more cleanly to LLM-generated code than custom CSS, which explains why the framework is becoming the default for AI-assisted UI development.
The commented-out `setTimeout` in the codebase reveals a bottom-up development strategy: validate UI state transitions with simulated delays before wiring up real asynchronous model loading.
The technology chain — DeepSeek R1 → Distillation → Qwen 1.5B → ONNX → Transformers.js → WebGPU — represents a series of capability sacrifices (size, precision, format) that ultimately trade raw power for the accessibility of a URL-based deployment.