MODULE 01 / 08

The LLM Backbone: Building a RAG-Based Custom GPT from Scratch

Go under the hood of modern LLMs—curate Common Crawl WARC data, train a custom BPE tokenizer, control generation with logits bias / temperature / repetition penalty, and ship a RAG web-summarizer Custom GPT with interactive decoding (greedy, beam, top-k, top-p).

From-scratch RAG backbone: WARC curation → BPE tokenization → logits control → decoding strategies → FastAPI microservice.

pytorchtensorhuggingfacetransformerswarcstreamlituv

You'll Build:

Web Summarizer Custom GPT

Techniques Covered:

  • T01Perform Common Crawl & heuristic filtering on raw WARC web data.
  • T02Build a BPE tokenizer to map text to tokens with a custom vocabulary.
  • T03Adjust logits via logits bias, temperature, and repetition penalty.
  • T04Interactively apply stochastic and deterministic decoding methods (greedy, beam, top-k, top-p).
  • T05Deploy the inference via an API as a production-ready microservice.

Production Goals

  • G01Implement a custom BPE tokenizer, logits adjustment, and major decoding methods (greedy, beam, top-k, top-p).
  • G02Curate web-scale training data with Common Crawl WARC + heuristic filtering—not toy corpora.
  • G03Deploy inference as a FastAPI microservice with a Streamlit playground for interactive decoding control.
The LLM Backbone: Building a RAG-Based Custom GPT from Scratch

The Project Kit

The ML Pipeline

A modular Python codebase structured for readability and scalability:

  • The Data Architect:A custom pipeline for heuristic filtering and fuzzy deduplication of raw web data (Common Crawl).
  • The Vocabulary Logic: A Byte Pair Encoding (BPE) tokenizer implementation with custom vocabulary mapping.
  • The Inference Backbone: A GPT-style engine featuring manual implementations of:
    • Logits Management: Raw score generation.
    • The Sampling Layer: Controllable Temperature, Top-k, and Top-p (nucleus) logic.
    • Advanced Decoding: Fast Greedy Search vs. high-quality Beam Search strategies.

The Full-Stack Core System

An entire system to run the ML pipeline to serve downstream services:

  • Server: A FastAPI server ready for deployment with Pydantic schemas for the API.
  • Visual Playground: A Streamlit frontend with real-time sliders to visualize how parameters change AI behavior.
  • Pre-Commit Quality Hooks: Automated Git scripts that run linting, formatting (Black/Ruff), and syntax checks before every commit.
  • Dependency Management: Ready to use UV and pip for the dependency management.

Portfolio-Ready Documentation

  • README.md: A professional project overview including architecture diagrams, installation guides, and How It Works section designed to showcase your technical depth on GitHub.
  • Project Manifest: A clear breakdown of the system design and tech stack (Python, PyTorch, FastAPI).
repo

Quick-Start Experiment Kit

  • Starter Dataset: A curated sample of refined web data so you can run the pipeline immediately without waiting for a 1TB download.
  • One-Command Setup: A start_app.sh script to handle virtual environment creation and dependency injection in seconds.
1chmod +x scripts/start_app.sh && uv run scripts/start_app.sh
terminal

Tutorial Summary


The Project Kit

The ML Pipeline

A modular Python codebase structured for readability and scalability:

  • The Data Architect:A custom pipeline for heuristic filtering and fuzzy deduplication of raw web data (Common Crawl).
  • The Vocabulary Logic: A Byte Pair Encoding (BPE) tokenizer implementation with custom vocabulary mapping.
  • The Inference Backbone: A GPT-style engine featuring manual implementations of:
    • Logits Management: Raw score generation.
    • The Sampling Layer: Controllable Temperature, Top-k, and Top-p (nucleus) logic.
    • Advanced Decoding: Fast Greedy Search vs. high-quality Beam Search strategies.

The Full-Stack Core System

An entire system to run the ML pipeline to serve downstream services:

  • Server: A FastAPI server ready for deployment with Pydantic schemas for the API.
  • Visual Playground: A Streamlit frontend with real-time sliders to visualize how parameters change AI behavior.
  • Pre-Commit Quality Hooks: Automated Git scripts that run linting, formatting (Black/Ruff), and syntax checks before every commit.
  • Dependency Management: Ready to use UV and pip for the dependency management.

Portfolio-Ready Documentation

  • README.md: A professional project overview including architecture diagrams, installation guides, and How It Works section designed to showcase your technical depth on GitHub.
  • Project Manifest: A clear breakdown of the system design and tech stack (Python, PyTorch, FastAPI).
repo

Quick-Start Experiment Kit

  • Starter Dataset: A curated sample of refined web data so you can run the pipeline immediately without waiting for a 1TB download.
  • One-Command Setup: A start_app.sh script to handle virtual environment creation and dependency injection in seconds.
1chmod +x scripts/start_app.sh && uv run scripts/start_app.sh
terminal