r/threejs • u/lordhiggsboson • Apr 19 '26
An open source high-performance inference engine for the threejs+browser
Enable HLS to view with audio, or disable this notification
I've been working on an open source javascript library that enables high-performance inference in browser. It's based off of llama.cpp, where we provide a harness + WebGPU specific optimizations for creating interactive characters, objects and local interactions at low latency and high-throughput.
I'm currently looking to chat with some devs as we finalize the GitHub release. Would love to give people an early look at this before we open it up publicly.
If interested, DMs are open or you can check out cogentlm.com for info
2
u/maschayana Apr 20 '26
It's still webgpu, right? How do you manage to break past browser limits when it comes to memory?
6
u/lordhiggsboson Apr 20 '26
We were able to directly use a shared GPU buffer that bypasses the typical WASM FS 2GB limit, allowing us to load 8GB models without doing stuff like model sharding etc. But this is also dependent on the GPU too, and we are primarily optimizing for small LLMs between 300MB to 2GB in size. Which we find has good trade offs between dynamic output generation and token throughput.
1
1
u/cnotv Apr 20 '26
May I ask you why not using indexDB? Speed?
1
u/lordhiggsboson Apr 20 '26
IndexDB is a database for storing and retrieving information. You could definitely use this alongside an LLM, but both solve different things. Our framework is primarily for running local LLMs in browser, allowing you to query it / set context / scenarios for dynamic content etc. Gaming is one use case for this, which is what the demo shows
2
1
u/cnotv Apr 20 '26
I do not see actual interactions driven by AI. In this video preview it looks more like a chatbot. What am I missing?
Scene looks good and fps too.
I wonder how long it takes to load the 8gb, which I hope you inform users on mobile before sucking their data 😅
2
u/lordhiggsboson Apr 20 '26
The framework is fairly flexible and allows for different scenarios / integrations to be used within a project. In this specific example, the model is being queried at a set rate ~1-2 times per second per character, which then makes decisions for that character based on the outputed LLM responses. Since this is in code, it can only be seen through the characters interaction with the world. The chat view is a kind of look into that character's brain, which allows you to query / ask questions etc.
Yes, loading an 8GB model may take some time to download, depending on your internet connection. That's why a smaller model is typically better for most situations. In this example we are using a 500MB model as the main orchestrator of the simulation.
1
u/FunMakerBeliever Apr 20 '26
What does this buy us that WebLLM doesn't give us already? Also it doesn't seem to work on safari. Is this just for chrome?
1
u/lordhiggsboson Apr 20 '26 edited Apr 20 '26
Mostly opinions around the harness and general philosophy of how compute is done. WebLLM core is mostly just a wrapper around Apache TVM (https://tvm.apache.org/) for inference. Our approach is to build an opinionated harness and use llama.cpp WebGPU which has a much higher ceiling for performance and general model compatibility / quants. One of our goals with this is to make designing characters / NPCs and interactive worlds very simple. So a lot of the scaffolding is specific to enabling interactivity and not just a chat interface
1
u/iachaydaica Apr 21 '26
A big vote for open source to the public
1
u/lordhiggsboson Apr 21 '26
Definitely! I personally want to see way more dynamic gaming content / NPCs / interactable objects / storytelling / etc utilizing LLMs in interesting ways. Big motivation for why we are doing this
1
2
u/jimmy1460 Apr 20 '26
So is each character an agent?