Matt Rickard

Share this post

Implementing LLMs in the Browser

blog.matt-rickard.com

Discover more from Matt Rickard

Thoughts on engineering, startups, and AI.
Continue reading
Sign in

Implementing LLMs in the Browser

Apr 30, 2023
3
Share this post

Implementing LLMs in the Browser

blog.matt-rickard.com
1
Share

LLMs are coming to the browser. While it’s still really slow, running these computations on clientside is much cheaper. And the browser is the ultimate delivery mechanism — no downloading packages, setting up a programming environment, or getting an API key. But, of course, they won’t be used clientside for everything — initially just testing, playgrounds, and freemium getting-started experiences for products. 

There are generally two strategies for getting LLMs working in the browser:

Compile C/C++ or Rust to WebAssembly. Take a fairly vanilla library like ggml and use emscripten to convert it to WebAssembly (Wasm fork of ggml, WasmGPT). Optionally, target the new WebGPU runtime like WebLLM.

Implement transformers in vanilla JavaScript. Transformers.js. These models don’t have the most complicated architecture. Typically, they can be implemented in less than a thousand lines of code (nanoGPT is 369 lines, with comments). You might also target WebGPU with this strategy, like WebGPT.

Now, combine a WebAssembly LLM in the browser with a WebAssembly Python interpreter in the browser, and you might get some interesting applications that are sandboxed by default. 

WebGPU will ship on May 2nd in Chrome. WebGPU exposes more advanced GPU features and general computation primitives (unlike WebGL). 

3
Share this post

Implementing LLMs in the Browser

blog.matt-rickard.com
1
Share
Previous
Next
1 Comment
Share this discussion

Implementing LLMs in the Browser

blog.matt-rickard.com
Ankesh Bharti
Writes The Westworld Dream
Jul 16·edited Jul 16

Can we generate embeddings and store it as vectors for WebLLM's context, all inside browser? Main goal being providing a all in one local in browser solution for Freemium LLM users for an app I'm planning to build.

Expand full comment
Reply
Share
Top
New
Community

No posts

Ready for more?

© 2023 Matt Rickard
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing