Advanced level

GPT from scratch

A transformer language model written line by line in PyTorch: tokenizer, attention, training loop and sampling. This small one learned to write by reading Shakespeare. Students then fine-tune a real open model with LoRA for a task of their own.

Where you see it
ChatGPT, Claude, Gemini and every modern chatbot
Time to build
About 6 weeks

How it works

  1. Write a tokenizer that turns text into numbers.
  2. Build self-attention and stack it into transformer blocks.
  3. Train on a GPU, tracking loss, and sample text as it improves.
  4. Fine-tune an open model with LoRA, and measure whether it got better.

Your child learns

  • How tokens, embeddings and attention work
  • Writing and training a transformer in PyTorch
  • Fine-tuning with LoRA on your own data
  • Evaluating language models honestly

Try this

  • Pick a character and press Write
  • Move the slider to Careful, then to Creative
  • Click an odd letter to see what else it considered
  • Type your own start, like: My lord,

The model on this page has about 800,000 parameters, tiny next to ChatGPT, so you can see every choice it makes. It was trained by Lernixa teachers and runs entirely in your browser.

Your child can build this

This project is part of Research Tutorial. Start with a free class and we will find the right level.