How Machine Learning Works: A GenAI Primer
Before you can prompt an LLM well, build a RAG pipeline, or fine-tune a model, you need one clear mental model: what a machine-learning model actually is and how it learns. Get this and generative AI stops being magic — prompting, embeddings, and fine-tuning all become obvious consequences of a few simple ideas. No heavy maths here; just the picture.
A model is a function with tunable knobs
A machine-learning model is a function that maps an input to an output — text to a next word, an image to a label, a question to an answer. What makes it learned rather than hand-written is that its behaviour is controlled by millions or billions of numbers called parameters (or weights). Change the weights and you change what the function does. Saying a model "has 70 billion parameters" just means it has that many tunable knobs.
Learning = adjusting the knobs to reduce error
The model learns from data through three steps, repeated an enormous number of times:
- Predict. Run an example through the current weights to get an output.
- Measure the error with a loss — a single number for how wrong the prediction was.
- Nudge the weights a tiny step in the direction that lowers the loss (gradient descent — the loss goes down, the model gets less wrong).
Do this over a huge dataset and the weights settle into values that make good predictions. That is all "training" means. It is slow and expensive — the reason training a frontier model costs millions.
Neural networks and "deep" learning
Modern models are neural networks: layers of weighted sums (the dot product from your maths lessons) with a simple nonlinear function between them. Stack many layers and you have deep learning. Each layer transforms the data a little; together they represent astonishingly complex patterns. A Large Language Model is just a very large neural network trained on a huge amount of text to do one deceptively simple task — predict the next token — which you will meet in Lesson 3.
Training vs inference
Two very different phases:
- Training finds the weights. Slow, expensive, done once (or occasionally).
- Inference is running the finished model forward to get an answer. Fast and cheap by comparison — this is what happens every time you send a prompt.
When you call an LLM API, you are doing inference on a model someone else already trained.
Common pitfalls
- The model does not "know" facts. It pattern-matches over its training data. When unsure it still produces fluent, confident text — this is hallucination, and it is why grounding (RAG) and verification matter.
- Training data has a cutoff. A model knows nothing that happened after its data was collected, unless you supply that information in the prompt.
- Bigger is not automatically better. More parameters can mean more capability and more cost and latency; the right model is a trade-off, not a maximisation.
Why this is your on-ramp
Prompting is steering a fixed function. RAG feeds it facts it never memorised. Fine-tuning nudges its weights for your task. Embeddings come from its inner layers. Every technique in this course is a move on the simple machine you just met: a function of many weights, trained to minimise a loss. Keep this picture close.
