Live demo

A chat model,
built end to end.

Every stage of this model ran on code I wrote: the tokeniser, the training framework and its GPU kernels, fine-tuning, evaluation, export, and the inference engine answering you below. It is small (97.5 million parameters): it chats and answers some simple questions, and it gets many facts wrong.

Talk to it

It runs in your browser: ember.cpp is compiled to WebAssembly, the model (221 MB, 16-bit) downloads once, and nothing you type leaves your machine.

If the window stays blank, open it directly: huggingface.co/spaces/johnnyteutonic/ember-chat.

How it was made

Model and tokeniser

paperkiln

A Llama-style decoder: 12 layers, width 768, 12 heads, rotary position embeddings, SwiGLU and RMSNorm, 97.5M parameters and a 512-token context. The tokeniser is byte-level BPE in the Llama 3 scheme (16,384 tokens, with chat role markers); paperkiln's encoder is ported from llama.cpp's, and the trainer and the engine share it.

Pretraining

C++ · CUDA

120,000 steps (0.98 billion tokens) on a cloud L4 GPU, on a mix of FineWeb-Edu educational web text and dialogue (SODA, UltraChat, OpenAssistant, everyday conversations): 27% dialogue for most of the run and 47% over the last 15%. Validation loss reached 2.68. The run survived a reclaimed machine by resuming from a checkpoint with its optimiser state.

Post-training

SFT

Supervised fine-tuning on 313,606 conversations in the chat template (463,695 replies, every assistant turn in the loss), from smol-smoltalk, TinyChat and everyday conversations, each checked against the evaluation sets first: 18,620 steps in BF16, one pass over the data, held-out loss 1.51. I chose it over three other fine-tuned models and the previous model here for its question answering.

Evaluation

frozen prompts

On a 60-question probe of facts, science, arithmetic and follow-up turns it answers 21: 44% of the facts and a third of the science questions, no arithmetic. The previous model here, trained on conversation alone, answered 2. The full-precision file runs unchanged in llama.cpp and Ollama, with the same greedy replies on the frozen prompts.

Serving

ember.cpp

The trained weights are exported to GGUF and loaded by ember.cpp, an inference engine written separately from the trainer. Greedy output is checked token for token against the trainer's own sampler. On a GPU each decoding step is replayed as a captured CUDA graph. Here the same engine runs as WebAssembly in your browser (with the forward pass on your GPU through WebGPU where the browser has it) and gives the same greedy replies as the native build; the 16-bit file gives the same greedy replies as the full-precision one.

What comes next

roadmap

Preference training: replies sampled from this model, ranked by a judge model, then DPO, gated on the same probes. Alongside it, a research programme on how small a model can be and still hold a conversation across many turns, trained on human-written text only.

Code: paperkiln (training) and ember.cpp (inference). Built with the help of AI coding assistants. Training data: TinyChat by starhopp3r, CC BY-NC 4.0, which the model inherits; smol-smoltalk and everyday-conversations (Apache-2.0); FineWeb-Edu (ODC-By 1.0); SODA (Kim et al., 2023; CC BY 4.0); UltraChat 200k (MIT); OpenAssistant (Apache-2.0).