Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

freeCodeCamp

LLM from Scratch Tutorial - Code and Train Qwen 3

via freeCodeCamp

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Learn how to build a Large Language Model from the ground up in this comprehensive tutorial that walks you through creating Qwen 3 line by line. Master the fundamental concepts of transformer architecture while implementing key components including grouped query attention logic, RoPE positional embeddings, self-attention mechanisms, and feed-forward networks with SwiGLU activation. Explore advanced optimization techniques using the Muon optimizer and understand the intricacies of model configuration and training hyperparameters. Follow along with hands-on coding as you set up data loading and tokenization processes, implement the complete model architecture, and establish evaluation metrics. Experience the complete machine learning workflow from initial setup through the training loop execution, culminating in inference and text generation capabilities. Watch gradients flow and observe how neural networks learn in real-time while building one of the most advanced language models available today.

Syllabus

⌨ 0:00:00 Intro & Demo
⌨ 0:01:46 Qwen 3 Architecture
⌨ 0:02:36 Prerequisites
⌨ 0:04:01 Code Setup & Imports
⌨ 0:05:26 Model Configuration
⌨ 0:08:26 Qwen 3 Specifics
⌨ 0:12:24 Training Hyperparameters
⌨ 0:17:18 Grouped Query Attention Logic
⌨ 0:18:56 Muon Optimizer Explained
⌨ 0:29:02 Data Loading & Tokenization
⌨ 0:32:37 RoPE Positional Embeddings
⌨ 0:36:56 Self-Attention Code
⌨ 0:44:28 Feed-Forward & SwiGLU
⌨ 0:47:36 Building the Final Model
⌨ 0:52:34 Evaluation & Optimizer Setup
⌨ 0:54:08 The Training Loop
⌨ 0:55:43 Running the Training
⌨ 0:58:38 Inference & Text Generation
⌨ 1:00:51 Final Results

Taught by

freeCodeCamp.org

Reviews

Start your review of LLM from Scratch Tutorial - Code and Train Qwen 3

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.