Artificial Intelligence & LLM Engineering

Ultimate AI Engineering: Build a Local Small Language Model

Build, wrap, and deploy a custom Small Language Model (SLM) from scratch using PyTorch. Learn model streaming, local Chat UIs, production APIs, and custom web scraping data pipelines.

Intermediate 24 Hours English 21 Lessons 0 graduates
Free
Login to Enroll for Free
Certificate of Completion Included
What You Will Learn
  • Set up a clean Python machine learning environment with PyTorch and CUDA architectures.
  • Tokenize raw text datasets using Byte-Pair Encoding (BPE) and manage disk memory footprints with NumPy memmap.
  • Engineer a Decoder-Only Transformer architecture from scratch with Multi-Head Self-Attention layers.
  • Train a neural network locally using AdamW, Cross-Entropy Loss, and Gradient Accumulation parameters.
  • Wrap custom weights in production interfaces, creating responsive interactive CLIs and professional local browser Chat UIs.
  • Securely serialize models into Safetensors formats and host scalable local APIs using FastAPI framework topologies.
  • Design data extraction pipelines, program automated web scrapers, and clean text strings to generate tokenized binary datasets for future custom SLMs.
Requirements
  • Proficiency in Python programming fundamentals.
  • A local machine with Python 3.10 or 3.11 installed.
  • Basic familiarity with command line terminal operations.
  • A dedicated CUDA-enabled GPU is recommended for acceleration, but standard modern CPUs are fully supported.
Description

The Local SLM Masterclass

This course cuts through the hype and teaches you how to build, train, run, wrap, and deploy a Small Language Model (SLM) entirely on your local machine using Python and PyTorch. Moving away from massive API black-boxes, you will engineer a custom Decoder-Only Transformer from scratch, develop your own web-scraping pipelines, and serve models through interactive UI architectures.

The Project Goal: We will use the Hugging Face TinyStories dataset to train an SLM capable of generating coherent, grammatically correct short stories. This dataset uses a highly compact vocabulary, making it fun, fast, and easy to train on standard consumer GPUs or modern CPUs. Following that, you will design custom data scrapers to collect, clean, and tokenize targeted training data for your next model iteration.

© A proprietary course creation by Surya Partap Singh. All Rights Reserved.

Course Curriculum 21 Lessons
Chapter 1: Groundwork & Environment 2 Lessons

Isolating your workflow, configuring Python, and installing the required ML stack dependencies.

Lesson 1: System Prep & Virtual Environments
Lesson 2: Installing the ML Stack and Configuring VS Code
Chapter 2: Data Engineering & Tokenization 3 Lessons

Acquiring the TinyStories dataset, understanding tokens, and writing large data to disk efficiently.

Lesson 3: Introduction to TinyStories & Code Framework
Lesson 4: Byte-Pair Encoding (BPE) with Tiktoken
Lesson 5: Memory Mapping & Binary Storage Processing
Chapter 3: Building the Data Pipeline 2 Lessons

Creating PyTorch data loaders, handling context windows, and mapping input-output training pairs.

Lesson 6: Context Windows & Input-Output Shifting Theory
Lesson 7: Creating the PyTorch DataLoader
Chapter 4: Architecting the Transformer 3 Lessons

Coding the neural network structure, including embeddings, attention mechanisms, and linear layers.

Lesson 8: The Embedding Layers
Lesson 9: Multi-Head Self-Attention Blocks Integration
Lesson 10: The LM Head and Loss Calculation Engineering
Chapter 5: Training & Generation Engines 4 Lessons

Optimizing the model weights, running the training loop, and writing the text generation script.

Lesson 11: The Optimizer & Evaluation Loop Engineering
Lesson 12: Running the Local Training Loop
Lesson 13: Auto-Regressive Text Generation Systems
Lesson 14: Probability Distribution Sampling & Story Output
Chapter 6: Model Serving & User Interfaces 2 Lessons

Wrapping custom language weights in consumer interfaces, building interactive command-line loops, and deploying graphical local Chat UIs.

Lesson 15: Building an Interactive Command Line Interface (CLI)
Lesson 16: Building a Graphical Local Chat UI with Streamlit
Chapter 7: Packaging & API Deployment 2 Lessons

Optimizing model serialization using modern secure storage formats and exporting the network as a high-performance web API.

Lesson 17: Model Storage Serialization (Safetensors Format)
Lesson 18: Hosting the Model as a Web API via FastAPI
Chapter 8: Custom Dataset Engineering & Web Scraping 3 Lessons

Building custom datasets from scratch, engineering automated web scrapers to target domain-specific text, and preprocessing raw strings into tokenized files for future SLM projects.

Lesson 19: Methodology for Designing Custom Text Corpora
Lesson 20: Building a Domain Web Scraper for Custom Training Data
Lesson 21: Preprocessing and Tokenizing Corpora for the Next SLM