Train a language model in this tab.
Not a scripted demo. A real character-level neural network with embeddings, a hidden layer and a softmax output — trained by backpropagation and Adam, right here in JavaScript. Watch the loss fall from a random guess to recognisable words, then sample from the model you just built. No server, no API key, no downloads: 51,245 parameters on the default corpus and ten seconds on an ordinary laptop.
Press train. Watch it learn.
Every number below is measured in your browser from the model in front of you. Training runs in small slices, so the page stays responsive and the curve draws as it happens.
Setup
Architecture
localStorage only.
Cross-entropy loss
no run yetValidation loss is measured on text the model never trains on.
- Step
- 0
- Tokens
- 0
- Train loss
- —
- Val loss
- —
- Perplexity
- —
- Speed
- —ms
Reading the dashed line. Validation is measured on the last 10% of the corpus. On a corpus this small it usually bottoms out after a few hundred steps and then climbs while training loss keeps falling — overfitting. The ring marks the best validation point; the readout names its step.
Give it a prompt. Read what it predicts.
The model continues your characters one at a time. Temperature is how much risk it takes; top-k keeps the choice inside the k most likely characters. A trained model writes words and fragments — a model this small does not write essays.
Output
waiting for a modelThe continuation appears here, character by character.
Controls
Checkpoint
localStorage · eltes.lab.model.v1Prove it actually learned.
Free generation from a small model is word salad, so here is a test with a pass mark. Give the model one paragraph, over and over, until the loss reaches zero — then ask it to recite from a short prompt. If the weights really changed, the paragraph comes back. Nothing is scripted.
One paragraph
repeated 24×Recital
loss —The model's recital appears here, generated one character at a time from its own weights.
What this model is — and is not.
The point of training your own model is to see how one actually works, not to pretend a 51k-parameter network is a chatbot. Here is the straight answer.
What it is
- A real neural network. One embedding table, one tanh hidden layer, one softmax over the vocabulary. Every weight is trained by backpropagation with Adam, gradient clipping, dropout and weight decay.
- Reproducible. A seeded PRNG initialises the weights and picks every batch, so the same corpus, shape and seed reproduce the same curve.
- Measured, not asserted. Training and validation loss are computed live on a 90/10 split; perplexity is derived from them.
- Yours. The checkpoint is a base64 dump of the weight arrays in
localStorage. No upload, no account, no key.
What it is not
- Not an instruction follower. It predicts the next character; it cannot answer a question, call a tool or follow a request. Ask it for the weather and you will get letters.
- Not a large model. 51,245 parameters on the default corpus against billions in a hosted model — and it is trained on tens of kilobytes of text, not the web.
- Not a writer. Free generation produces word-shaped fragments. Memorisation is the only place it looks fluent, and that is because the text is in the weights.
- Not Eltes CAI. CAI is the separate rule engine that answers product questions; Lab is the model you train here. In chat it is labelled On-device · trained here.
Characters in
Text becomes integer ids through a vocabulary built from the corpus; unseen characters become one unknown token.
Forward pass
The last 14 ids are looked up in the embedding table, concatenated, and pushed through
tanh to 128 hidden units.
Backward pass
Cross-entropy against the true next character gives a gradient for every weight — hand-written backprop, no autograd library.
Adam update
Gradients are clipped by global norm, then Adam steps the weights with bias correction. Repeat.
Train it once. Chat with it after.
Save the checkpoint and open the workspace: Eltes Lab-1 appears in the model picker as an on-device model. It will quote a continuation of what you type and tell you plainly that a character model wrote it.