DL Methods

How deep learning models are actually built: PyTorch from tensors up, the architecture families, and the LLM and RAG systems assembled on top.
Author

Benedict Thekkel

Where DL Tasks answers “which model solves this problem”, this site answers “how does the model work and how do I build one”. It runs from PyTorch fundamentals through the classical architecture families to the retrieval and agent systems that current work is mostly made of.

The two halves are quite different in character. The PyTorch and architecture pages are long, worked, and stable; the LLM and RAG folders are a large set of focused pages, one per stage of a pipeline, reflecting that this is where the field is moving fastest.


PyTorch

The foundation, and the longest pages on the site.

Page Covers
PyTorch Basics Tensors and operations, at 218 cells the most thorough page here
Model Creation Assembling modules into a network
Training Loop The loop itself, written out rather than hidden behind a framework
Datasets and DataLoaders Getting data in efficiently, which is usually the bottleneck
Transforms Preprocessing and augmentation
Save and Load Checkpointing, and the distinction between weights and whole models
timm Loading pretrained vision models from the library that collects them
Transfer Learning Adapting a pretrained ResNet-18 rather than starting from noise
Evaluation Metrics How performance is measured, with detection metrics in particular
Model Diagrams Rendering an architecture as a picture
TensorFlow The alternative framework, covered briefly through its graph model
PyTorch Setup Marked OLD; kept for reference

Architecture Families

One page per family, each covering the idea, the mechanics, and where it is still the right choice.

Page Covers
Overview The map of everything below
FNN Feedforward networks, the starting point
CNN Convolutional networks, and why they suit images
RNN Recurrence for sequences
LSTM Gating that fixes the vanishing gradient
GRU The simplified version of the same idea
Transformers Attention, which displaced most of the above
Autoencoders Learning a compressed representation
GAN Two networks trained against each other
RBM Restricted Boltzmann machines
DBN Deep belief networks stacked from them

Building Models by Hand

Implementations written from scratch, which is the fastest way to find out what the abstractions were hiding.

Page Covers
MNIST from Scratch in NumPy A neural network with no framework at all, forward and backward pass written out
Simple CNN in PyTorch The same problem with the framework back on
ResNet-18 from Scratch Building the residual architecture layer by layer
ResNet-18 with fastai The same result in a fraction of the code, as the contrast

Computer Vision

Page Covers
Image Classification One label per image
Multi-Label Classification Several labels at once
Object Detection Locating and labelling
Semantic Segmentation Classifying each pixel
Instance Segmentation Separating individual objects of the same class
Panoptic Segmentation Both of the above at once
Car Detection A worked application

LLMs

Page Covers
LLM Class Wrapping model access behind one interface
Ollama Running models locally
OpenAI SDK Calling a hosted API directly
LangChain The orchestration framework
OpenAI with LangChain The two combined

LLM Pipeline Patterns

Seven pages, one per pattern, ordered from least to most autonomous. Start with the overview.

Page Covers
Pipeline Designs The overview and how the patterns relate
Prompt Chaining Output of one call feeding the next
Routing Classifying the request, then dispatching to the right handler
Parallelization Running independent calls at once and combining them
Orchestrator-Workers A planner decomposing work across workers
Evaluator-Optimizer Generating, critiquing, and revising in a loop
Autonomous Agents The model choosing its own next step, and the cost of that

RAG

The most systematic part of this site: nineteen pages walking the retrieval-augmented generation pipeline stage by stage, then the concerns that sit across all of it. The retrieval and re-ranking pages restrict themselves to open-source components.

The pipeline, in order

Page Covers
RAG The overview, and what the rest of the folder expands
Document Pre-processing Getting source material into a usable state
Chunking Splitting documents, which sets the ceiling on everything downstream
Embedding Turning chunks into vectors
Indexing Storing them so they can be searched
Query Transformation Rewriting the question before searching with it
Retrieval Dense, sparse, and hybrid search
Re-ranking Reordering candidates before they reach the model
Context Assembly Deciding what actually goes in the prompt
Generation The answer, and grounding it in what was retrieved

Across the pipeline

Page Covers
Evaluation Scoring a pipeline you cannot otherwise improve
Observability Seeing what it did in production
Caching Cutting cost and latency
Index Lifecycle Keeping the index current as documents change
Access Control Making sure retrieval respects who is asking
Guardrails Constraining what comes out

Variants

Page Covers
Agentic RAG Letting the model decide when and what to retrieve
Graph RAG Retrieval over a knowledge graph instead of a flat index
Multimodal RAG Retrieval across images and documents, not only text

Not Covered Yet

  • No fine-tuning. Nothing on LoRA, QLoRA, adapters, or full fine-tuning, which is the most obvious gap given the depth of everything around it.
  • Nothing on training at scale: no distributed training, mixed precision as a subject, or gradient accumulation.
  • No diffusion model page, despite GANs and autoencoders both being covered and diffusion having displaced them for generation.
  • No serving or inference optimisation. Quantisation, batching, and throughput are absent.
  • Indexing opens with a models.py heading, which suggests it was drafted from a specific project rather than written as a reference page.
  • Car Detection is thin at six cells, and sits alone in its own folder.
  • The vision pages here overlap the task pages in DL Tasks; this site is the how, that one is the which, but the boundary is not always obvious.

Back to top