User Input
Model Processing
Output
Context Window
User Prompt
Natural language input
Raw query or instruction
System Prompt
Behaviour constraints
Persona & tone rules
Conversation History
Prior turns & memory
Token budget managed
→ tokenise
Tokenisation
BPE encoding
~100k vocab tokens
Embedding Layer
Token → vector representation
Positional encoding applied
↓ forward pass
Transformer Blocks
Multi-head self-attention
Feed-forward network
Layer normalisation ×N
↓ decode
Output Projection
Linear layer → logits
Softmax probability dist.
↓ sample
Token Sampling
Temperature / top-p
Next token selected
✓
Response Assembly
Tokens decoded to text
Streamed to interface
↓ filter
Safety Layer
RLHF alignment check
Policy enforcement
↓ deliver
Final Output
Formatted response
Rendered to user
↓ loop
Feedback Loop
Response appended
to conversation history
—   Inference State   —
Stateless per call ~100ms latency Autoregressive generation Max context: 128k tokens