Learn AI Math

Topic 2 of 20 · 47 words

LLM Fundamentals

How large language models turn text into tokens and embeddings, predict one token at a time, and follow system and user prompts.

✎ Napkin Diagram · Topic 02How ChatGPT & Claude Talk: Super-Powered Autocomplete
PNG ↗
How ChatGPT & Claude Talk: Super-Powered Autocomplete Simple cartoon diagram showing a sentence chopped into Lego word blocks (tokens), an AI brain weighing the odds of the next word ("mat" 75%, "couch" 18%, "roof" 5%), and snapping "mat" onto the end of the sentence. 1. Chop into word-pieces ("Tokens")"The""cat""sat""on""the"1 token ≈ ¾ of a word2. Check patterns What word fitsbest next?3. Pick from top guesses"mat"75% ★"couch"18%"roof"5%Snap "mat" onto the sentence, then repeat to guess the next word! ↺ getaimath.com
Language models don’t plan whole essays at once—they play a super-smart game of "guess the very next word" over and over.

The 47 words, in learning order

Start at 1. Each word builds on the ones before it.

  1. Large Language Model (LLM)A Large Language Model is a huge AI model trained on enormous amounts of text so it can read, write and answer questions in human language.
  2. Foundation ModelA foundation model is a big, general-purpose AI model trained on broad data that can be adapted to many different tasks.
  3. Generative AIGenerative AI is AI that creates new content, like text, images, music, video or code.
  4. Multimodal ModelA multimodal model is an AI that can understand or create more than one kind of data, like text, images, audio and video.
  5. Language ModelA language model is an AI that learns how language works so it can predict or produce words and sentences.
  6. TransformerA Transformer is a type of neural network design that reads all the words in a passage at once and works out how they relate, using attention.
  7. GPT (Generative Pre-trained Transformer)GPT stands for Generative Pre-trained Transformer, a family of language models by OpenAI that generate text after being pre-trained on huge amounts of data.
  8. EncoderAn encoder is the part of a model that reads an input and turns it into a set of numbers that capture its meaning.
  9. DecoderA decoder is the part of a model that produces output, one piece at a time, such as writing a sentence word by word.
  10. Encoder-Decoder ArchitectureAn encoder-decoder architecture is a model design with two parts: one that reads and understands the input, and one that writes the output.
  11. Autoregressive ModelAn autoregressive model creates output one piece at a time, using everything it has created so far to choose the next piece.
  12. Causal Language ModelA causal language model predicts the next word using only the words that came before it, never the ones after.
  13. Masked Language ModelA masked language model learns by filling in blanks: some words in a sentence are hidden and the model guesses them using words on both sides.
  14. Next Token PredictionNext token prediction is the simple training game behind LLMs: look at some text and guess which token comes next.
  15. TokenA token is a small chunk of text, like a word or part of a word, that a language model reads and writes.
  16. TokenizerA tokenizer is the tool that chops text into tokens and turns each token into a number the model can use.
  17. VocabularyA model's vocabulary is the complete list of tokens it knows, each with its own ID number.
  18. TokenizationTokenization is the process of splitting text into tokens so a language model can work with it.
  19. Subword TokenizationSubword tokenization splits words into common smaller pieces, so the model can handle any word using a limited vocabulary.
  20. Byte Pair Encoding (BPE)Byte Pair Encoding is a popular way to build a tokenizer by repeatedly merging the most common pairs of characters into new tokens.
  21. SentencePieceSentencePiece is a free tokenizer tool from Google that splits text into subword tokens and works with any language, even ones without spaces.
  22. EmbeddingAn embedding is a list of numbers that represents the meaning of something, like a word, sentence or image.
  23. Semantic RepresentationA semantic representation is a way of storing the meaning of text or data so a computer can work with it.
  24. Latent SpaceLatent space is the hidden map inside a model where every input is placed as a point based on its meaning or features.
  25. ContextContext is all the information an AI model can see when it answers, such as your message, earlier messages and any documents you give it.
  26. Context WindowThe context window is the maximum amount of text, measured in tokens, that a model can look at in one go.
  27. Context LengthContext length is the number of tokens a model can handle at once, or how many tokens are currently being used.
  28. Input TokensInput tokens are the tokens you send to a model, including your prompt, instructions and any documents.
  29. Output TokensOutput tokens are the tokens the model generates in its reply.
  30. System PromptA system prompt is a set of hidden instructions given to an AI model before the conversation starts, to shape how it behaves.
  31. User PromptA user prompt is the message a person types to an AI model, like a question or a request.
  32. Assistant MessageAn assistant message is a reply written by the AI model in a conversation.
  33. Prompt EngineeringPrompt engineering is the skill of writing and arranging instructions so an AI model gives the best possible answers.
  34. Zero-shot PromptingZero-shot prompting is asking an AI to do a task without giving it any examples first.
  35. One-shot PromptingOne-shot prompting is asking an AI to do a task after showing it exactly one example.
  36. Few-shot PromptingFew-shot prompting is giving an AI a handful of examples in the prompt before asking it to do the task.
  37. Chain of Thought (CoT)Chain of Thought is when an AI works through a problem step by step in writing before giving its final answer.
  38. TemperatureTemperature is a setting that controls how random or creative a model's answers are.
  39. Top-K SamplingTop-K sampling means the model only chooses the next token from its K most likely options.
  40. Top-P SamplingTop-P sampling means the model picks from the smallest group of likely tokens whose chances add up to P, such as 90%.
  41. Repetition PenaltyA repetition penalty is a setting that makes a model less likely to repeat the same words or phrases over and over.
  42. LogitsLogits are the raw scores a model gives every possible next token before they are turned into probabilities.
  43. SoftmaxSoftmax is a math function that turns a list of raw scores into probabilities that add up to 100%.
  44. Probability DistributionA probability distribution is a list of every possible outcome with the chance of each one happening, adding up to 100%.
  45. Next Token ProbabilityNext token probability is the chance a model gives to a specific token being the next one in the text.
  46. SamplingSampling is how a model picks the next token from its list of possible options, using their probabilities.
  47. Deterministic GenerationDeterministic generation means the model gives the exact same output every time for the same input.

How LLM Fundamentals fits together

A Large Language Model (LLM) never reads words the way you do. First, a tokenizer chops text into subword pieces called tokens and maps each piece to a list of numbers called an embedding. Then a Transformer predicts probabilities (logits) for which token should come next, repeating that loop over and over.

Everything else in prompting and generation builds on that loop: the context window sets how many tokens the model can see at once, prompt techniques steer what sits inside that window, and sampling settings like temperature and top-p control how bold or predictable each next-token choice becomes.