Tech, AI & Internet 5 min · 840 words ·

How Modern AI & LLMs Work: Tokens, Attention & GPUs

Behind every instant reply in a modern chat assistant sits an architecture designed less than ten years ago to solve a very narrow bottleneck: reading sequences without waiting word by word. Rather than storing prewritten database answers or consulting hidden encyclopedias, a large language model predicts probability distributions over subword pieces one step at a time, weighing billions of learned parameters stored inside high-bandwidth memory chips.

Key Takeaways

From Characters to Subword Tokens

Before a neural network performs a single multiplication, a tokenizer splits every prompt into integer IDs drawn from a fixed vocabulary of typically 50,000 to 130,000 entries. Breaking sentences strictly into individual letters creates sequences far too long for efficient memory use, whereas storing every full word fails immediately on typos, compound technical names, or inflected Romanian and German endings.

Modern systems solve this with subword algorithms such as byte-pair encoding, originally published as a 1994 file compression trick. Frequent fragments like ing, tion, pro, or common whole words stay unified as single IDs, while rare surnames or new slang break gracefully into shorter known syllables. Arithmetic errors and letter-counting quirks trace directly back to this step: inside transformer layers, the model sees integer token boundaries (token 314, token 8892) rather than visual glyphs on a screen.

Why the 2017 Transformer Changed Everything

Before 2017, dominant sequence systems read sentences left to right using recurrent neural networks (RNN and LSTM). Each word had to wait for the previous hidden state to finish updating, forming a sequential traffic jam across long chapters while steadily fading memories of distant nouns.

In June 2017, eight researchers introduced the Transformer in Attention Is All You Need. Instead of moving sequentially, self-attention projects every token into three vectors called Query, Key, and Value, then multiplies all pairs simultaneously inside a single matrix pass. A pronoun near the end of a paragraph directly compares itself against every earlier noun in constant depth, letting training clusters ingest trillions of words across whole web archives without sequential stalls. Positional encodings inject sequence order mathematically alongside each vector so the network still knows who performed an action to whom.

Why GPUs Won AI Compute

Self-attention and feed-forward multilayer perceptrons reduce almost all language processing to gigantic matrix multiplications (GEMM operations). Traditional CPUs prioritize complex branching logic, low single-thread latency, and tiny execution caches suited to running an operating system cleanly.

By contrast, a graphics processing unit packs thousands of simpler arithmetic cores optimized for applying identical linear algebra across millions of screen pixels simultaneously. Researchers in the late 2000s realized pixel matrices and neural weight tensors follow identical hardware math. Specialized tensor cores and stacked high-bandwidth memory (HBM) keep huge parameter tables close to compute silicon, while NVLink and optical interconnects split giant training runs smoothly across racks of thousands of accelerators.

Pretraining, Fine-Tuning, and Human Feedback

Raw pretraining simply teaches a base network one objective across massive book, code, and article corpora: predict the missing or next token as accurately as cross-entropy loss allows. A pure pretrained base checkpoint can complete historical prose or Python boilerplate fluently, yet often answers simple questions by hallucinating another interview question instead of following instructions cleanly.

To turn completion engines into dependable tools, teams add supervised instruction fine-tuning (SFT) followed by alignment phases like reinforcement learning from human feedback (RLHF) or direct preference optimization. Human annotators rank candidate replies for helpfulness, honesty, and refusal boundaries, training a reward signal that steers weights away from toxic or rambling continuations. Even after alignment, a language model has no built-in truth sensor unless paired with external retrieval, deterministic code execution, or citation verification: hallucinations occur precisely when fluent pattern synthesis predicts plausible-sounding words for facts missing from training context.

FAQ

Why do language models occasionally struggle to count letters inside a single word?

Because tokenizers group whole words or common syllables into single numerical IDs before the neural network reads them, meaning the Transformer often inspects one combined token ID rather than separated character tokens.

What is the core advantage of a Transformer over earlier recurrent neural networks?

Transformers compute self-attention across all tokens in a context window in parallel during training, removing sequential bottlenecks and capturing relationships between distant words far more reliably.

Can an LLM verify facts on its own without external search or tools?

Not reliably, because parameter weights encode statistical patterns rather than a deterministic database, so external retrieval, calculators, and human-verified citations remain essential for accurate trivia and reference publishing.