Skip to content
All articles

15 min read

By

Machine Learning for AI Engineers: What You Need to Know

The ML foundations AI engineers need: how models learn, supervised vs self-supervised learning, overfitting, precision and recall, embeddings, transformers and RLHF.

If you want to be an effective AI engineer, you need to understand some machine learning. But the ML foundations you need for AI engineering are actually pretty manageable. You won't be training models from scratch. You'll be building systems on top of pre-trained foundation models, so what matters is the intuition, not the math.

The short answer: you need to know how a model learns (parameters, loss, gradient descent), where the right answers come from (supervised, unsupervised, self-supervised and reinforcement learning), why models memorize instead of learning (overfitting, test sets, data leakage), how to measure "good" (precision, recall and ranking metrics, not just accuracy), what's under the hood of an LLM (neural networks, embeddings, tokens, attention and transformers), and how autocomplete becomes an assistant (fine-tuning and RLHF). I've spent seven years doing production ML and have worked with nearly 400 people on moving into AI/ML careers, so I have a pretty good sense of what you need to know and what you can safely skip. This guide covers all of it.

The short version

Concept What it means Why it matters for AI engineers
AI vs ML vs deep learning vs LLMs Nested subsets: AI ⊃ ML ⊃ deep learning ⊃ LLMs "AI" in 2026 almost always means a large deep learning model
Training Nudge the model's parameters to make the loss go down Explains parameters, epochs and hyperparameters like temperature
Where labels come from Supervised, unsupervised, self-supervised, reinforcement learning Self-supervised learning is why LLMs could get so large
Overfitting Memorizing the training data instead of learning the pattern Tuning prompts on the same examples you report is the same mistake
Metrics Accuracy, precision, recall, F1, MAE/RMSE, recall@k You'll use ranking metrics constantly in RAG
Neural networks and embeddings Layers of simple math; meaning turned into numbers Search, recommendations and RAG retrieval compare embeddings
Transformers Attention over all tokens, processed in parallel Nearly every modern foundation model is a transformer
Inference Running a trained model on new input; parameters are frozen Every API call you make is inference
RLHF Reinforcement learning from human rankings Turns a base model (autocomplete) into an assistant

AI vs machine learning vs deep learning vs LLMs

These terms often get kind of smooshed together, but they have fairly distinct meanings.

In normal programming, you write rules for how the program should function. Say you're building a spam filter. You write something like: if the email contains the phrase "free money," flag it as likely spam. That works until the spammers change the wording, and then you're adding rules forever.

Machine learning flips that around. Instead of writing the rules, you show a computer a bunch of emails, each one labeled spam or not spam, and it works out the rules itself. The result of this process is a machine learning model that can predict whether a new email is spam or not.

Deep learning is machine learning done with a particular kind of model called a neural network. We'll get to how these work later, but for now just know it's the kind of model that's really good when you give it a lot of data. Large language models (LLMs) are one type of deep learning model.

And AI is the umbrella word for everything in this field, including some pretty old rule-based systems that nobody would call AI today. So by definition:

  • machine learning is a subset of AI,
  • deep learning is a subset of machine learning,
  • and LLMs are a subset of deep learning.

In practice, though, when someone says AI in 2026, they almost always mean some kind of large deep learning model, which can be a bit confusing.

One thing worth knowing: the older, non-deep-learning kind of ML is still most of what actually runs in production for things like fraud detection, recommendations or demand forecasting.

How a machine learning model actually learns

When a model is brand new, before any training, it's wrong about basically everything. It would look at an email and guess spam or not spam at random. Training is the process of making it less wrong, and it works the same way whether we're talking about a simple spam filter or a frontier LLM.

Parameters: the dials inside the model

Inside every model is a set of numbers called parameters. These are the numbers that control what the model outputs. You can think of them as a giant board of dials. A tiny model has a few hundred dials, while the big LLMs have hundreds of billions. So when you hear that a model has 70B parameters, that's 70 billion dials.

Loss and gradient descent

To make the model less wrong by adjusting these dials, we need a way to score how wrong it is. That score is called the loss, and it's just one number. Lower is better. The entire point of training is to get this number down.

So training goes like this:

  1. Show the model an example.
  2. Compare its guess to the right answer and calculate the loss.
  3. Nudge every single dial a tiny bit in whatever direction would have made the loss a little smaller.
  4. Repeat with the next example, millions or billions of times.

The technique for figuring out which way to nudge each dial is called gradient descent. It's the part of the process with the most math, but as an AI engineer you'll be fine with just the intuition. If you want to go deeper, here's a wonderful visual breakdown of how gradient descent works.

One full pass through the training data is called an epoch. Training usually runs for several of them, because one look at the data isn't enough.

Parameters vs hyperparameters

The parameters are the numbers the model learns. But there's a second set of numbers that a human picks before training starts, and those are called hyperparameters. They include:

  • the learning rate: how big each nudge should be,
  • the batch size: how many examples to look at before nudging,
  • the number of epochs to run.

If you're familiar with LLMs, you'll recognize temperature as a hyperparameter for LLM inference.

Realistically, everything I just described is the job of an ML engineer or data scientist. As an AI engineer, you won't be training models from scratch. Instead, you'll most likely be working with a coding agent to build AI systems on top of pre-trained foundation models.

Where the right answers come from: supervised, unsupervised, self-supervised and reinforcement learning

Nudging the model toward the right answer assumes we know what the right answer is for every example. There are actually four different ways to get those answers.

1. Supervised learning: humans label it

Humans label the data, or we have some ground truth. For example, humans label emails, or radiologists tag x-rays. Or we look at logs and see whether someone clicked on a recommendation or didn't. This is supervised learning, and it's the most common kind in traditional ML.

Within supervised learning there are two main kinds of predictions:

  • Classification: predicting a category, like spam or not spam.
  • Regression: predicting a number, like a house price or how many units you'll sell next week.

2. Unsupervised learning: no answer key at all

You give the model a pile of data and ask it to find structure on its own. Group these customers into segments, or flag the transactions that look unlike all the others. That's unsupervised learning, and it's what you use when you don't know in advance what the categories should be.

3. Self-supervised learning: the data labels itself

This is the one that matters most for LLMs. For text, you take a sentence, hide the next word, and ask the model to guess it. The real next word is the answer key. No human labels are required, and every piece of text ever written can be a training example.

This is self-supervised learning, and it's how every LLM gets pretrained. It's the reason language models were able to get so large: you can train on the entire internet if nobody has to label it.

4. Reinforcement learning: a score, not an answer

There's no right answer per example, just a score for how well the model did overall. That's reinforcement learning. We'll come back to it at the end, because it's really important for modern AI systems.

I also made a free ML for AI Engineers checklist with all the topics in this guide, plus a short summary you can use as a study guide.

What is overfitting? Memorizing instead of learning

So now the model has an answer key and a loss score, and the loss is going down. That sounds like it's working. Except the point of a model isn't to memorize the right answers in the training data. It's to make predictions on new data. Sometimes a model gets so good at the training data that it can't generalize to new situations.

This is called overfitting. Imagine a student who memorized last year's exam questions and answers. They'd get 100% on the practice test and then fail the real one, because they never learned the material, just the question-and-answer pairs. A model does the exact same thing: with enough parameters it can memorize the specific examples instead of learning the pattern underneath them.

The opposite is underfitting. The model is too simple, or didn't train long enough, to pick up the pattern at all. That's the student who didn't study.

Train, validation and test sets

This is why you never evaluate a model on the data it trained on. Before training starts, you hold back a chunk of the data, often around 20%, that the model never sees. That's the test set, and we only report performance scores calculated on that set.

In practice there's usually a third chunk, called the validation set. During training you'll try a bunch of things to improve performance, and if you always score against the test set, you end up overfitting to the test set and still don't generalize well. So you use the validation set to check performance while you're working, and only report final numbers on the test set at the end.

Data leakage and contamination

ML engineers are also a little paranoid about data leakage: anything that lets information from the test set sneak into training. That could be the same customer showing up in both sets, or including the cancellation reason in a model that predicts customer churn. You're giving the model information from the future that it won't actually have at prediction time. The result is really strong metrics during training, and then really bad performance once you try to use the model.

The LLM version of this is called contamination. If a benchmark's questions were somewhere in the pretraining data, the benchmark score is meaningless, because the model has essentially memorized the exam.

Why this matters even if you never train a model

This applies to you as an AI engineer too. If you iterate on a prompt against the same twenty examples and then report your eval score on those same twenty examples, you've overfit the prompt. It's the exact same mistake. Hold some examples back that you never tune against.

Why accuracy can lie to you: precision, recall and other metrics

Holding back a test set tells you where to measure your results. The next question is what to measure.

Accuracy and the class imbalance problem

The metric most people know is accuracy: what percentage of examples did the model get right?

Accuracy works fine when the categories are balanced. If you were predicting whether a baby will be a boy or a girl, accuracy would be fine, because the true rate is essentially 50/50. The problem is that most things in real life aren't evenly split.

Say you're building a fraud model, and fraud is only 0.1% of transactions. A model that says "not fraud" every single time is 99.9% accurate and catches zero fraud, so it's functionally useless. The key issue is that accuracy hides which kind of mistake you're making.

False positives, false negatives, precision and recall

There are two different ways to be wrong:

  • A false positive: you flag something that wasn't actually fraud.
  • A false negative: you miss something that was.

Every classification problem has to decide which of those is the bigger problem.

  • Precision: of the things the model flagged, how many were actually right? Of all the transactions we classified as fraud, what percentage actually were fraudulent? High precision means few false alarms.
  • Recall: of the positives that were actually there, how many did the model catch? Of all the real fraudulent transactions, what percentage did we correctly identify? High recall means few misses.

You almost always have to trade one for the other. When classifying, the model outputs a probability, and we pick a threshold for when to call it fraud. Move the threshold down and we catch more fraud but freeze more innocent cards. Move it up and we annoy fewer customers with frozen cards, but miss more real fraud. Picking that threshold is a product decision as much as a technical one.

If you care about both, F1 combines precision and recall into a single score.

Regression metrics: MAE and RMSE

All of the above assumes we're predicting discrete classes. For regression, where you're predicting a number, the metric is how far off you are on average. You'll see MAE and RMSE (mean absolute error and root mean squared error). These are just different ways of averaging the misses.

Ranking metrics for search and RAG

As an AI engineer, you'll very likely use ranking metrics a lot. When the output is an ordered list, like search results or the documents a RAG system retrieves, the question is whether the right answer was in the top few. You'll hear recall@k or precision@k, where k is how many results you looked at.

Why evaluating LLMs is harder

All of these metrics assume there's one right answer per example. A generated paragraph has lots of acceptable answers, so you can't just count matches. That's one of many reasons evaluating LLMs is so difficult.

There are many other ML metrics, of course, and the right one depends on your specific use case.

How neural networks, embeddings and transformers work

So far we've treated the model as a black box. Now let's look a bit at how it works under the hood.

Neural networks

A neural network is a model made of layers of very simple math units. Each unit takes in some numbers, multiplies them by its own parameters (called weights), adds the values up, and passes the result to the next layer. Stack lots of layers together and those simple units combine into something that can make really complex predictions.

What makes layers useful is that each one builds on the last. In an image model, the early layers pick up simple things like edges and color changes, middle layers combine those into shapes, and later layers combine those into things like faces. In a language model it's similar: common word pairs, then grammar, then something like meaning. This happens naturally as a result of training.

Embeddings

One of the most useful things a neural network learns is how to turn unstructured input like images and text into a list of numbers that captures what it means. That list is called an embedding. You can embed a word, a sentence, an image, or even a user or a product.

The defining property is that similar embeddings end up close together. "Car" and "automobile" are right next to each other in the embedding space. "Car" and "banana" aren't.

When you search by meaning instead of keywords, that's comparing embeddings. So are clustering, recommendations and the retrieval step in RAG.

Tokens

Earlier I said LLMs are trained with self-supervised learning, guessing the missing word in a sentence. In reality, LLMs don't read words. They read tokens, which are chunks of text.

Attention and transformers

For a long time, models read text one token at a time and tried to carry the meaning forward, and they lost track during long sentences. The reason LLMs took off was something called attention. For every token, the model looks at every other token in the input and decides how much each one matters right now.

Take the sentence "the dog that chased the cat was brown." Attention is how the model connects "brown" to "dog" and not to "cat." Several of these attention lookups run at the same time, each one tracking something different, like who a pronoun refers to, or the tone of a sentence.

The transformer is the architecture built around attention. It's particularly effective because it processes all the tokens in parallel instead of one at a time. That meant training could use a whole bunch of GPUs at once, which meant models could get gigantic. Nearly every modern foundation model is a transformer.

So, putting it all together: an LLM is a very large transformer, trained self-supervised to predict the next token, on a huge slice of the internet.

What is inference?

Once you have a trained model, running it on a new input to get an output is called inference. Unlike during training, the model's parameters are frozen. Nothing is being learned at this point.

You can still adjust the outputs with hyperparameters, just like with traditional ML. For LLMs, common ones are temperature and top_p. These control how the model picks the next token, making it more or less creative.

So when you send a message to an LLM with a prompt and your hyperparameter choices, the response you get back is inference taking place.

But here's a question: if the model was trained to predict the next token of internet text, why does it answer your question instead of just continuing your sentence?

How autocomplete becomes an assistant: fine-tuning and RLHF

Interestingly, continuing your sentence is exactly what an LLM does at one point during its training. LLMs go through several stages: pretraining, which is the self-supervised next-token prediction we've been talking about, and then a couple of fine-tuning stages on top of that.

The model that comes out of pretraining is called a base model, and a base model really is just autocomplete. If you ask it a question, it might keep going and write three more questions, because that's what text on the internet often looks like.

Reinforcement learning

The step that turns a base model into an assistant is reinforcement learning. In RL there are no labels and no right answer per example. The model, which in RL terms is called the policy, tries something, gets a score called the reward, and adjusts to earn more reward over time. It's trial and error. The classic examples are game-playing agents and robot control, where there's a clear win or lose signal.

Fine-tuning

Fine-tuning means taking a model that's already been trained and training it a bit more on a smaller, targeted dataset. Everything that happens to an LLM after pretraining is some form of fine-tuning.

From base model to assistant in two steps

  1. Supervised fine-tuning (SFT). You show the base model a modest set of human-written question-and-answer pairs, so it learns the format of answering a question instead of continuing the text. That's supervised learning from earlier, just on a tiny dataset compared to pretraining.
  2. RLHF (reinforcement learning from human feedback). You have the model generate several answers to the same prompt, and humans rank them from best to worst. Then you train a separate, smaller model, the reward model, to predict those rankings. Finally, you use reinforcement learning to fine-tune the LLM so it produces answers the reward model scores highly. The reward model stands in for a human judge, so you don't need a person rating every single output.

That step is what gives LLMs helpfulness, instruction following, refusals, tone, and everything else we expect from the chatbots we use.

What to learn next

That's all the ML foundations you need to succeed as an AI engineer. Everything here is the layer underneath what AI engineers actually build, but it's important to understand so you can build robust systems (and get along with your ML colleagues).

If you want to go from here into the practical side of AI engineering, I have a complete 76-minute AI engineering course that picks up exactly where this one leaves off.

And if you want help building your own production-ready project, I run a small, application-only build cohort where I personally work with a handful of people over eight weeks to take an AI engineering project all the way through deployment.

Frequently asked questions

How much machine learning does an AI engineer need to know?

Less than most people think. AI engineers don't train models from scratch; they build systems on top of pre-trained foundation models. What you need is the intuition: how models learn, where training labels come from, overfitting and test sets, how to pick a metric, what embeddings and transformers are, and how a base model gets turned into an assistant with fine-tuning and RLHF.

What is the difference between AI, machine learning, deep learning and LLMs?

AI is the umbrella term for the whole field, including old rule-based systems. Machine learning is a subset of AI where the computer learns rules from examples instead of being told them. Deep learning is machine learning done with neural networks, and large language models are one type of deep learning model. In 2026, when people say AI they almost always mean some kind of large deep learning model.

What is the difference between parameters and hyperparameters?

Parameters are the numbers the model learns during training, like a giant board of dials; a 70B model has 70 billion of them. Hyperparameters are numbers a human picks, such as the learning rate, the batch size or the number of epochs. Temperature is a hyperparameter you set when running an LLM.

What is overfitting, and how does it affect AI engineers?

Overfitting is when a model memorizes its training examples instead of learning the pattern underneath them, so it does great on data it has seen and badly on new data. AI engineers can make the same mistake without training anything: if you iterate on a prompt against the same twenty examples and then report your eval score on those same twenty examples, you've overfit the prompt. Always hold some examples back that you never tune against.

Why is accuracy a misleading metric?

Accuracy hides which kind of mistake a model makes, so it breaks down when the categories are unbalanced. If fraud is 0.1% of transactions, a model that always says 'not fraud' is 99.9% accurate and catches nothing. Precision (how many flagged items were really positive) and recall (how many real positives were caught) tell you much more.

What is an embedding?

An embedding is a list of numbers that a neural network produces to capture what something means. You can embed words, sentences, images, users or products, and similar things end up close together, so 'car' sits near 'automobile' but far from 'banana'. Semantic search, clustering, recommendations and the retrieval step in RAG all work by comparing embeddings.

What is RLHF?

RLHF, or reinforcement learning from human feedback, is the training step that turns a base model, which is really just autocomplete, into a helpful assistant. Humans rank several model answers to the same prompt, a smaller reward model learns to predict those rankings, and reinforcement learning then fine-tunes the LLM to produce answers the reward model scores highly. It's what gives chatbots their helpfulness, instruction following, refusals and tone.

Marina Wyss
Written by

Marina Wyss

AI educator, speaker, and AI/ML career coach. Former Senior Applied Scientist at Twitch (Amazon). Since 2022 I've worked with nearly 400 people on moving into AI and ML careers, many from non-traditional backgrounds like mine.