Machine Learning · Insper

The Frontier

Fundamental approach

Where everything you learned sits, and when a foundation model is the right tool

The path of this part

  1. Map the fieldevery technique by the job it does; four walks
  2. Reuse, don’t restarttransfer learning, foundation models, prompting
  3. Find the classical insidesoftmax, k-NN, logistic regression, leakage
  4. Route the problemwhere classical wins; what to use when
Each stage answers one question: where does each technique you learned sit? → why start from zero when a model already knows so much? → which pieces of this course are inside an LLM? → which tool for which problem?
Stage 1 · where does each technique you learned sit?

A map of the field

Solid chips were taught in the course (the badge is the lesson code), dashed ones lie beyond. Click a technique: what it is, what it builds on, what builds on it, where to read more. The map scrolls.

Reading the map: four walks

retrieval-augmented generation (RAG)

builds on k-NN and dense embeddings: a 1951 idea and a 2013 idea are the retrieval half of a 2020 system

alignment (RLHF)

reinforcement learning from human feedback. The reward model: \(P(\text{A preferred to B}) = \sigma(r_A - r_B)\), with \(r\) the score of an answer and \(\sigma\) the sigmoid: a logistic regression

evaluating LLM systems

LLMs (large language models) are graded with classification metrics; a benchmark whose questions leaked into training is a scaler fitted before the split, at internet scale

tabular foundation models

the one place where the frontier attacks gradient boosting head on (the advanced approach)

Stage 2 · why start from zero when a model already knows so much?

Transfer learning: stop starting from zero

Pre-train a large model on a huge generic corpus, then adapt it to your task.

feature extraction

freeze the model, use its representations as features for a classical head. You did this: sentence embeddings fed to a logistic regression or to clustering.

fine-tuning

continue training some or all weights on your labeled data: typically 10²–10⁴ examples instead of 10⁶.

ULMFiT (2018) and BERT (2019): pre-trained on unlabeled text, then fine-tuned, they beat models trained from scratch with a fraction of the labels.

LoRA: fine-tune a thin slice

Low-rank adaptation (Hu et al., 2022): keep the weight matrix \(W\) frozen and train only a correction \(BA\), with \(B\) and \(A\) thin.

Predict. \(W\) is \(4096 \times 4096\) and the rank is \(r = 8\). How many numbers does LoRA train?
The frozen 4,096 × 4,096 matrix W, 16,777,216 numbers, plus B of 4,096 × 8 times A of 8 × 4,096: 65,536 trained numbers, 0.39% of W

\(B\): \(4096 \times 8\); \(A\): \(8 \times 4096\). Together \(2 \times 4096 \times 8 = 65{,}536\) numbers, against 16,777,216 in \(W\): 0.39%.

Foundation models

  • Transformers, self-supervised pre-training (predict masked or next tokens: the labels are free), billions of parameters.
  • One very large model adapted to many tasks (Bommasani et al., 2021): GPT, Claude, Gemini, Llama for text; CLIP for vision and language; Whisper for speech.
  • Why scale? Test loss falls as a smooth power law in parameters, data and compute (Kaplan et al., 2020).
Sutton's "Bitter Lesson" (2019): over 70 years, general methods that exploit more computation have beaten hand-built knowledge.

With LLMs, adaptation gets lighter still

adaptationlabeled data neededwhat happens
zero-shotnonedescribe the task in the prompt
few-shot / in-contexta handfulexamples in the prompt; no weights change
fine-tuning (full / LoRA)hundreds+update the weights, or a low-rank slice
RAGnone (needs documents)retrieve passages by nearest-neighbor search over embeddings, put them in the context
"Classify this ticket as billing, technical or other": in 2018 a labeling project; today often one prompt. Prompting became the new fit(), and you still need a labeled test set to know whether it works.
Stage 3 · which pieces of this course are inside an LLM?

The classical toolbox, inside the LLM stack

  • The output layer is a softmax regression over the vocabulary; training is mini-batch gradient descent with weight decay (an L2 penalty) on cross-entropy.
  • RAG systems are k-NN over embeddings; a vector database is an approximate nearest-neighbor engine.
  • The reward model of RLHF is a logistic regression on pairs of answers.
  • Evaluating an LLM system is precision/recall thinking plus honest held-out design; leaked test questions are the field's current leakage problem.
  • BERTopic already composed foundation-model embeddings with UMAP, HDBSCAN and TF-IDF.
Stage 4 · which tool for which problem?

Where classical ML still wins

Predict. A table of churn data, a credit decision in milliseconds, an auditor who must see why. Foundation model or the classical stack?
situationwhy classical wins
tabular datagradient boosting still leads on medium-sized tables (Grinsztajn et al., 2022); LLMs are poor at tables of numbers
latency, cost, scalea logistic regression scores a row in microseconds
regulated decisionsodds ratios and SHAP values (SHapley Additive exPlanations) can be shown to an auditor; a prompt cannot
small, structured problems2,000 rows need bias–variance control, not a trillion parameters
determinismfixed model + fixed input = fixed output; LLMs sample

One challenger on small tables: TabPFN, a transformer pre-trained on synthetic tables that predicts in one forward pass (advanced approach).

Routing: what to use when

the requestroute
free text, images or sound, few labelsfoundation model: a prompt first; with a few hundred labels, embeddings + a classical head; fine-tune (LoRA) if neither is enough
the answer must come from your documentsRAG: a k-NN over their embeddings feeds the prompt
a table of numbers and categoriesclassical stack: gradient boosting by default; logistic regression to audit or to score in microseconds
both kinds of inputboth: the foundation model turns text into columns, the classical model decides
An LLM reads the free-text complaint, a gradient-boosted model scores the churn risk, and MLOps (machine learning operations) monitors both. Whatever the route: a labeled test set.

Summary

  1. Every technique has a place on the map; most of the frontier builds on chips this course taught.
  2. Transfer learning: a frozen model as a feature extractor, or fine-tuned (LoRA trains a thin slice).
  3. Foundation models: self-supervised pre-training at scale; adapted by a prompt, a few examples, retrieved passages or fine-tuning.
  4. Inside the LLM stack: softmax regression, gradient descent, k-NN retrieval, a logistic reward model, leakage.
  5. Route: language to foundation models, tables to the classical stack, real systems to both.
Every "new" idea is a composition of things you now understand: losses, gradients, regularization, embeddings, neighbors, ensembles, honest validation.
Fundamental lab · about 30 min, in pairs

Route the problem, steps 1 to 4

  • No notebook: copy the code of each step from the lesson page into a new Colab notebook, in order. Steps 1 and 4 need no code.
  • Step 1: find your course on the map · step 2: the retrieval half of RAG is a k-NN · step 3: the reward model is a logistic regression · step 4: route six requests.
  • At every step, answer the Predict before running or opening the solution.
  • Simulations: the same question, in other words (step 2) and voters who like long answers (step 3).

Pace: step 1 in 5 min; step 2 and its simulation in 10 min; step 3 and its simulation in 10 min; step 4 in 5 min.