sahanav@rust:~/blog$ pdflatex hello-world.tex
This is latex.rs, Version 2027.6.0 (rust, wasm32-unknown-unknown)
(./hello-world.tex) [1]
Output written on hello-world.html (329 words).

Hello, world

rustlatexburnmeta

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:

p(y \mid x) = \operatorname{softmax}\big(W_2 \, \mathrm{ReLU}(W_1 x + b_1) + b_2\big), \qquad W_1 \in \mathbb{R}^{96 \times 1024}.

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 examples5,880
validation accuracy95.8%
parameters99,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.