@ondeinference / ed Mirror · read-only
Fork 0

Read-only mirror of github.com/ondeinference/ed.

Mirrored from https://github.com/ondeinference/ed.git

Synced Nov 23, 01:00 UTC

development
md 72 lines 2.66 KB
Rendered Raw
1 # web-chat
2
3 Ed running a model entirely in the browser. The page talks to a Web Worker
4 that owns one `Ed` instance compiled to `wasm32-unknown-unknown`. Nothing you
5 type is sent to a server.
6
7 ## Build and run
8
9 You need `wasm-pack` and the `wasm32-unknown-unknown` target.
10
11 ```bash
12 ./build.sh
13 python3 -m http.server -d www 8080
14 ```
15
16 Open <http://localhost:8080>. No bundler, npm or special headers are needed.
17 Cache Storage needs a secure context, which `localhost` counts as.
18
19 The browser engine comes from `onde` 1.5.0 on crates.io. To try a local `onde`
20 checkout instead, pass a patch through to cargo:
21
22 ```bash
23 ./build.sh --config 'patch.crates-io.onde.path="../../../onde"'
24 ```
25
26 ## Deploy
27
28 The demo is published at <https://ondewebdemo.5mb.app> as a static site on
29 smbCloud (app `ondewebdemo`, in the Onde Inference project). It needs the `smb`
30 CLI 1.1.0 or newer and a prior `smb login`.
31
32 ```bash
33 ./build.sh
34 ./deploy.sh --dry-run # lists the files, uploads nothing
35 ./deploy.sh # publishes, then waits for /version.txt to match
36 ```
37
38 `deploy.sh` ships only `index.html`, `main.js`, `worker.js`, `style.css`, the
39 icons, the two store badges in `badges/`, and the two files in `pkg/` that the
40 page loads. Each deploy is a new release, and
41 `/version.txt` holds the commit it was built from (`-dirty` if the tree had
42 uncommitted changes). The site is static and needs no special headers.
43
44 ## What it downloads
45
46 Qwen 2.5 0.5B (GGUF, about 380 MB), once, on the first click of Download. It
47 is stored in the browser's Cache Storage for this origin, so a reload loads it
48 from disk without downloading again. **Remove model** in the footer deletes it.
49
50 ## Phones and tablets
51
52 Loading the model peaks at about three times the file in memory (the cached
53 bytes, the copy handed to the engine, and the tensors built from it), so a bit
54 over 1 GB. Mobile browsers kill the tab before that. On phones and tablets the
55 page shows a warning instead of starting, with a link to Siti AI in the App
56 Store or Google Play (Onde in a native app) and a **Try anyway** button. The
57 same warning appears on any device whose previous visit was killed while the
58 model was loading. Lowering the peak is work for onde's `web_store`.
59
60 ## Speed
61
62 Inference is CPU only, single threaded, using WebAssembly SIMD. Expect one to three
63 tokens per second on a laptop (measured 1.2 to 2.5 on an Apple Silicon Mac). Stop ends the worker and starts a new one, so it
64 also resets the conversation.
65
66 ## Layout
67
68 - `src/lib.rs`: the wasm-bindgen API (`WebChat`) around `Ed`.
69 - `www/worker.js`: owns the wasm module and the `WebChat`.
70 - `www/main.js`, `index.html`, `style.css`: the UI.
71
72 This crate is excluded from the root workspace and has its own lockfile.