July 17, 2026 - AI Course - Chapter 5

How an LLM is built and what it's good at

How a neural network works, what training is, and what LLMs are really good at: from language to code, from classification to tools.

How an LLM works

Representation of a neural network

A neural network isn’t a physical object and isn’t a program in the classic sense; it’s a complex mathematical function made up of millions of small computational units, the nodes, connected to each other. A node is a computational unit that receives an input, processes it and produces an output. Each node does something simple: it receives numbers, combines them and produces an output number, which it passes on to other nodes. Taken one by one they’re trivial; it’s the millions of nodes cascading, across many layers, that give rise to complex behaviors.

Every connection between nodes has a weight, a number that indicates how much the signal passing through it counts: a high weight means an influential connection; a weight close to zero means it’s almost ignored. Each node also has a bias, a value that regulates how easily it “activates.” Weights and biases together are the model’s parameters, which range from tens of billions for small models that can run locally (e.g., 10B parameters, billions = billions) up to a few trillion for frontier models (GPT-4 had about 1.8T; trillion = 1000 billion).

Training the network means searching for the values that let it guess the most plausible next word in a text (technically the token, which isn’t exactly a word), and then the next one, and the next one after that, until it composes a full response. No one chooses them: they emerge on their own during training and subsequent phases, as the effect of millions of cycles of writing parameters - generating output - correction - adjusting parameters.

Training consists of “digesting” enormous amounts of text from the internet, books and code; the most recent models also add images. They don’t store verified facts, but the statistical structures of language, the regularities with which words string together. Direct consequence: everything that’s in the data, including errors and biases, gets into the model. To train large models requires thousands of specialized processors running for months.

Once this phase is finished, the network can predict text and will also respond to dangerous requests. It therefore needs to be aligned with ethical values of safety, lack of bias, non-dangerousness of responses, and similar. It’s taught which responses are preferable by rewarding those that comply with a set of established principles, a phase carried out with a mix of human evaluations and other AI models used as judges.

Once the training phase is finished, today’s models are “closed,” meaning they have no ability to learn and modify their weights and parameters, and consequently they know nothing about what happened after their training cutoff date. They’re therefore not able to update themselves, and if you want to know yesterday’s news you have to ask them to search the internet, although modern models also do this search operation on their own.

An important and more practical concept is the context window: how much text the model keeps in view in a single chat, measured in tokens. It’s a single budget shared between your question, the documents you paste in and the response itself: fill it with a long input and the response gets shorter. It’s also why long chats lose steam: when the conversation exceeds the window, the earliest details fade away. Windows have grown a lot, from a few thousand tokens up to millions in recent models, but they remain a limit.

Now that we have an idea of how they’re built, let’s understand the advantages this technology can give us.

What they’re good at

We’ve seen that LLMs aren’t databases, aren’t search engines and aren’t “intelligences” in the human sense of the term. But they’re extremely powerful tools at one specific thing: working with language and transforming information.

Working with language

Rewriting, summarizing, translating, changing register, fixing the form, adapting a text for a different audience. Here they’re very strong because they’ll work on text that we ourselves provide, so they don’t need to retrieve information from their memory. The more text, context and clear constraints you give it, the more reliable it becomes. Once you understand this point, you understand LLMs. So, on important matters, gather the sources you consider reliable, feed them to it, and it will help you understand them, analyze them, find recurring patterns, and so on.

Obviously this is one of the things we’ll cover in this course. To be fair, today all LLMs use search functions to find information outside their memory, and they don’t just “blurt out the first thing that comes to mind” like they used to, so, if used well, it’s possible to get information with a decent degree of reliability even without providing the sources yourself. But it’s not yet an automatic process, so the golden rule is DON’T TRUST IT.

Recognizing and continuing patterns

An LLM, through training, has learned linguistic, structural, semantic regularities. The same goes for other AIs: image generators have learned patterns from billions of images, music generators by listening to music, voice generators by listening to conversations. If the task is recognizing patterns and the data is clean, beating an AI is nearly impossible. An LLM therefore knows what a sentence looks like, how a certain type of text continues, what shape a table, a list, an email, a meeting minute, a contract, a post, a technical explanation has. You give it the beginning of something and it continues in the same style. You give it disordered notes and it turns them into an outline. You give it three examples and it produces a fourth one consistent with the others. You give it free text and it extracts ordered data from it. Three emails become a table with names, dates and amounts. A hundred reviews get split into positive aspects, negative aspects and recurring requests. A confusing meeting minute becomes a list of decisions made, open issues and next actions. It doesn’t have a “human” understanding (a topic that deserves separate treatment), but it recognizes form, context and relationships between concepts: it knows how to turn the chaotic into structured material.

Classifying and evaluating

LLMs are also good at classifying content according to given criteria. You can ask: are these emails urgent or not urgent? Do these customer tickets concern technical, administrative or commercial issues? Do these CVs meet the minimum requirements? Are these responses favorable, opposed or neutral? The important thing is to provide a clear grid. If the criterion is vague, the answer will be vague too. If the criterion is precise, the model can become an excellent first-pass assistant. It doesn’t replace final judgment, but it greatly reduces the grunt work.

Generating variants

Another very strong point: producing alternatives. Different titles, different examples, simpler versions, more technical, harsher, more elegant, more commercial, more explanatory. A person often gets stuck on the first formulation. An LLM can produce ten in a few seconds. That doesn’t mean they’re all good. In fact, often many of them aren’t. But they’re useful for exploring the space of possibilities. A provocation: isn’t this a form of creativity?

From human language to technical language

This is one of the most practical revolutions. You write in plain English (or Italian): “find me the lines where this topic is discussed”, “make me a table with this data”, “create a formula for me”, “prepare a query for me”, “turn these notes into a procedure”. The model translates the request into a technical language: code, formula, query, prompt, data structure, command, schema, document. It doesn’t eliminate the need for technical skill, but it lowers the barrier to entry. You don’t always have to already know the machine’s language. You do need to know how to clearly explain what you want to achieve.

Code

Code is a special case of the previous points. It’s language—or rather, it’s many languages—but much more regular and structured than human language: it has rigid syntax, recurring structures and a huge number of available examples. This is why LLMs have become very strong at everyday programming: writing functions, fixing errors, explaining code, generating scripts, turning an idea into a first working draft. Historically they didn’t shine on rare, complex or highly specific problems, but the performance of the most recent models is impressive. One rule remains: code must be tested. An LLM can write code that looks perfect and is still wrong. Since we’ve seen that LLMs are good at turning human language into code, this has given rise to what’s been called “vibe coding,” meaning it’s possible to create apps and software simply by describing them in words, and with agents this ability has been further strengthened.

Explaining and acting as a tutor

Explaining is one of the most natural uses of LLMs and follows from the previous points. In my personal opinion, if they were used as teaching tools today—rather than as a substitute for doing homework—they could radically transform learning, at any level, making it more fun and interactive, drastically cutting the time needed to prepare teaching materials and easily adapting it to each student’s specific needs, providing a tireless teacher who can quiz us and guide us in overcoming our gaps. It’s one of the best uses, especially for learning. But with one fundamental limit: you have to provide the material yourself, because otherwise it might explain what’s wrong with the same confidence as what’s right.

Using tools

Here’s one of the most important and most impactful leaps for our society. An LLM on its own responds with what it has learned and with the context you give it. But connected to tools it can do much more: search the web, read documents, query databases, run code, use a calculator, call other software to request and provide information or commands, edit files, fill in tables, drive software. This is changing the nature of work. Where will all this take us? Nobody knows.


This is where the circle closes. Today, the neural networks of LLMs and other AIs don’t contain an archive of true answers to consult: they contain those billions of parameters that make up a statistical map of how language, images or other types of information behave; they’re extremely powerful tools that you need to know how to use.