← AI Knowledge Home05 · Tokens, Context & Inference
How a Language Model Turns Your Input into an Answer
This module explains how text becomes tokens, enters the model’s context, and is processed during inference to generate an answer one token at a time.
Follow one request from raw text to generated output.
The Big Picture · inference timeline
From user text to final response
USER TEXTRaw input from a person or application
↓
TOKENIZATIONText is split into token units
↓
TOKENSUnits the model processes
↓
CONTEXT WINDOWInformation available for this run
↓
INFERENCEThe trained model processes the context
↓
NEXT-TOKEN PREDICTIONCalculate probabilities for possible next tokens
↓
SAMPLINGA generation method selects the next token
↓
GENERATED TOKEN ↺ REPEATAdd it to the sequence until a final response is complete
Knowledge Map
Understand each idea by its role
A · INPUT
Converts raw text into tokens.
A unit processed by the model.
B · CONTEXT
The amount of information available during a run.
C · EXECUTION
Running the trained model on current input.
Next-token Prediction
Calculating probabilities for possible next tokens.
D · CONTROL
Controls how next-token choices are selected.
Reuses earlier attention information during generation.
Key Distinctions
Connected concepts, different jobs
TokenModel input unit≠WordHuman language unit
TokenizationConversion process≠TokenResulting unit
Context WindowAvailable request information≠MemoryPersistent state across work
InferenceRunning a trained model≠TrainingChanging learned parameters
PredictionScores possibilities≠SamplingSelects one option
KV CacheEfficiency support≠Context WindowAvailable context
Recommended Learning Path
Learn the flow in order
This is a learning path, not a strict software pipeline.
01TokenizationHow text is converted.
02TokenWhat the model processes.
03Context WindowWhat is available.
04InferenceHow the model runs.
05PredictionHow options are scored.
06SamplingHow one token is selected.
07KV CacheHow repeated work is reduced.
Remember the flow
Text is tokenized, placed into context, processed during inference, and generated one token at a time through prediction and sampling.