project record

llama.cpp in a browser tab

indexprojectsfig. p-08

fig. no.
p-08
kind
project · internal R&D at Tmotions
period
February – June 2023
status
archived
stack
WASM · Emscripten · ggml
repository
none · died with the laptop

fig. p-08 · retrieved from memory

Layered stack diagram: Brave and Node on top, a JavaScript adapter, the Emscripten module with generated glue and main.wasm, then the original C++ sources unchanged.
fig. p-08.1 · the stack, as reconstructed · drawn for this site

the problem

Final semester of college, 2023, on a backend internship at Tmotions. I wanted a language model to run where I already was, in a browser tab, without sending the weights out of the machine. llama.cpp already knew how to do inference. The browser did not look like Linux. This was internal R&D on internship time, not coursework.

what I did

I compiled ggml and llama.cpp with Emscripten, then wrote a JavaScript runtime adapter so the same .wasm could load a quantised model, tokenise, and run inference in Node and in Brave.

I did not port llama.cpp. I compiled main and called it from JS. The adapter is the host OS that WASM does not have: it creates the module, feeds it a fake filesystem, intercepts printf, and dumps the text into the DOM.

method

Linear memory was the bottleneck, so the models stayed small. The test was crude and honest: does a token appear in Brave. The chat UI had an anime girl for an avatar, blue and pink hair, white cyberpunk clothes. She was decoration, not a character.

what I found

The interesting work was not the model. It was making a browser look enough like a host that an unmodified binary would start. Most of the difficulty was systems work, not machine learning, and that ratio has held for every local-inference project since.

open

The source died with the laptop. This record is part memory, part reconstruction, and it does not claim that every compiler flag is remembered correctly. A rebuilt demo is still owed.