TinyLanguageBuilder

Build a small language model right here, on your own CPU: pre-train it, teach it a task, and chat with it. No GPU, no server, no account. Your text never leaves this browser tab.

New to this? Read The Tiny Textbook: interactive lessons on tokens, embeddings and more.

1. Set up

Training text

Pick your settings, then press Prepare model.

Progress is saved in this browser automatically.

3. Teach it a task

Pre-training teaches a model to continue text. Fine-tuning shows it examples of an instruction and a good answer, so it learns to follow it. Use the built-in task (write a sentence that uses a given word), or teach it your own examples.

Examples to learn from

Available once the model has been trained a while.

4. Learn from preferences

Fine-tuning shows the model good answers, but never what to avoid. Here the model writes several answers per prompt, a checker marks which use the word and finish properly, and it is trained to prefer the good ones over the bad ones (DPO).

Available once fine-tuning has finished.

2. Watch it learn

Step
0
Train loss
–
Validation loss
–
Speed
–

Loss is in bits per byte of text: lower is better, 8 means no idea at all.

  • Train (smoothed)
  • Validation

What the model writes while it trains

  1. Samples appear here as training progresses.

5. Try it

Continue some text

A pre-trained model continues whatever you start.

–

Ask the fine-tuned model

Fine-tune the model first, then type a word and it writes a sentence using it.

  1. –

Save or share the model

Put the files in one folder and the command-line tool can use them: tlm chat --model folder --input "dragon"

Open a model from files

Choose model.safetensors and tokenizer.json (and sft.json to ask it questions). Models made by the tlm command-line tool work too. An opened model can generate text but not train.