WebLLM is a high-performance, in-browser inference engine designed to execute large language models (LLMs) locally without server-side dependency. By leveraging WebGPU for hardware acceleration and WebAssembly for performance-critical operations, the engine enables complex tasks like structured JSON generation directly within the browser. The framework is fully compatible with the OpenAI API, supporting features such as streaming chat completions, JSON mode, and seeding. It offers extensive model support, including the Llama (3 and 2), Phi (1.5, 2, and 3), Gemma, Mistral, and Qwen families. To optimize user experience and performance, WebLLM supports offloading computations to Web Workers or Service Workers and provides multiple caching backends, such as IndexedDB, the Cache API, and the Origin Private File System (OPFS). Developers can integrate the engine via NPM, Yarn, or CDN, and can deploy custom models in MLC format. Furthermore, the project includes security features like Subresource Integrity (SRI) hash verification for model artifacts to ensure the integrity of downloaded weights and WASM libraries.

Read original