The paradigm shift from programming to learning.
Traditional software is explicitly programmed: a human writes rules, and the machine follows them. Machine learning inverts this — the machine discovers its own rules from data. This shift is the engine behind nearly every modern AI breakthrough, from image recognition to language models.
Learning objectives
By the end of this note, you should be able to:
- Explain how machine learning differs from traditional programming
- Distinguish supervised, unsupervised, and reinforcement learning
- Describe neural network architecture: layers, nodes, activation functions
- Explain how deep learning builds hierarchical representations
- Understand the training→inference lifecycle and why optimization matters
- Articulate what makes transformers and GPT models architecturally distinct
Learning from data, not from instructions.
Intuition: teaching by example
Imagine teaching a child to recognize cats. You don't describe whisker lengths, ear shapes, and fur patterns in precise measurements. You show them many cats and say "this is a cat" — eventually, they learn. Machine learning works similarly: instead of coding rules, you feed a system thousands of labeled examples, and it discovers the patterns that distinguish cats from dogs.
Technical: the learning problem
Formally, machine learning seeks a function f that maps inputs X to outputs Y, such that f generalizes well to unseen data. The system is given a training set of input-output pairs, a loss function that measures prediction error, and an optimization algorithm that adjusts internal parameters to minimize that loss.
Machine learning shifted AI from brittle, hand-crafted rule systems (→ Note 03: Traditional Techniques) to adaptive systems that improve automatically. This is why modern AI can handle tasks too complex for humans to specify rules for — like understanding natural language or recognizing faces in varied conditions.
Data
The raw material. More data generally means better models, provided the data is relevant, diverse, and properly labeled.
Model
The mathematical structure that learns patterns — from simple linear regressions to neural networks with billions of parameters.
Loss Function
A measure of how wrong the model's predictions are. Training minimizes this function across the training data.
From raw data to predictions.
Every machine learning system follows a common pipeline: collect data, prepare it, train a model, evaluate its performance, and deploy it for inference on new data.
Training is the expensive, one-time process of learning from data — it can take days or weeks on powerful GPUs. Inference is the fast, repeated process of using the trained model to make predictions on new inputs. This distinction is fundamental to understanding AI system costs and capabilities.
Three paradigms for learning from experience.
Machine learning systems are categorized by the type of feedback signal they receive during training. Each paradigm suits different kinds of problems and available data.
| Paradigm | Training Signal | Goal | Example Tasks |
|---|---|---|---|
| Supervised Learning | Labeled input-output pairs | Learn mapping from inputs to known outputs | Image classification, spam detection, translation |
| Unsupervised Learning | Unlabeled data only | Discover hidden structure and patterns | Clustering, dimensionality reduction, anomaly detection |
| Reinforcement Learning | Reward/penalty signals from environment | Learn optimal sequence of actions (policy) | Game playing, robotics, autonomous driving |
Supervised Learning
Intuition: A teacher provides the correct answer for each example.
Technical: Given a dataset of (x, y) pairs, learn a function f(x) → y that generalizes to new x values. Common algorithms: linear regression, decision trees, support vector machines, neural networks.
Example: Email spam detection — trained on thousands of emails labeled "spam" or "not spam," the model learns which features (keywords, sender patterns) predict spam.
Unsupervised Learning
Intuition: Finding patterns in data with no answer key.
Technical: Given unlabeled data X, discover latent structure — clusters, distributions, or compressed representations. Common algorithms: k-means clustering, PCA, autoencoders, GANs.
Example: Customer segmentation — grouping shoppers by purchasing behavior without predefined categories, revealing natural market segments.
Reinforcement Learning
Intuition: Learning by trial and error with rewards and penalties.
Technical: An agent interacts with an environment, taking actions and receiving rewards. It learns a policy — a strategy mapping states to actions — that maximizes cumulative reward. Key algorithms: Q-learning, policy gradients, PPO.
Example: AlphaGo learned to play Go by playing millions of games against itself, receiving +1 for wins and −1 for losses (→ Note 02: Goals).
Supervised learning requires large labeled datasets, which are expensive to create. This bottleneck drove the rise of self-supervised learning (a form of unsupervised learning) — where models create their own training signal from unlabeled data. This is how GPT and other large language models are trained: by predicting the next word in text, requiring no human labels.
The architecture that powers modern AI.
Artificial neural networks are computing systems loosely inspired by biological neural networks. They consist of interconnected nodes (neurons) organized in layers, where each connection has an adjustable weight that is tuned during training.
Architecture components
Layers
Input layer: receives raw data (pixels, words, sensor readings). Each node represents one feature of the input.
Hidden layers: perform computations. Each layer transforms the data, extracting increasingly abstract features. More hidden layers = "deeper" network.
Output layer: produces the final prediction (classification probabilities, regression values, generated text).
Activation Functions
Non-linear functions applied at each neuron, enabling networks to learn complex patterns. Without them, any number of layers would collapse to a single linear transformation.
ReLU (Rectified Linear Unit): f(x) = max(0, x) — the most common choice, simple and effective.
Sigmoid: f(x) = 1/(1+e⁻ˣ) — squashes output to [0,1], used in output layers for binary classification.
Softmax: converts raw scores to probability distributions across classes.
Each connection between neurons has a weight (how much influence one neuron has on another) and each neuron has a bias (a baseline activation level). Training adjusts these millions or billions of parameters to minimize prediction error. A network with 1 billion parameters has 1 billion numbers to tune — this is why training requires enormous computation.
Layers that build understanding.
Deep learning uses neural networks with many hidden layers — sometimes hundreds. Each layer learns to represent the data at a different level of abstraction, building a hierarchy from simple features to complex concepts.
Key architectures
Convolutional Neural Networks (CNNs)
Intuition: Sliding a filter across an image to detect local patterns like edges, then combining those into larger structures.
Technical: Use convolutional layers with learnable filters that detect spatial features. Pooling layers reduce dimensionality. Shared weights make them parameter-efficient for image data.
Example: ImageNet-winning models like AlexNet, ResNet. Used in medical imaging, autonomous driving, facial recognition.
Recurrent Neural Networks (RNNs)
Intuition: Processing sequences one element at a time, maintaining a "memory" of what came before.
Technical: Each step takes the current input and the previous hidden state, producing a new hidden state. Variants like LSTM and GRU address the vanishing gradient problem for long sequences.
Example: Language modeling, time series prediction, speech recognition. Largely replaced by transformers for NLP tasks since 2017.
The core insight of deep learning: instead of hand-engineering features (→ Note 03: Traditional Techniques), let the network learn the best features automatically. A CNN trained on images learns edge detectors in early layers and object-part detectors in later layers — no human specified what "edges" or "parts" should look like.
The architecture behind modern language AI.
Generative Pre-trained Transformers (GPT) represent the dominant architecture in modern AI. Built on the transformer architecture introduced in 2017, these models process language by attending to all parts of the input simultaneously — rather than reading sequentially like RNNs.
Self-Attention
The key innovation. For each word in a sentence, the model computes how much it should "attend to" every other word. In "The cat sat on the mat because it was tired," attention links "it" to "cat" — resolving ambiguity that sequential models struggled with.
Mathematically: Attention(Q,K,V) = softmax(QKT/√d)V — queries, keys, and values derived from the input, scaled by dimension.
Generative Pre-training
Pre-training: Train on massive text corpora with a simple objective — predict the next token. No labels needed. The model learns grammar, facts, reasoning patterns, and world knowledge implicitly.
Fine-tuning: Adapt the pre-trained model to specific tasks (summarization, coding, conversation) with small amounts of task-specific data or via instruction tuning (RLHF).
GPT-2 (2019) had 1.5 billion parameters. GPT-3 (2020) had 175 billion. GPT-4 (2023) is estimated at over a trillion. As models scale, they exhibit emergent capabilities — abilities not present in smaller versions, like chain-of-thought reasoning, code generation, and few-shot learning. This scaling behavior is one of the most important phenomena in modern AI research. → Note 05: Modern AI Systems
How networks actually learn.
Training a neural network is an optimization problem: find the set of weights and biases that minimizes the loss function across the training data. This is done iteratively through forward passes, loss computation, and backward propagation of errors.
Forward Pass
Input data flows through the network layer by layer. Each neuron computes a weighted sum of inputs plus bias, applies an activation function, and passes the result forward. The output layer produces a prediction.
Backpropagation
The core algorithm. After the forward pass, the loss function measures prediction error. Backpropagation computes the gradient of the loss with respect to every weight — using the chain rule of calculus — propagating error signals backward through the network.
Gradient Descent
The optimization algorithm. Each weight is adjusted by a small step in the direction that reduces loss. The step size is controlled by the learning rate. Variants like Adam, SGD with momentum, and AdaGrad improve convergence speed and stability.
Overfitting & Regularization
A model that memorizes training data but fails on new data is overfitting. Regularization techniques — dropout, weight decay, early stopping, data augmentation — prevent this by constraining the model's capacity to memorize noise.
Training GPT-4 is estimated to have cost over $100 million in compute alone, using tens of thousands of GPUs for months. This has concentrated AI development in well-funded organizations and raised questions about the sustainability of the current scaling approach.
Inference: using the trained model
Once trained, the model is deployed for inference — making predictions on new, unseen data. Inference is computationally cheaper than training (no gradients needed), but still requires significant resources for large models. Techniques like quantization, pruning, and distillation reduce model size for efficient deployment on edge devices.
Remember these ideas.
Machine learning learns patterns from data instead of following hand-coded rules — a paradigm shift that enables AI to handle tasks too complex for explicit programming.
Three learning paradigms: supervised (labeled examples), unsupervised (finding hidden structure), and reinforcement (trial-and-error with rewards).
Neural networks are layers of connected neurons — each computing weighted sums plus nonlinear activations. Weights are adjusted during training via backpropagation.
Deep learning adds many layers, each learning features at a higher level of abstraction — from pixels to edges to parts to objects to concepts.
Transformers replaced RNNs by using self-attention to process sequences in parallel. GPT models scale this architecture to billions of parameters with emergent capabilities.
The training-inference distinction is fundamental: training is expensive and one-time; inference is fast and repeated. Optimization (backprop + gradient descent) is how networks learn.