Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Build Your Own ChatGPT: LLM & Transformers From Scratch
New
Rating: 5.0 out of 5(5 ratings)
29 students

Build Your Own ChatGPT: LLM & Transformers From Scratch

Learn how ChatGPT works inside: code tokenizers, attention and a GPT model step by step, then train it to write text
Last updated 11/2026
English
English

What you'll learn

  • Build a GPT-style large language model from scratch in Python and PyTorch, without ready-made transformer layers
  • Explain self-attention, Query/Key/Value, the causal mask and multi-head attention with clear visual intuition
  • Code tokenization (character-level and Byte-Pair Encoding), embeddings and positional encoding by hand
  • Implement a complete transformer block with layer normalisation, residual connections and a feed-forward network
  • Train a transformer on a laptop CPU and read loss curves to diagnose learning and overfitting
  • Generate text with temperature, top-k and top-p sampling, and visualise next-token probabilities and attention
  • Build an interactive AI playground web app with Gradio to demo your own language model
  • Explain how GPT, ChatGPT, BERT and the original Transformer relate, including pre-training, fine-tuning and RLHF
  • Answer common transformer interview questions with confidence

Coding Exercises

This course includes our updated coding exercises so you can practice your skills as you learn.

See a demo
Image of coding exercise example

Course content

7 sections • 19 lectures • 1h 4m total length
  • Welcome: see what you will build3:23

    Watch the model you will build write Shakespeare live, and see the roadmap from an empty folder to a working AI app.

  • Why transformers changed everything4:12

    How transformers replaced RNNs, the 2017 breakthrough behind ChatGPT, and where transformers are used today.

  • How LLMs Work

Requirements

  • Basic Python programming (functions, classes, lists, loops)
  • A computer with Python 3.9 or newer. No GPU required
  • No prior deep learning or advanced maths needed. Every concept is explained visually first

Description

This course contains the use of artificial intelligence.
Ever wondered what really happens inside ChatGPT? In this course, you'll find out by building one yourself.

Build Your Own ChatGPT takes you from zero to a working GPT-style language model, written in Python. No black boxes and no shortcuts. You'll write every line and understand why it works.

What you'll build, step by step:

  • A tokenizer: use byte-pair encoding to turn raw text into tokens and numbers

  • Embeddings: represent tokens as vectors the model can learn from

  • Self-attention: queries, keys, values, causal masking and multi-head attention

  • The transformer: feed-forward layers, residual connections and layer normalization

  • Training: train your model on real text and watch the loss fall

  • Text generation: sample from your model and chat with your own GPT

Every concept is explained visually first and then coded from scratch, so the math becomes clear and the code makes sense.

Who this course is for:

  • Developers who use LLMs and want to understand how they really work

  • Students and data scientists moving into AI and NLP

  • Anyone curious about the technology behind ChatGPT

Requirements: basic Python. Familiarity with high school math helps, and everything else is taught along the way.

By the end, you won't just use AI. You'll know how to build it.

Enroll now and start building your own ChatGPT today.


Who this course is for:

  • Curious learners who prefer code over hype
  • Python developers who want to understand how ChatGPT and large language models really work
  • Students and data scientists moving into Generative AI and deep learning
  • Software engineers preparing for machine learning or AI engineering interviews
  • Professionals who use LLM tools or APIs and want to see what happens inside the black box
  • Educators and tech leads who need to explain transformers clearly to their teams