Hello, world
This site is one Cargo workspace compiled to wasm32-unknown-unknown and run as a Cloudflare Worker. There is no JavaScript framework; the browser sends the lines you type and prints the HTML that comes back. Everything else is Rust.
§1Three crates
site- The worker: routing, the shell, sessions, and storage in D1.
latex- A small LaTeX-to-HTML renderer. Posts like this one are written in LaTeX and rendered on save; math is typeset in the browser by KaTeX.
intent- A Burn model that reads what you type into the shell.
§2The model
When input isn’t a command, the shell hashes it into a feature vector x \in \mathbb{R}^{1024} (word unigrams and bigrams, plus character 2-, 3- and 4-grams) and runs a two-layer MLP:
It picks one of 14 intents (ls projects, resume, contact, …, and unknown). Above p = 0.55 the shell runs the command; between 0.30 and 0.55 it suggests it.
#[derive(Module, Debug)]
pub struct IntentNet {
hidden: Linear,
out: Linear,
act: Relu,
}
impl IntentNet {
pub fn forward(&self, x: Tensor<2>) -> Tensor<2> {
self.out.forward(self.act.forward(self.hidden.forward(x)))
}
}
Training data is generated: seed phrases for each intent, expanded with conversational prefixes and suffixes and keyboard typos. It trains in about thirteen seconds on a CPU.
| intent model | |
|---|---|
| generated examples | 5,880 |
| validation accuracy | 95.8% |
| parameters | 99,758 |
| weights (burnpack) | 400 KB |
The weights are embedded in the worker binary and run on Burn’s pure-Rust CPU backend. Try burn what are you working on in the shell to see its top guesses.
§3Writing
Logged in, new post <slug> opens an editor with the LaTeX source on the left and the rendered page on the right. Warnings show up the way pdflatex reports them, with line numbers. :w saves, :publish publishes.