Skill 1.2.1

Describe how generative AI models work

Key Concepts

Language models work with tokens, which are words or pieces of words; a rough guide is that 100 tokens correspond to about 75 English words. Each token is mapped to an embedding, a vector of numbers whose position reflects meaning, so that related tokens such as dog and puppy are close together. Modern language models use the transformer architecture, whose attention mechanism lets the model weigh how relevant each token in the context is to every other token.

A model is first pretrained on large amounts of text to predict the next token, then usually fine-tuned and aligned with human feedback so that it follows instructions helpfully and safely. At inference time the model receives the prompt, calculates a probability for each possible next token, selects one, appends it and repeats until it reaches a stop condition. Because the output is a prediction of plausible text rather than a lookup of facts, models can produce fluent but incorrect statements; grounding the prompt in trusted data reduces this risk. The amount of text a model can consider at once is its context window, measured in tokens.