CoursesMachine Learning
Machine LearningAdvancedSelf-paced
Building Large Language Models from Scratch
This course covers the fundamentals and practical implementation of large language models, including data preparation, attention mechanisms, GPT model implementation, pretraining, and fine-tuning techniques. It is designed for learners who want to understand and build large language models. The course includes introductions to necessary tools and techniques for model development and optimization.
86chapters
216modules
470lessons
86quizzes
Syllabus
86 chapters, 216 modules, 556 lessons and quizzes.
01Getting Started1 modules · 2 lessons
02Introduction to Large Language Models and the Book2 modules · 5 lessons
Understanding the Book Cover
03Understanding Large Language Models2 modules · 7 lessons
Introduction to LLMs
LLMs in the Context of AI and Machine Learning
04Exploring the Diverse Applications of Large Language Models2 modules · 7 lessons
Understanding LLM Applications
Building and Understanding LLM Assistants
05Building and Using Large Language Models2 modules · 5 lessons
Motivation for Building Custom LLMs
06Harnessing Large Datasets for LLMs3 modules · 7 lessons
Understanding Large Datasets for LLMs
GPT-3 Dataset Details
Pretrained LLMs and Fine-Tuning
07Understanding the GPT Architecture2 modules · 7 lessons
GPT Architecture Overview
08Introduction to Word Embeddings2 modules · 7 lessons
What are Word Embeddings?
Word Embedding Techniques
09Converting Tokens to IDs and Implementing a Tokenizer2 modules · 6 lessons
Creating a Vocabulary and Converting Tokens to IDs
10Challenges in Modeling Long Sequences1 modules · 4 lessons
Limitations of Traditional Language Translation Models
11Capturing Data Dependencies with Attention2 modules · 5 lessons
Limitations of RNNs and Introduction to Attention
Self-Attention Mechanism
12Loading Pretrained Weights for Fine-Tuning1 modules · 3 lessons
Understanding Pretrained Weights and Their Importance
13Understanding Weight Parameters in Deep Learning Models1 modules · 3 lessons
14Decoding Strategies for Controlled Text Generation4 modules · 7 lessons
Understanding Text Generation and Decoding Strategies
Modifying the Text Generation Function
Temperature Scaling for Controlled Text Generation
Top-k Sampling for Improved Text Generation
15Saving and Loading PyTorch Model Weights2 modules · 4 lessons
Saving Model Weights
Loading Model Weights and Continuing Training
16Loading Pretrained GPT-2 Weights2 modules · 8 lessons
Downloading and Loading GPT-2 Model Weights
Loading GPT-2 Model Weights into GPTModel
- LessonConfiguring GPTModel for Pretrained WeightsEnroll to open
- LessonHow load_weights_into_gpt Places Pretrained WeightsEnroll to open
- LessonUsing the Pretrained GPT-2 Model for Text GenerationEnroll to open
- LessonExercise 5.5: Measuring Training and Validation Loss for a Pretrained GPT-2 ModelEnroll to open
- LessonComparing GPT-2 Models of Different SizesEnroll to open
17Creating Data Loaders for Text Classification4 modules · 6 lessons
Handling Text Messages of Varying Lengths
Implementing a PyTorch Dataset Class
Creating PyTorch Data Loaders
Exercise: Increasing the Context Length
18Creating Data Loaders for Instruction Fine-Tuning2 modules · 5 lessons
Configuring the Device for Data Loading
19Extracting and Evaluating Model Responses4 modules · 8 lessons
Extracting Model Responses
Evaluating Conversational Performance
Implementing Automated Evaluation
Saving the Fine-Tuned Model
20Evaluating Fine-Tuned Large Language Models7 modules · 8 lessons
Introduction to Evaluating Fine-Tuned LLMs
Using Ollama for Model Evaluation
Querying Ollama Models
Evaluating Model Responses
Scoring Model Responses
Assessing Model Performance
Improving Model Performance
21Introduction to PyTorch3 modules · 9 lessons
Understanding PyTorch and its Components
Deep Learning Fundamentals
Installing PyTorch
- LessonChoosing the Right Python Version for PyTorchEnroll to open
- LessonInstalling PyTorch with CUDA SupportEnroll to open
- LessonVerifying PyTorch Installation and GPU AvailabilityEnroll to open
- LessonPyTorch on Apple Silicon and Alternative GPU OptionsEnroll to open
- LessonVerify Your PyTorch InstallationEnroll to open
22Layer Normalization for Stable Neural Network Training3 modules · 7 lessons
Understanding Layer Normalization
Implementing Layer Normalization
Comparing Layer Normalization and Batch Normalization
23Implementing Feed Forward Networks with GELU Activations2 modules · 5 lessons
Understanding GELU Activation Function
Implementing Feed Forward Neural Network Module
24Tensors and PyTorch Fundamentals3 modules · 9 lessons
Introduction to Tensors
Creating and Manipulating Tensors
25Understanding the Transformer Architecture3 modules · 8 lessons
Transformer Architecture Basics
Transformer Variants and Applications
26Understanding Self-Attention Mechanisms3 modules · 7 lessons
Introduction to Self-Attention
Simple Self-Attention Mechanism
Computing Attention Weights for All Input Tokens
27Self-Attention with Trainable Weights2 modules · 8 lessons
Computing Attention Weights Step by Step
Implementing a Compact Self-Attention Python Class
28Causal Attention in Large Language Models3 modules · 8 lessons
Understanding Causal Attention
Masking Additional Attention Weights with Dropout
Implementing a Compact Causal Attention Class
29Understanding Attention Mechanisms in Large Language Models2 modules · 8 lessons
Attention Mechanisms in LLMs
Advanced Concepts in LLMs
30Fine-Tuning Categories for Large Language Models2 modules · 5 lessons
Understanding Fine-Tuning Approaches
Choosing the Right Fine-Tuning Approach
31Tokenizing Text for Large Language Models3 modules · 5 lessons
Introduction to Tokenization
Tokenization Techniques
Applying Tokenization
32Enhancing Tokenization with Special Context Tokens1 modules · 5 lessons
Modifying Tokenizers and Vocabulary
- LessonUnderstanding Special Context TokensEnroll to open
- LessonUpdating Vocabulary with Special TokensEnroll to open
- LessonModifying Tokenizers to Handle Unknown WordsEnroll to open
- LessonTokenizing and Detokenizing with Special TokensEnroll to open
- QuizSpecial Tokens and Tokenization QuizEnroll to open
33Implementing a Large Language Model Architecture3 modules · 7 lessons
Understanding GPT Model Architecture
Configuring and Implementing the GPT Model
Processing Input Data and Model Outputs
34Preparing the Dataset for Classification Fine-Tuning3 modules · 9 lessons
Downloading and Inspecting the Dataset
Balancing and Preprocessing the Dataset
35Training a Large Language Model4 modules · 10 lessons
Implementing the Training Loop
Model Evaluation and Text Generation
Optimization Techniques
36Fine-Tuning a Pre-Trained LLM for Spam Classification3 modules · 8 lessons
Implementing the Training Loop for Fine-Tuning
Choosing the Number of Epochs and Final Evaluation
37Preparing Datasets for Instruction Fine-Tuning3 modules · 7 lessons
Understanding Instruction Fine-Tuning
Preparing and Organizing Data
38Preparing Text Data and Understanding Attention Mechanisms2 modules · 8 lessons
Text Preparation for LLMs
39Implementing Multi-Head Attention2 modules · 8 lessons
Stacking Single-Head Attention Layers
Efficient Multi-Head Attention Implementation
40Implementing the GPT Model Architecture3 modules · 9 lessons
GPT Model Architecture Implementation
Calculating Parameters and Memory Requirements
Initializing Larger GPT Models
41Instruction Fine-Tuning Summary1 modules · 6 lessons
Overview of Instruction Fine-Tuning
42Constructing a Large Language Model from Scratch4 modules · 5 lessons
Overview of Building a Large Language Model
Stage 1: Implementing LLM Architecture and Data Preparation
Stage 2: Pretraining the LLM
Stage 3: Fine-Tuning the Pretrained LLM
43Introduction to Large Language Models2 modules · 8 lessons
Overview of Large Language Models
44Introduction to Instruction Fine-Tuning for Large Language Models1 modules · 3 lessons
45Byte Pair Encoding for Tokenization3 modules · 5 lessons
Introduction to Byte Pair Encoding
Implementing BPE with Tiktoken
Advantages of Byte Pair Encoding
46Understanding Byte Pair Encoding for Unknown Words1 modules · 3 lessons
47Data Sampling with a Sliding Window for LLM Training3 modules · 8 lessons
Creating Input-Target Pairs
Efficient Data Loading
48Creating Token Embeddings for LLM Training3 modules · 7 lessons
Understanding Token Embeddings
Implementing Token Embeddings
Understanding the Returned Embedding Vector
49Encoding Word Positions in LLMs2 modules · 5 lessons
Understanding Positional Embeddings
50Implementing Transformer Blocks in GPT Architecture2 modules · 5 lessons
Understanding Transformer Block Architecture
51Training and Evaluating Large Language Models2 modules · 6 lessons
Key Concepts in LLM Architecture
52Modifying Pretrained LLMs for Classification Tasks5 modules · 10 lessons
Understanding the GPT Model Architecture
Fine-Tuning the Model
Modifying the Output Layer for Classification
Using the Model for Classification
Exercises and Further Exploration
53Evaluating Model Performance for Spam Classification4 modules · 6 lessons
Converting Model Outputs to Class Labels
Calculating Classification Accuracy
Calculating Classification Loss
Initial Loss Values
54Using a Fine-Tuned LLM for Spam Classification1 modules · 4 lessons
55Fine-Tuning Large Language Models3 modules · 7 lessons
Classification Fine-Tuning
Evaluating Classification Models
Instruction Fine-Tuning
56Preparing Datasets for Instruction Fine-Tuning3 modules · 8 lessons
Downloading and Loading the Instruction Dataset
Understanding the Dataset and Prompt Styles
57Loading Pretrained GPT Models and Evaluating Performance2 modules · 6 lessons
Loading Pretrained GPT Models
58Fine-Tuning Large Language Models on Instruction Data4 modules · 7 lessons
Fine-Tuning a Pretrained LLM
Dealing with Hardware Limitations
Fine-Tuning and Evaluating the LLM
Exercise: Fine-Tuning on the Original Alpaca Dataset
59Wrapping Up LLM Development3 modules · 7 lessons
Next Steps in LLM Development
Staying Current with LLM Research
Final Thoughts on LLM Development
60Simplifying Automatic Differentiation2 modules · 6 lessons
Understanding Partial Derivatives and Gradients
61Evaluating Generative Text Models3 modules · 9 lessons
Text Generation with GPT
Calculating Text Generation Loss
62Text Generation with GPT Models3 modules · 8 lessons
Encoding Input Text and Decoding Output
Model Evaluation and Dropout
Understanding the Text Generation Process
63Understanding and Fine-Tuning Large Language Models3 modules · 11 lessons
LLM Text Generation Basics
Pretraining and Fine-Tuning LLMs
Applying LLMs to Text Classification
64Implementing Multilayer Neural Networks in PyTorch3 modules · 9 lessons
Understanding Model Initialization and Forward Pass
Defining a Multilayer Perceptron in PyTorch
Inspecting Model Parameters
65Efficient Data Loading in PyTorch2 modules · 4 lessons
Creating a Custom Dataset Class
66Implementing a Typical Training Loop for Neural Networks3 modules · 8 lessons
Training a Neural Network in PyTorch
Making Predictions and Computing Accuracy
Exercise A.3: Understanding Model Parameters and Hyperparameters
67Saving and Loading PyTorch Models2 modules · 5 lessons
Saving PyTorch Models
68Optimizing Training Performance with GPUs3 modules · 9 lessons
PyTorch Computations on GPU Devices
Single-GPU Training
69Introduction to PyTorch and Large Language Models2 modules · 8 lessons
PyTorch Fundamentals
70Further Reading and Resources for LLMs5 modules · 9 lessons
Transformer Architecture and Variants
Tokenization Methods
Attention Mechanisms and Layer Normalization
LLM Pretraining and Fine-Tuning
Additional Resources for LLMs
71Understanding Tokenization and Model Configurations3 modules · 6 lessons
Tokenization and Decoding
Data Loading Configurations
72Implementing TransformerBlock and GPTModel3 modules · 8 lessons
TransformerBlock and GPTModel Architecture
Text Generation Techniques
73Practical Exercises for Neural Networks and GPU Acceleration4 modules · 7 lessons
Calculating Neural Network Parameters
GPU Acceleration for Matrix Multiplication
Revisiting Neural Network Parameters
Further Exploration of GPU Acceleration
74Learning Rate Warmup for Stable LLM Training2 modules · 5 lessons
Understanding Learning Rate Warmup
75Cosine Decay for Learning Rate Modulation1 modules · 4 lessons
76Gradient Clipping for Stable LLM Training1 modules · 4 lessons
77Enhancing Model Training with Advanced Techniques2 modules · 8 lessons
Implementing the Modified Training Function
- LessonUnderstanding Linear Warmup in TrainingEnroll to open
- LessonApplying Cosine Decay for Learning Rate ModulationEnroll to open
- LessonGradient Clipping for Stable TrainingEnroll to open
- LessonPutting It All Together: The Modified Training FunctionEnroll to open
- QuizAdvanced Training Techniques QuizEnroll to open
78Introduction to Low-Rank Adaptation (LoRA)1 modules · 4 lessons
79Preparing Datasets for Fine-Tuning3 modules · 5 lessons
Dataset Preparation
Creating PyTorch Dataset Objects
80Parameter-Efficient Fine-Tuning with LoRA3 modules · 8 lessons
Implementing LoRA Layers
Applying LoRA to GPT Models
81Initializing a Pretrained Model for Fine-Tuning2 modules · 5 lessons
Loading Pretrained GPT Models
Evaluating the Pretrained Model's Output
82Loading Pretrained Models for Fine-Tuning1 modules · 4 lessons
83Initializing and Preparing the GPT Model for Fine-Tuning2 modules · 6 lessons
Loading and Verifying the Pretrained GPT Model
Preparing the GPT Model for Classification Fine-Tuning
84Preparing Data for Instruction Fine-Tuning3 modules · 7 lessons
Implementing the InstructionDataset Class
Custom Collate Function for Batching
Masking Out Instruction Sections
86Mitigating the Vanishing Gradient Problem with Shortcut Connections2 modules · 5 lessons
Understanding Shortcut Connections
Analyzing the Effect of Shortcut Connections
87Understanding Models as Computation Graphs2 modules · 4 lessons
Introduction to Computation Graphs
Start Building Large Language Models from Scratch today.
Listed at ₹7,999. Free for you right now.
Building Large Language Models from Scratch