It helps to know what's actually happening under the hood: what makes these models learn and why a large language model behaves so differently from a regular algorithm you'd write by hand. You'll be calling models that already exist, but a handful of terms — tokens, embeddings, fine-tuning — will keep showing up, so it's worth spending a few minutes on where they come from.
What is machine learning?
Machine learning (ML) is the subfield of AI concerned with algorithms that learn from past examples instead of following rules a person wrote down. Spam filtering is a classic case: instead of hand-coding rules like "contains the word lottery," you show an algorithm thousands of emails already labeled spam or not spam, and it learns on its own what separates the two. The result of that learning process is called a model — the combination of the algorithm and everything it picked up from the data, ready to make predictions on new emails it has never seen.
That's the core idea behind all of machine learning: you don't tell the algorithm the rule, you show it examples and let it find the rule itself. ML problems generally fall into three broad settings:
In supervised learning, every example in the training data comes with the correct answer attached (a label). If the label is one of a few categories — spam or not spam, cat or dog — the task is called classification. If the label is a number — a house price, tomorrow's temperature — it's called regression.
In unsupervised learning, there are no labels at all. A common task here is clustering: grouping similar examples together, for example to segment customers by purchasing behavior, without knowing in advance what the groups should be.
In reinforcement learning, an agent learns by interacting with an environment and getting rewarded or penalized for its actions, gradually discovering a good strategy through trial and error rather than from labeled examples.
From machine learning to neural networks
A neural network is one particular kind of ML model, loosely inspired by how neurons in the brain connect and pass signals. It's built from layers of simple processing units; data flows through the layers (forward propagation), and during training the network repeatedly adjusts the connections between units to make its predictions more accurate (backward propagation).
Compared to classic ML algorithms like linear regression or decision trees, neural networks don't need you to manually decide which features of the data matter — they learn useful representations directly from raw data. That's especially valuable for messy, unstructured data like text, images, or audio, where hand-crafting features is impractical. The trade-off is that neural networks typically need much more data and compute to train well.
Deep learning simply refers to neural networks with many stacked layers. Thanks to more available data and much faster hardware (GPUs), deep learning has become the dominant approach behind modern breakthroughs in the field.
Large language models
A large language model (LLM) is a neural network, almost always built on an architecture called the transformer, trained on huge amounts of text so it can recognize, generate, and reason about language. The "large" refers to its number of parameters — often in the billions.
LLMs are typically built in two stages:
Pre-training produces the foundation model. The model is exposed to massive amounts of text and learns general statistical patterns of language — grammar, facts, associations — without any explicit labels. At this stage the model isn't yet solving a specific task; depending on how it was built, it might, for example, just predict the next word in a sequence.
Fine-tuning takes that foundation model and further trains it, usually on a smaller, labeled dataset, to make it good at a specific task or behavior. The "chat" in a model name like GPT-4o-chat generally means the foundation model was fine-tuned on conversations, so it responds helpfully to instructions instead of just continuing text. This is also the stage where a model gets aligned to behave in an expected way. When you later write code like
.model("gpt-4o-mini")or.model("claude-sonnet-4-5"), you're picking one of these fine-tuned variants — each with its own balance of cost, speed, and capability.
LLMs fall into two broad categories based on what they output:
Autoregressive (generative) models predict the next token in a sequence, one at a time, based on everything before it — this is why you see them stream their answer token by token. ChatGPT, Claude, and Gemini are all autoregressive models. They're the ones you talk to and the ones that generate code.
Representational (embedding) models don't generate text. Instead, they convert a piece of text into a vector of numbers — an embedding — that captures its meaning, so that texts with similar meaning end up close together in that vector space. Embeddings are the foundation of semantic search: finding relevant documents by meaning rather than exact keyword matches.
This distinction matters practically, because you'll meet both kinds of models again later: an autoregressive model will generate the responses your app shows to the user, while an embedding model — accessed the same way, through the OpenAI Java SDK's embeddings endpoint or Spring AI's VectorStore — is what powers retrieval-augmented generation (RAG), where relevant facts are looked up first and handed to the model as context before it answers.
Autoregressive models are powerful but imperfect: because they generate the statistically likely next word rather than looking anything up, they can "hallucinate" — produce plausible-sounding but incorrect information — and by default they have no way to cite a source. RAG is one of the main ways developers address this, and it's also the mechanism behind the AI coding agents: an autoregressive model acts as a reasoning engine, decides what to do next, and calls out to external tools — reading a file, running a test, querying an API — to gather the context or take the action it needs. That's exactly what's happening under the hood when Junie explores your project or Claude Code runs your test suite.
Conclusion
Machine learning algorithms learn from examples instead of hard-coded rules — supervised, unsupervised, and reinforcement learning are the three main settings this can happen in. Neural networks are one ML model family, built from layers that learn their own representations from data, and deep learning simply means many layers. LLMs are neural networks trained on text: pre-training builds a general-purpose foundation model, and fine-tuning specializes it for a task like following instructions. Autoregressive models generate text and power the assistants and coding agents you've used so far in this course; representational models produce embeddings, the building block for semantic search and RAG.