Purpose: wllama is a WebAssembly binding for llama.cpp, with the goal of completing large language model inference directly in the browser, without relying on backend services or a GPU.
Main capabilities: runs inference based on WebAssembly SIMD; supports WebGPU; supports multimodality (image and audio file input); supports tool calling; provides a fully typed OpenAI-compatible API; no runtime dependencies; can split models into multiple small files for parallel loading; automatically switches between single-threaded and multi-threaded builds based on browser support; inference is executed inside a worker, without blocking UI rendering.
Usage: import via the prebuilt npm package @wllama/wllama. Enabling multithreading requires adding Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy response headers. Models are recommended to be split into chunks of at most 512MB, to speed up parallel downloads and avoid memory issues; Q4, Q5, or Q6 quantization is recommended, while IQ (imatrix) is not recommended, as inference may be slow and quality low. The upper limit for a single file is 2GB (limited by ArrayBuffer); if exceeded, use llama-gguf-split to split it, and passing the URL of the first chunk when loading will automatically load all of them. WebGPU is automatically enabled starting from V3.1, with all layers offloaded to the GPU by default; when VRAM is insufficient, it can be adjusted via the n_gpu_layers parameter of LoadModelParams. A custom logger can be passed in to suppress debug information. The repository provides examples such as basic completion, embeddings and cosine distance, multimodality, tool calling, and decision models.
Limitations: The Wasm binary is not prebuilt with the repository; compiling it yourself requires installing Docker; multithreading depends on specific response headers; the single-file limit is 2GB; LoRA adapter support is not yet provided, and multi-sequence support is also not provided.