Moka
A cute Go-playing model.
Moka v1 is a 104,129-parameter policy and value network for 9×9 Go. Its 112 KB INT8 weights run entirely in the browser. With 64-visit search, this artifact won 117 of 300 fresh games against KataGo b6c96, compared with 113 for the previous artifact on the same openings.
Moka was distilled from KataGo b6c96 using teacher games and positions reached by Moka’s own rollouts.
Browser payload
| Path | Weights | Runtime | Total load |
|---|
| Moka v1 · INT8 | 100 KB | 4 KB | 103 KB |
| KataGo b6c96 · ONNX | 4.1 MB | 12.8 MB | 17.0 MB |
Moka’s browser path is about 165× smaller than the teacher path. The point is not to replace KataGo. It is to put a learned Go player inside an ordinary webpage.
Browser performance
Moka runs inference in a Web Worker, which keeps model execution off the main thread.
| Metric | Latency |
|---|
| Initialization | 10.1 ms |
| Mean inference | 9.0 ms |
| p50 inference | 8.8 ms |
| p95 inference | 9.6 ms |
These are the medians of five Chromium runs on Apple Silicon. Each run measured 100 positions after 10 warmups. Latency includes Worker messaging; inference stays off the main thread.
Embed Moka on a site
Embed Moka by serving its browser client, worker, manifest, and weights with your site. The example below runs without a framework or bundler.
Build and copy the browser assets
Build Moka from this repository, then copy its four runtime files into your site’s public directory.
ni
nr build
mkdir -p ../your_site/public/moka
cp dist/index.js ../your_site/public/moka/index.js
cp dist/worker.js ../your_site/public/moka/worker.js
cp model/go-model.json ../your_site/public/moka/go-model.json
cp model/go-model.bin ../your_site/public/moka/go-model.bin
The deployed site should serve these files from /moka. Use different URLs in the initialization options if you choose another directory.
Initialize Moka in the browser
Run this code from a JavaScript module, such as an app.js file loaded with type="module".
import {
GoModelWorkerClient,
createGameState,
encodeStudentFeatures,
playMove,
selectHighestLegalMove,
} from "/moka/index.js";
const mokaWorker = new Worker("/moka/worker.js", {
type: "module",
});
const moka = new GoMode