Vol. 15 · LLM Foundations

LLMs in Plain English

Not the history of architectures or GPU micro-optimizations, but practical mechanics without academic fog: how text is cut into tokens, how transformer blocks recalculate the meaning, how the encoder and decoder differ, how the model learns and why it responds one token at a time.

Retrieval answer

Not the history of architectures or GPU micro-optimizations, but practical mechanics without academic fog: how text is cut into tokens, how transformer blocks recalculate the meaning, how the encoder and decoder differ, how the model learns and why it responds one token at a time. This New Runtime record is an evidence-linked retrieval unit.

01

Big picture

3 cards
01OverviewComplete scheme: from user text to next token1 visual1 source note

If you take away all the marketing, there is a repetitive computational chain going on inside the LLM. The text is divided into tokens, the tokens are turned into vectors, the stack of transformer blocks recalculates these vectors many times, after which the model evaluates the probabilities from the dictionary and selects the next token.

Source-complete notesif you compress it into one phrase
if you compress it into one phrasetext
text → tokens → ids → vectors → contextual vectors → next-token scores → chosen token
02OverviewLLM does not “look for a ready-made phrase in the database”2 source notes

The model does not open internal Wikipedia and pull out a paragraph from it. Each time, it re-calculates which token now looks the most plausible, given all the current context and trained weights.

Source-complete notesstep by step · useful formulations
step by steptext
Search the database:
query → index → found document → show to user

LLM:
prompt → forward pass network → logits by dictionary → token

Important:
the model doesn't know the "correct paragraph"
the model knows "which continuation is similar to the truth"

useful formulations

  • the model estimates probabilities
  • the model compresses language statistics into weights
  • the model stores articles as files
03OverviewWhat really lives in the weights1 visual1 source note

The weight of a neural network is not a “cell with knowledge”, but a small numerical coefficient. The meaning is distributed among billions of such coefficients: somewhere the tendency to associate a pronoun with a noun is stored, somewhere a code pattern, somewhere statistics of facts and style.

Visual model · Annotated exampleInspect the concrete example behind What really lives in the weights, one layer at a time.
Complete view · 4 layers
Source-complete notestwo things follow from this

two things follow from this

  • the model can generalize to new combinations
  • the model can confidently mix similar patterns
02

How text becomes numbers

4 cards
04TokensTokenization: text is not cut into letters and not always into words1 visual1 source note

The model does not see “text” like a human. It receives tokens as input: sometimes they are whole words, sometimes parts of words, sometimes punctuation marks or spaces. Such a compromise is needed so that the dictionary is not endless and does not break up into too long chains of letters.

Visual model · Annotated exampleInspect the concrete example behind Tokenization: text is not cut into letters and not always into words, one layer at a time.
Complete view · 6 layers
Source-complete notesminimal chain
minimal chaintext
"Neural networks explain text"
→ tokenizer
→ [4811, 932, 18452, 77, 901]
→ then the network works only with numbers
05TokensEmbedding: Token ID turns into a dense vector1 source note

The token with ID `4811` does not mean anything by itself. Therefore, its index is used to pull out a row from the large embeddings table. The result is a vector of hundreds or thousands of numbers, which the network can already process with linear algebra.

Source-complete noteswhat's literally happening
what's literally happeningtext
vocab_size = 128000
d_model = 4096

Embedding matrix E ∈ R^[128000 × 4096]

token_id = 4811
vector = E[4811]

This is not a calculation "by meaning"
This is a lookup: we took a ready-made table row
06TokensPositional cues: word order doesn't appear on its own1 visual

If you simply add up a set of tokens, phrases with different word orders will look the same. Therefore, position information is added to the model: which token is first, which is second, who is closer, who is further.

Visual model · ComparisonContrast the alternatives in Positional cues: word order doesn't appear on its own under the same frame.
Complete view · 6 layers
07TokensContextualization: the word “bank” changes meaning according to its neighbors1 visual

The starting embedding for a word is usually the same. But after several transformer blocks, the representation of the word changes under the influence of neighboring tokens. This is why the same word can mean different things in different sentences.

Visual model · Process flowFollow the sequence behind Contextualization: the word “bank” changes meaning according to its neighbors and locate where work or state changes.
Complete view · 5 layers
03

What it does Transformer Block do?

4 cards
08AttentionWhy was attention needed at all?1 visual

To understand a token, it's helpful to take a quick look at other important tokens. In a long phrase, the word at the end may depend on the word at the beginning. Attention provides a direct mechanism: not to drag the whole meaning through a narrow neck, but to immediately choose what to look at now.

Visual model · ComparisonContrast the alternatives in Why was attention needed at all? under the same frame.
Complete view · 5 layers
09AttentionSelf-attention: each token asks who is useful to it now1 visual1 source note

Self-attention is not magic, but a way to mix information between positions. Each token creates three versions of itself: query, key and value. Query says “what am I looking for”, key says “how can I help”, value is “what information I convey if I am selected”.

Visual model · Formula mapConnect the quantities and operations that determine Self-attention: each token asks who is useful to it now.
Source-complete notesthe essence of the formula without unnecessary mathematics
the essence of the formula without unnecessary mathematicssql
for token i:
q_i = W_Q x_i
k_i = W_K x_i
v_i = W_V x_i

score(i, j) = q_i · k_j
weights(i, :) = softmax(scores)
new_x_i = Σ_j weights(i, j) v_j

That is, token i collects a weighted mixture of value from other tokens
10BlockMLP: after context exchange there is local processing1 source note

Attention answers the question “from whom to get information.” But after this, the model must still transform the already collected meaning. This is what MLP does: a small two-layer block that is applied separately to each position.

Source-complete notessimple MLP role
simple MLP roletext
attention:
  “she” realized that she was connected with “Marina”

MLP:
  reworked this context
  enhanced beneficial symptoms
  reduced the noise
  prepared a presentation for the next block

Attention = gather connections
MLP = transform collected
11BlockResidual + LayerNorm: the glue that holds the deep network1 visual

Transformer is not just attention and MLP. Residual connections and normalization are also important. Residual allows each block not to break an already useful representation, but to neatly add an improvement on top of the old one. LayerNorm keeps numbers in a stable range.

Visual model · Concept treeTrace the hierarchy and branches that make up Residual + LayerNorm: the glue that holds the deep network.
04

Encoder, Decoder and Encoder-Decoder

3 cards
12ArchitectureEncoder: read everything at once and show understanding1 visual

The encoder model sees the entire input. Each token can look both left and right. Therefore, encoder is especially good where you need to understand the text, rather than continue it: classification, search, reranking, NER, feature extraction.

Visual model · Annotated exampleInspect the concrete example behind Encoder: read everything at once and show understanding, one layer at a time.
Complete view · 6 layers
13ArchitectureDecoder: write from left to right without looking into the future1 visual

The decoder-only model also uses transformer blocks, but with a causal mask. The token at position `i` sees only what came before it. It is this limitation that makes generation possible: the model honestly predicts the next token without knowing the future answer.

Visual model · Annotated exampleInspect the concrete example behind Decoder: write from left to right without looking into the future, one layer at a time.
Complete view · 5 layers
14ArchitectureEncoder-decoder: one reads the input, the other writes the output1 visual1 source note

In the encoder-decoder architecture, the two roles are separated. Encoder reads all the source text and builds a representation of it. The decoder generates a response one token at a time, but at each step it can look at the encoder outputs through cross-attention. This is useful for translating, summarizing and converting text from format A to format B.

Visual model · Annotated exampleInspect the concrete example behind Encoder-decoder: one reads the input, the other writes the output, one layer at a time.
Complete view · 4 layers
Source-complete noteswhen it's especially appropriate

when it's especially appropriate

  • translation
  • summation
  • structural text transformation
  • for free chat today they often use decoder-only
05

How a model learns

3 cards
15TrainingHow to learn decoder-only LLM: guess the next token1 visual1 source note

The main task of the decoder-only model is simple: to guess the next token using the left context. During training, she is shown the correct text in its entirety and is forced to predict the next token at each position. This is called next-token prediction.

Visual model · Process flowFollow the sequence behind How to learn decoder-only LLM: guess the next token and locate where work or state changes.
Complete view · 5 layers
Source-complete noteswhat is being optimized
what is being optimizedpython
for each position:
  logits → softmax → P(next token)
  compare with the correct token
  calculate loss
  adjust the weights a little

repeat this on billions of examples
16TrainingHow an encoder learns: fill in gaps and understand the context1 visual

Encoder models are usually trained differently. They corrupt the input: they hide some of the tokens or distort the text, and then ask them to restore what they missed. To cope, the model is forced to look at the left and right context simultaneously and learn to "understand" well.

Visual model · Annotated exampleInspect the concrete example behind How an encoder learns: fill in gaps and understand the context, one layer at a time.
Complete view · 5 layers
17TrainingBackprop in simple words: error pushes weights in the right direction1 source note

After each prediction, the model is compared with the correct answer. If the probability of the correct token was too small, you need to slightly adjust the weights that led to this. Backprop is a way to neatly propagate an error back throughout the network.

Source-complete noteswithout formal gravity
without formal gravitytext
1. the model predicted the probabilities
2. saw the correct token
3. got the error value
4. calculated which weights increased the error
5. moved them a little in the opposite direction

Training = billions of micro-weight shifts
06

How the model responds

3 cards
18InferencePrefill: first the model “reads” the entire prompt1 source note

When a user sends a request, the model first runs the entire prompt through itself. At this step, it builds context states for all existing tokens. This is a preparatory pass before the first new token is generated.

Source-complete noteswhat's going on
what's going onsql
prompt = system + history + user_text

tokenize(prompt)
embed(prompt_tokens)
pass all tokens through all blocks
get hidden states for all positions

This is where the understanding of the context before the first word of the answer comes from
19InferenceDecode: further response is generated one token at a time1 visual

After the first new token, the model adds it to the context and repeats the calculation. Then another one. And one more thing. Hence the feeling of flow when streaming. On the outside it looks like printing text, but on the inside it's a cycle of "evaluate probabilities → select token → add to context."

Visual model · Annotated exampleInspect the concrete example behind Decode: further response is generated one token at a time, one layer at a time.
Complete view · 6 layers
20InferenceLogits, softmax and temperature: how the next word is chosen1 visual1 source note

At the output of the generation block, the model does not output a word directly. It produces a set of numbers throughout the dictionary. These numbers are called logits. After softmax they turn into probabilities. Temperature changes the “sharpness” of this distribution: low makes the choice more conservative, high adds variety.

Visual model · Formula mapConnect the quantities and operations that determine Logits, softmax and temperature: how the next word is chosen.
Source-complete notespractical intuition

practical intuition

  • low temperature: code, formal answers
  • medium: normal chat
  • high: creative, but more risk of noise
07

Limits and common sense

3 cards
21LimitsWhy is the model hallucinating?1 source note

The model was trained to continue the text plausibly, not to verify the truth of each statement. Therefore, if the context is weak, the question is ambiguous, or similar patterns are mixed in the weights, it can confidently give a polished but incorrect answer.

Source-complete notestypical source of error
typical source of errortext
little context
or
there are too many similar patterns
or
required fact rare / fresh / controversial

→ the model selects a statistically plausible continuation
→ not a verified fact
22LimitsWhy prompt helps, but does not rewrite the model1 visual

Prompt works as a temporary context. It can direct the model's attention, set the role, give examples and push towards the desired style. But it does not change the weights themselves. Once the request completes, this temporary context disappears unless you save them in the next context.

Visual model · ComparisonContrast the alternatives in Why prompt helps, but does not rewrite the model under the same frame.
Complete view · 4 layers
23LimitsShort selection card: encoder, decoder or encoder-decoder2 source notes

If you remove the noise of terms, the choice of architecture depends on the type of task. Need to understand the input? More often encoder. Do you need to freely continue the text? Decoder-only LLM. Do you need to convert one text to another with a strict binding to the input? Often encoder-decoder.

Source-complete notestable · practical conclusion
ArchitectureHow he looks at the textStrengthTypical tasks
Encoder-onlysees the entire input at onceunderstanding and comparisonclassification, embeddings, reranking, NER
Decoder-onlyonly sees left contextfree generationchat, code, letters, brainstorming
Encoder-decoderreads the entire input and writes the output step by steptransformation A→Btranslation, summarization, structured generation

practical conclusion

  • not everything related to text needs to be solved by LLM
  • narrow task + a lot of traffic = often more profitable than encoder
  • free generation almost always gravitates towards decoder-only

No dead end

Keep moving through the map.

Continue in sequence, switch to a related guide, or return to the seven-track learning map.

Discovery graph / next reads

Continue through New Runtime

Open the graph
  1. 01learning trackLlm FoundationsOpen the complete learning track.
  2. 02related materialFrom a Neuron to an LLMContinue with another guide in this learning track.
  3. 03related materialLLM Internals: From Token to Logit to AnswerContinue with another guide in this learning track.
  4. 04related materialLLM Internals: KV Cache & GenerationContinue with another guide in this learning track.
  5. 05related materialWhat a Prompt Is and Why a Question Becomes an AnswerContinue with another guide in this learning track.

These links are also published in this page’s JSON twin and as typed edges in DiscoveryGraph v1.

Who read this page?Machine requests, hidden until opened

Loading the privacy-safe route aggregate…

Open the JSON contract