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
- Write a tokenizer that turns text into numbers.
- Build self-attention and stack it into transformer blocks.
- Train on a GPU, tracking loss, and sample text as it improves.
- 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.
More projects
- Intermediate AI agents for business Plan, use tools, ask a human A support agent that checks orders, follows policy and issues refunds.
- Advanced Diffusion model Text-to-image, from scratch A U-Net that turns static into images it was asked for.
- Advanced Self-play game AI AlphaZero-style learning Search plus neural networks, improving by playing itself.
Your child can build this
This project is part of Research Tutorial. Start with a free class and we will find the right level.