HACKER Q&A
📣 jfoster

What's the idea behind the WebNN API?


The WebNN API will make it possible to run AI models in the browser: https://www.w3.org/TR/webnn/

The idea of having AI in browsers (see the "Application Use Cases") seems cool, but on the other hand, the idea of downloading & storing large models for each website/webapp seems terrible.

It seems to me that it would make more sense to have models built into browsers, and to have a web API that provides standardized ways to interact with the underlying models of each browser. From what I have understood from the WebNN spec, though, despite listing out all of the cool use-cases, the API doesn't seem intended to provide higher level functionality than loading, running & performing operations on a model.

Is my understanding of the API right, or is there something else that uses it to make these use-cases available in browsers?


  👤 lxgr Accepted Answer ✓
Not all neural network models are necessarily very large, or language models:

For example, many chess engines these days are already based on neural networks, and these run pretty well in WASM (for example, Stockfish, one of the strongest engines, has a 7M and a 44M version on lichess.org), but as far as I understand that's mostly because they're optimized for CPU usage.

It would be pretty cool to be able to run similar specialized models on the best execution resources a device has available and not just the CPU (or maybe a GPU via WebGPU).


👤 DavorDK
A great question, went into a small rabbit hole, still don't know how to answer this xD

👤 Oioioioiio
MS and Apple already have/will have/build ai features into the OS and intel is also adding AI cores to laptop CPUs.

So when you have a webbrowser based photo editor or other tools, you can build things which do not require a backend server.

Not everything has to run remote and without such an API you can't use it locally.

Perhaps this will allow me/us to write a website for a local agent as well or an assitant.


👤 1oooqooq
expect browse/os to ship models and website llms will be just like font/colors in the 90s.

web-safe-models heh.



👤 jacobgorm
The question is not whether we need NNs running in the browser, we do, the question is whether WebGPU would be sufficient to cover those needs.