Skip to content
Now boarding New: every course now has a coding preview video — five lines, C++ to SAS. See new lines Code WELCOME10 takes 10% off your first ticket · 14-day refund
AI Line New

Train a Small Language Model from Scratch

Build and train your own transformer language model in PyTorch, from tokenizer to text generation.

  • Advanced
  • 21 lessons · 4h 3m of video
  • 147 students
  • English
  • Updated Oct 2026
Coding preview Train a Small Language Model from Scratch

The route

Curriculum

5 modules · 21 lessons · 4h 3m of video

  1. 1

    Tokenizers

    4 lessons

    41m
  2. 2

    Attention from scratch

    5 lessons

    58m
  3. 3

    The transformer block

    4 lessons

    49m
  4. 4

    Training at small scale

    5 lessons

    1h 1m
  5. 5

    Sampling and evaluation

    3 lessons

    34m

Destination

What you will be able to do

  • Build a byte-pair tokenizer
  • Implement self-attention and transformer blocks
  • Write a stable training loop
  • Measure loss and perplexity
  • Generate text with temperature and top-k sampling

Before you board

You will need

  • Confident Python
  • Basic understanding of neural networks

About this course

The journey

The best way to understand language models is to build one. You write every part yourself in PyTorch: a tokenizer, embeddings, self-attention, transformer blocks, the training loop and sampling.

Then you train a small model on a public-domain text collection on a single GPU or a free cloud notebook, measure it, and generate text with it. Nothing is hidden behind a library call.

Frequently asked questions

Still unsure about something? Write to our contact page and a human answers, usually the same working day.

Advanced. It assumes solid everyday experience with the language.

No. You pay once and keep lifetime access, including every future update to this course.

Yes. The preview video at the top of this page shows real code from the course being written and run.

Checkout is handled on our provider's secure payment page. The moment your payment clears we email your personal access link and access code to the address you used at checkout, and the same link appears in your account library. There is nothing to install and nothing to wait for.

Email within 14 days of your purchase, quote your order number, and we refund the full amount to your original payment method. No form to fill in and no questions about how much of the course you watched.

What students say

No reviews yet

Nobody has reviewed this course yet, so there is no score to show. Buy it, work through it, and your review could be the one that helps the next developer decide.

€97 EUR

One-time payment · lifetime access

Timetable updates

New lines, first. One email when something departs.

Release notes for new courses and major updates to the ones you own, plus launch fares for subscribers. No digest padding, unsubscribe in one click.

By subscribing you agree to our Privacy Policy.