Understand AI models

What a language model does

Understand a language model as a system that predicts likely continuations from patterns learned during training.

When you type something in ChatGPT, Claude, or any AI coding tool, the tool sends your request to a model. The model is what produces the answer. Everything else is an interface around it.

You’ll often see the term LLM, Large Language Model. That’s the kind of model we use for coding.

How a model is made

A model learns patterns from a huge amount of data. For coding, that means billions of lines of public code from GitHub and other repositories, plus books, documentation, Stack Overflow questions and answers, forums, mailing lists.

During training, the model repeatedly tries to predict a missing piece of that data. Each mistake slightly adjusts billions of numbers called parameters. Training is the expensive part. It takes months and enormous amounts of hardware.

When you send a prompt later, the model runs inference. It uses those learned parameters to produce a response. That’s the part we pay for, per request.

How this works internally is machine learning territory. Neural networks, weights, biases, gradients. I’m not going there, and you don’t need to either. We’re here to use models, not build them.

One token at a time

The model doesn’t look up a complete answer in a database. It calculates which piece of text is most likely to come next, given everything it has seen so far.

Suppose the prompt ends with:

The capital of Italy is

The model gives a very high probability to Rome. It produces Rome, adds it to the text, and predicts again. Same thing until the answer ends.

Code works the same way. A likely function name, then a parameter, then the next symbol. It can write a whole working program because it learned a huge number of relationships between code, docs, error messages, and explanations.

Prediction is more than autocomplete

This sounds like autocomplete with a big dictionary. It’s not.

To predict well, the model had to build useful internal representations of language, code, structure, and how things relate. That’s what lets it combine patterns in ways it never saw in one place.

But there’s a catch, and it matters for the whole course. The model produces what fits the context. Not what it has proved. A package name that doesn’t exist can fit a coding answer perfectly. A made-up quote can fit an article. The sentence sounds right while the claim is wrong.

Your input changes the odds

When you add an example, a constraint, or a file, you change the context the model predicts from. That’s why a precise request with the right files gives a better result, without changing the model at all.

It also explains why the same prompt can give two different answers. More than one next token is plausible. A different early pick changes everything after it.

One more thing to keep in mind. The model has no access to your intentions, your project, or the outside world. It only knows what was in its training data, what you put in the context, and what a tool returns to it.

Lesson completed