Status: [UNTESTED] Endpoints found: http://127.0.0.1:8787/api/generate Source: https://github.com/lifesahaskell/rusty-gpt # rusty-gpt A GPT trained from scratch in Rust on top of [Burn](https://burn.dev). The crate stacks five progressively richer models — embedding → single-head attention → multi-head attention → full transformer (MiniGPT) → mixture-of- experts transformer (MoeGPT) — so the codebase reads as a teaching arc. It ships an Axum HTTP API and a React UI for poking at attention matrices and expert routing interactively. ## Quick start ```bash # Container dev stack: API at :8787, UI at :5173, hot reload on both. docker compose up # Or natively (Rust 1.93+): cargo run --bin rusty-gpt -- --serve --load-latest-checkpoint cargo test # Train a MiniGPT from scratch on the bundled Shakespeare corpus. # One-time: build the BPE tokenizer (writes checkpoints/tokenizer.json). cargo run --bin train-tokenizer -- --corpus data/input.txt \ --vocab-size 2048 --output checkpoints/tokenizer.json # Then train MiniGPT (defaults to 1000 steps on CPU; add --release for speed). cargo run --release # Train the MoE variant with four experts and top-2 routing. cargo run --release -- --model moe-gpt --moe-experts 4 --moe-top-k 2 ``` Open VS Code with the *Dev Containers* extension to pick between a CPU dev environment and a CUDA one ([details](docs/development-runbook.md#container-based-development-recommended)). ## Highlights - **Five models, one progression** — [src/model/definitions.rs](src/model/definitions.rs) builds up from a trivial embedding head to a full pre-norm transformer block, each variant runnable on the same training loop. - **Two backends from one binary** — CPU (`ndarray`) by default, CUDA opt-in via the `cuda` Cargo feature; no recompile to swap. - **Self-describing checkpoints** — every `.mpk` ships with a `.metadata.json` sidecar (shape, tokenizer hash, training config, git commit), validated on load. - **Graceful interrupt** — Ctrl-C (or `SIGTERM`) during a MiniGPT training run completes the current step, writes a partial checkpoint