Users Pricing

articles

Home Articles How Large Language Models Work, Explained Without the Maths – MindStick
How Large Language Models Work, Explained Without the Maths

How Large Language Models Work, Explained Without the Maths

Magdalena Krawczyk 85 24 Nov 2026

Large language models (LLMs) write code, summarise contracts, answer questions and draft emails. To many people they feel like magic, or like a mind. They’re neither.

Understanding roughly how they work isn’t just interesting. It helps you use them better, trust them appropriately and spot when they’re likely to get things wrong. Here’s the explanation, with no equations.

The one-sentence version

An LLM is a very large program that has learned, from huge amounts of text, to predict what comes next in a piece of writing, and it’s good enough at that prediction that useful behaviour emerges.

Everything else is detail. Let’s go through the detail.

Step 1: Text becomes tokens

Computers work with numbers, not words. So the first thing an LLM does is split text into tokens: small chunks, often a whole short word, part of a longer word, or a punctuation mark.

“Unbelievable results!” might become something like Un + believ + able + results + !.

Each token maps to a number. This is why AI pricing and limits are measured in tokens. In English, a token is roughly three-quarters of a word on average. Languages written in other scripts, like Hindi, often need more tokens for the same meaning, which can make them more expensive to process.

Step 2: Predict the next token

At its core, the model does one thing: given a sequence of tokens, it calculates the probability of every possible next token.

If the text so far is “The capital of France is”, the model gives a very high probability to ” Paris” and tiny probabilities to everything else. It picks a token, adds it to the text, and repeats. One token at a time, that’s how every answer is written.

A setting called temperature controls how adventurous the choice is. Low temperature means the model almost always picks the most likely token, which is good for factual and code tasks. Higher temperature lets it pick less likely ones, which gives more varied and creative writing.

Step 3: Where the knowledge comes from (training)

How does the model know Paris is likely? From pre-training.

The model reads an enormous amount of text: books, websites, articles, code and more. For each piece, it tries to predict the next token, checks the real answer, and adjusts its internal settings slightly to do better next time. Repeat this an almost unimaginable number of times.

Those internal settings are called parameters, and modern models have billions of them. They aren’t a database of facts. They’re more like a gigantic web of learned patterns: grammar, facts, writing styles, reasoning steps, how code fits together, and how ideas relate.

Step 4: The transformer and “attention”

Almost every modern LLM uses an architecture called the transformer, introduced by Google researchers in a 2017 paper titled “Attention Is All You Need”.

Its key idea is attention. When deciding the next token, the model looks back at all the previous tokens and works out which ones matter most for this decision.

Take: “The trophy didn’t fit in the suitcase because it was too big.” To understand what “it” refers to, the model needs to connect “it” with “trophy” and “big”. Attention lets it weigh those relationships. In the sentence “…because it was too small”, attention shifts towards “suitcase”.

Transformers stack many layers of attention, so the model builds up an increasingly rich understanding of the text as it goes.

Step 5: Turning a predictor into an assistant

A model that only predicts text isn’t a helpful assistant yet. Ask it a question and it might continue with more questions, because that’s what text on the internet sometimes looks like.

So after pre-training, models go through further training:

  • Instruction tuning: training on examples of questions paired with good answers, so the model learns to respond helpfully.
  • Learning from feedback: people (and other methods) rate responses, and the model is adjusted to prefer the kinds of answers rated as helpful, honest and safe. You’ll often see this called RLHF, reinforcement learning from human feedback.

This stage shapes the model’s personality, its tone, and what it will and won’t do.

Step 6: The context window

The model doesn’t remember your previous conversations by default. What it “knows” about your chat is whatever is included in the current request, called the context window. That includes the system instructions, the conversation so far and any documents you attached.

Context windows have grown enormously, from a few thousand tokens in early models to hundreds of thousands or more today. But they’re still finite, and very long contexts can cost more and sometimes reduce accuracy on details buried in the middle.

Features like “memory” in chat apps work by storing notes and putting them back into the context window.

Why LLMs make things up

Now the most important consequence. An LLM generates text that is statistically plausible. Usually plausible and true overlap. Sometimes they don’t.

If you ask about an obscure research paper, the model knows what paper titles, author names and citations look like. If it hasn’t learned the real details, it may produce a convincing but invented one. This is called hallucination, and it isn’t a bug that will be fully patched away. It comes from the way the model works.

Other limits follow from the same design:

  • Knowledge cutoff: the model only knows what was in its training data, up to a certain date, unless it’s connected to search or documents.
  • Arithmetic and counting can be unreliable without tools, because the model predicts tokens rather than calculating.
  • Confidence isn’t evidence. A model sounds equally fluent whether it’s right or wrong.

How modern systems reduce these problems

  • Retrieval-augmented generation (RAG): fetch relevant documents first and give them to the model, so answers are grounded in real sources.
  • Tool use: let the model call a calculator, run code, query a database or search the web.
  • Reasoning steps: newer models can work through a problem step by step before answering, which improves accuracy on maths, logic and coding.
  • Citations: asking for sources makes answers easier to verify.

What this means for you

  • Give context. The model only knows what’s in its training and in your prompt. Paste the relevant document, data or code.
  • Be specific. Clear instructions, examples of the output you want, and the format you need all improve results.
  • Verify facts that matter, especially numbers, legal points, citations and anything recent.
  • Use tools for precision. For calculations and data analysis, have the model write and run code rather than doing it “in its head”.
  • Don’t share secrets carelessly. Check your provider’s data policies before sending confidential or personal data.

In short

An LLM turns text into tokens, predicts the next token using patterns learned from vast amounts of text, and repeats that until it has an answer. The transformer’s attention mechanism lets it understand how words relate across a passage. Extra training turns that predictor into a helpful assistant.

It’s not magic, and it’s not a mind. It’s an extraordinarily capable pattern engine. Knowing that is the key to using it well: give it good context, check what matters, and let it do what it does best.


Magdalena Krawczyk

Software Engineer at Capgemini

I am a Software Engineer at Capgemini, Lublin, with 2 years of experience in backend development and cloud platforms. I graduated from Maria Curie-Sklodowska University with an engineering degree in Computer Science and completed a master's degree in Computer Science at Lublin University of Technology. Outside work I enjoy reading fantasy novels and cooking.


Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md