Bruno S. Aguirre

Inside an LLM: Visual Engine

← Home CV Blog Interactive Demo
Visual Architecture & Mechanics

How a Large Language Model Operates: Words → Numbers → Stochastic Roll → Words

LLMs do not think, reason, or understand physics. They are continuous high-dimensional vector engines that transform human text into numbers, push those numbers through billions of static matrix calculations, and roll a weighted dice to turn numbers back into text.

1

Phase 1

Words → Numbers

Text split into sub-words, assigned unique dictionary IDs, and converted into continuous vector coordinates.

2

Phase 2

Numbers × Billions of Weights

Vectors pass through 32 to 80 Transformer layers where attention connects words and memory cells fire.

3

Phase 3

Numbers → Words (Dice Roll)

Output scores become probabilities. A stochastic dice filter rolls to pick the next word, looping autoregressively.

Complete End-To-End Architecture

The Full Left-to-Right Signal Pipeline

1. Prompt In (Left)
"Why" ID 4839
" is the sky" IDs 318, 262, 6781
" blue?" ID 4171
2. Dense Vectors
4,096 Dim Stream
3. 32-80 Deep Layers
Self-Attention & Memory
4. Dice Filter
Temp T=0.7
Stochastic Sampling
5. Words Out
"Sunlight"

Signals originate as raw prompt strings on the far left, convert to numbers, ripple through 32 to 80 Transformer layers, pass through a stochastic probability filter, and emerge as output words on the right.

1

Phase 1: Words → Numbers

Ingestion: Translating String Text into Continuous Vector Coordinates

A

1. Sub-Word Tokenization

Computers cannot process string letters directly. First, a tokenizer slices words into sub-word chunks called tokens using algorithms like Byte-Pair Encoding (BPE).

"Why is the sky blue?"
"Why" " is" " the" " sky" " blue" "?"
Result: Text cut into discrete, measurable units
B

2. Dictionary ID Lookup

Every token maps directly to a unique integer index in the model's fixed vocabulary dictionary (containing 32,000 to 128,000 cataloged words).

Token String Dictionary Integer ID
"Why" 4839
" is" 318
" the" 262
" sky" 6781
" blue?" 4171
Result: [4839, 318, 262, 6781, 4171]
C

3. Continuous Vectors & Waves

Integer IDs cannot undergo math operations. They are converted into dense streams of 4,096 numbers (embeddings) blended with sinusoidal wave signals (positional encodings) to track word order.

Vector Coordinates (4,096 Dim):
[+0.82, -0.14, +0.95, +0.02, -0.61, ...]
Positional Signal Waves Blended In
Result: High-dimensional geometry ready for calculation
2

Phase 2: Numbers Through Billions of Weights

Deep Transformer Layers: Calculating Word Connections & Associative Memory

Self-Attention Mechanics Interactive Attention Matrix

How Words Look at Other Words

Click on any word below to see how the model calculates attention weights connecting it to other prompt words (e.g., how "blue" directs strongest attention toward "sky" and "Why").

Self-attention replaces hard rules with dynamic contextual correlations.

Feed-Forward Pattern Memory

While Attention connects active prompt words, Feed-Forward layers act as a massive static dictionary encyclopedia. The vector expands 4x in size to fire stored pre-training knowledge.

Vector Dimension Expansion
4,096 Dimensions 16,384 Dimensions

Triggers static knowledge memory cells learned during web training

Stacking 32 to 80 Transformer Layers

Each layer refines the numbers. Early layers handle basic syntax; middle layers handle semantics; deep layers form high-level abstract predictions.

Layer 80 (Deepest) High-level Reasoning State
... 78 Intermediary Layers ...
Layer 01 (Initial) Grammar & Syntax Signals
3

Phase 3: Numbers → Stochastic Dice Roll → Words

Output Logits, Probability Distributions, and the Temperature Dice Sampler

Interactive Stochastic Simulator

Where Randomness Enters

After 80 layers, the LLM produces raw score numbers (logits) for every word in its vocabulary. The Temperature Knob controls how flat or sharp the probabilities become before rolling a weighted dice to pick the winner!

0.7 (Balanced)
0.1 (Strict / Predictable) 0.7 (Default) 1.5 (Creative / Random)

Next Token Probability Distribution

Winner: "Sunlight"

At Temperature 0.7, highest scoring token ("Sunlight") has a 68% chance of winning, but lower candidates still have a valid dice roll probability.

Reality vs. Statistical Co-occurrence

Why an LLM is a "Stochastic Parrot"

To demonstrate why LLMs lack comprehension, consider what happens when a model generates a response to "Why is the sky blue?":

Real Physical World (Rayleigh Scattering)

Sunlight contains all color wavelengths. When light enters Earth's atmosphere, high-frequency short blue light waves collide with Nitrogen ($N_2$) and Oxygen ($O_2$) gas molecules and scatter in every direction.

Short Blue Waves: Scatter strongly off gas molecules
Long Red Waves: Pass straight through atmosphere
Requires grounded physical atmospheric physics

LLM Mechanics (Stochastic Parrot)

The LLM has no concept of light waves, gas, or skies. If it generates: "The sky is blue because water vapor scatters light", it outputs this simply because words like "water", "vapor", and "blue" co-occur near each other on millions of web pages.

Zero Physical Understanding: No sensor or world model
Geometric Trajectory: Matches statistical paths in weights
Regurgitates high-probability language patterns

Core Insight

Language models synthesize syntactic coherence via mathematical probabilities, not semantic comprehension.

Hermes Agent Harness → Hermes Architecture Spec →