How a 34 MB model runs this guard

You type at a castle guard until he opens the gate. Each line goes through a 34 MB model running in your browser tab, which decides if you're being friendly, bribing him, threatening him, lying, or talking nonsense. That takes about 6 to 11 ms on a laptop. Load the page once and it keeps working in airplane mode.
How it works
The model only answers one question: which of those five things did you just say? Everything else is ordinary game code.
- The model is Dopp's Tiny base (bge-small, int8) trained on a few hundred labelled lines of things a traveller might say. It runs with onnxruntime-web.
- The guard's replies are all hand-written. When he names what you offered ("A pie? Don't wave it at me"), that's a word list picking out the pie, not the model.
- The rules are plain code too. Each night he wants something (food, manners, company, or a real gift), gifts wear off, and he needs more than one kind of reason. Spamming bribes doesn't work.
His read of you is on screen ("read: bribe 91%"), so when he gets you wrong you can see how sure he was. Warm lines about the cold weather sometimes read as threats. That's the model being small.
Make your own
If your app keeps asking the same question about some text (is this spam, what does the player want, which intent is this), it's the same recipe:
- Make a route on dopp.sh and write the question, one sentence per answer.
- Add examples: your real requests, pasted lines, or generated ones for the answers you're short on.
- Check the labels. That's the part that matters most.
- Train Tiny and look at how it does on lines it never saw.
- Download it and load it in the browser with the loader from the game's code, or run it as a small local API.
Dopp is open source: github.com/doppsh/dopp. If a line fools the guard in a funny way, send it to @justkrup.