LLMs & Generative AI ยท 2.1

๐Ÿ’ฌ How Large Language Models Work

The surprisingly simple trick behind ChatGPTโฑ ~2 min

๐Ÿ“ฑIt's autocomplete on a planetary scale

When your phone suggests the next word as you type, that's a tiny language model. An LLM like ChatGPT is the same idea โ€” predict the next word โ€” but trained on a huge chunk of the internet and made enormously bigger. That's genuinely most of the secret. It's autocomplete that read a library.

Predict the Next Token, Over and Over

A Large Language Model does one thing: given some text, it predicts the next 'token' (a word or word-piece). It picks one, adds it to the text, and predicts again. Repeat, and coherent paragraphs pour out. The model isn't 'thinking' about your question โ€” it's computing which token most plausibly comes next, based on patterns in its training data.

"The cat sat on the ___"the prompt so farLLMmat46%floor22%couch14%moon2%An LLM predicts the next word (token), picks one, then repeats โ€” thousands of times per answer.That's the whole trick. Everything else is scale: billions of weights, trillions of training words.
The whole mechanism: predict the next token, pick one, repeat

The Transformer โ€” The Breakthrough Architecture

Modern LLMs are built on a neural network design called the Transformer, introduced by Google researchers in 2017 in a paper titled 'Attention Is All You Need.' Its key innovation, 'attention,' lets the model weigh which earlier words matter most for predicting the next one โ€” so it can track context across long passages. Every major model (GPT, Claude, Gemini, Llama) is a Transformer.

Key Terms for Talking About LLMs

TermMeaning
TokenA chunk of text the model processes โ€” roughly ยพ of a word in English
PromptThe text you give the model as input
Context windowHow much text the model can 'see' at once โ€” its short-term memory limit
ParametersThe model's learned weights โ€” more (usually) means more capable, and more expensive
TemperatureA setting controlling randomness โ€” low = predictable, high = creative/varied
Training vs inferenceTraining = the (huge) one-time learning; inference = each time you use it
โ˜… FactLLMs have no memory between separate conversations unless the app adds it, and no live access to the world unless connected to tools. Out of the box, a model only knows patterns from its training data, which has a cutoff date. When it 'looks something up,' a tool is fetching that for it โ€” the model itself is frozen.
๐Ÿง Quick Checkfirst try = +5 XP

At its core, what does an LLM like ChatGPT actually do?

โญ 0 XP๐Ÿ”ฅ 0 days