4.2 Types of Machine Learning

Machine Learning Taxonomy for LLM Development

Understanding different learning paradigms is crucial for developing effective Large Language Models. Each approach addresses specific challenges in natural language understanding and generation.

Supervised Learning: Learning from Examples

The foundation of most LLM training, where models learn from input-output pairs.

Mathematical Framework

Given training data D = {(x₁, y₁), (x₂, y₂), ..., (xₙ, yₙ)}, find function f: X → Y that minimizes:

L(f) = (1/n) Σᵢ₌₁ⁿ ℓ(f(xᵢ), yᵢ) + λΩ(f)

Where ℓ is the loss function and Ω(f) is a regularization term.

LLM Applications

Next Token Prediction

Input: "The capital of France is"

Target: "Paris"

Objective: P(w_{t+1} | w₁, w₂, ..., wₜ)

Text Classification

Input: "This movie was amazing!"

Target: "Positive"

Objective: P(class | text)

Question Answering

Input: Context + Question

Target: Answer span

Objective: P(answer | context, question)

Interactive: Next Token Prediction

Top Predictions:
{{pred.token}} {{pred.probability | number:3}}

Unsupervised Learning: Finding Hidden Patterns

Learning from data without explicit targets, crucial for understanding language structure and representation learning.

Mathematical Framework

Given data X = {x₁, x₂, ..., xₙ}, discover hidden structure by optimizing:

θ* = argmax_θ Σᵢ log p(xᵢ | θ)

Where θ represents model parameters and p(x|θ) is the data likelihood.

Key Techniques for LLMs

Clustering for Topic Discovery

Group similar texts to discover latent topics and themes in training corpora.

Algorithm: k-means with cosine similarity

J = Σᵢ₌₁ᵏ Σ_{x∈Cᵢ} ||x - μᵢ||²
Word Embeddings

Learn dense vector representations that capture semantic relationships.

Word2Vec Objective:

J = (1/T) Σₜ₌₁ᵀ Σ_{-c≤j≤c,j≠0} log p(wₜ₊ⱼ | wₜ)
Autoencoder Language Models

Learn compact representations by reconstructing input text.

Objective: Minimize reconstruction loss

L = ||x - g(f(x))||²

Interactive: t-SNE Visualization

Explore how high-dimensional word embeddings cluster in 2D space:

{{tsnePerplexity}}

Reinforcement Learning: Learning from Feedback

Critical for aligning LLMs with human preferences and optimizing for complex objectives.

Mathematical Framework

Agent learns policy π(a|s) to maximize expected cumulative reward:

J(π) = 𝔼[Σₜ₌₀^∞ γᵗ R(sₜ, aₜ)]

Where γ is the discount factor and R(s,a) is the reward function.

RLHF: Reinforcement Learning from Human Feedback

{{$index + 1}}
{{step.title}}

{{step.description}}

{{step.formula}}

Interactive: Policy Learning Simulation

{{rlEpisode}}
{{averageReward | number:3}}
{{policyConfidence | number:3}}

Self-Supervised Learning: The LLM Revolution

The dominant paradigm for modern LLMs, learning rich representations from raw text without explicit labels.

Mathematical Framework

Create supervision signal from the data itself through pretext tasks:

L = -Σᵢ log P(xᵢ | context(xᵢ))

Where context(xᵢ) represents the surrounding tokens or masked portions.

Pretext Tasks for Language Models

{{task.name}}

{{task.description}}

Example:
{{task.input}}
{{task.target}}

Interactive: Masked Language Modeling

{{maskProb}}
Masked Text:

Prediction Task:

Model must predict the [MASK] tokens based on context.

Comparative Analysis

Learning Type Data Requirement Scalability Performance LLM Usage
{{comparison.type}} {{comparison.data}} {{comparison.scalability}} {{comparison.performance}} {{comparison.usage}}

Modern LLM Training Pipeline

How different learning types combine in state-of-the-art language models:

{{stage.name}}

{{stage.type}}

{{stage.description}}

{{key}}: {{value}}