ngxson/wllama
WebAssembly binding for llama.cpp - Enabling on-browser LLM inference
What it solves
wllama 提供了一种直接在 Web 浏览器中运行大型语言模型 (LLM) 的方式,而不需要后端服务器或专用 GPU。它通过将推理引擎带到客户端,消除了对外部基础设施的依赖。
How it works
它作为 llama.cpp 的 WebAssembly (Wasm) 绑定,允许 C++ 推理引擎在浏览器环境中运行。该项目利用 WebAssembly SIMD 进行基于 CPU 的推理,并利用 WebGPU 进行硬件加速的 GPU 推理。为了处理浏览器内存限制(特别是在 2GB ArrayBuffer 限制下),它支持将大型 GGUF 模型文件拆分为更小的分块,以便进行并行下载。
Who it’s for
想要通过使用 OpenAI 相容的 API 将本地 LLM 能力整合到其应用程序中的 Web 开发人员,以及偏好隐私导向或离线可用的 AI 体验,且数据从不离开浏览器的用户。
Highlights
- Hardware Acceleration: Supports both WebGPU for GPU offloading and WebAssembly SIMD for CPU inference.
- Multimodal Capabilities: Supports image and audio file inputs in addition to text.
- Developer Friendly: Provides a fully-typed OpenAI-compatible API and a pre-built npm package.
- Performance Optimizations: Supports splitting models into smaller files for faster parallel downloads and to avoid memory restrictions.
- Non-blocking UI: Runs inference inside a web worker to ensure the browser UI remains responsive.