LLMs Explained: 36 Key AI Concepts
Tokens, embeddings, attention, RAG, agents, MCP… 36 key concepts to understand how LLMs and modern AI applications work.
Introduction
An LLM (Large Language Model) is an artificial intelligence model trained on a very large amount of data to understand and generate natural language.
Models such as GPT, Claude, Gemini, and Llama are examples of LLMs.
An LLM does not "think" like a human. At a fundamental level, it predicts the most likely next token based on the patterns and relationships it learned during training.
1. The Fundamental Principle
At a very high level, an LLM works like this:
User Input
|
v
Tokenization
|
v
Tokens
|
v
Embeddings
|
v
Transformer
|
v
Probabilities
|
v
Next Token
|
v
Repetition
|
v
Generated TextFor example:
"The sun rises in the"The model might estimate:
east 0.72
Paris 0.03
morning 0.01
...It selects a token and repeats the process until it produces a complete response.
2. Token
An LLM does not usually work directly with words.
It works with tokens.
A token can represent:
- a word;
- part of a word;
- a character;
- punctuation;
- sometimes a space combined with a word.
For example:
"Hello everyone"could be tokenized approximately as:
["Hello", " everyone"]The exact tokenization depends on the model and tokenizer.
Why are tokens important?
Tokens determine things such as:
- context window size;
- API cost;
- how much text a model can process;
- how much text a model can generate.
3. Context Window
The context window is the maximum amount of tokens a model can consider at once.
┌─────────────────────────────────────────────┐
│ Context Window │
├─────────────────────────────────────────────┤
│ System instructions │
│ Conversation │
│ Documents │
│ Tool results │
│ User message │
└─────────────────────────────────────────────┘A larger context window allows a model to work with more information within a single interaction.
However, a large context window does not automatically mean that the model will use every piece of information perfectly.
4. Embeddings
Embeddings represent information as numerical vectors.
For example:
"cat"could be transformed into:
[0.12, -0.43, 0.87, ...]Concepts that are semantically similar tend to have relatively close representations in the vector space.
dog
*
/
/
*
cat
car *Embeddings are especially important for:
- semantic search;
- vector databases;
- RAG;
- classification;
- recommendations;
- document similarity.
5. Transformer
Modern LLMs are primarily based on the Transformer architecture.
Transformers allow models to process relationships between different tokens in a sequence.
Its central mechanism is attention.
"The developer fixed the bug
because they found the error."
attention
|
v
"they" ───────────────> "developer"The model can learn which parts of the context are relevant when interpreting a token.
6. Attention
The attention mechanism allows the model to determine which pieces of context are relevant for producing the next token.
A simplified representation is:
Attention(Q, K, V)
=
softmax(QKᵀ / √d) VWhere:
- Q — Query: what we are looking for;
- K — Key: what helps identify relevant information;
- V — Value: the actual information used.
This mechanism allows the model to capture complex relationships between tokens.
7. Parameters
Parameters are the numerical values learned by the model during training.
Models can be described as having:
7B parameters
70B parameters
400B parameters
...The number of parameters gives an indication of the model's size, but it is not a direct measure of intelligence.
Two models with a similar number of parameters can have very different capabilities.
8. Training
Training consists of adjusting the model's parameters so that it becomes better at predicting tokens.
A simplified process:
Dataset
|
v
Tokenization
|
v
Model
|
v
Prediction
|
v
Compare with expected output
|
v
Loss
|
v
Backpropagation
|
v
Update Parameters
|
└───────────────> Repeat9. Pretraining
Pretraining is the first major training phase.
The model learns language structures and relationships from a very large dataset.
A common task is next-token prediction:
"Paris is the capital of"
↓
FranceAfter seeing a huge number of examples, the model learns increasingly complex representations of language.
10. Fine-tuning
After pretraining, a model can be specialized through fine-tuning.
Targeted examples are provided to modify or improve the model's behavior.
For example:
General LLM
|
v
Fine-tuning
|
v
Specialized LLMFine-tuning can be used to improve:
- a specific behavior;
- a particular task;
- a specific domain;
- output formatting;
- instruction following.
11. Instruction Tuning
Instruction tuning trains a model to better follow human instructions.
For example:
Instruction:
"Summarize this text in three sentences."
Expected response:
"The text explains..."The model learns to associate instructions with expected behaviors.
12. RLHF
RLHF — Reinforcement Learning from Human Feedback uses human preferences to improve model behavior.
A simplified representation:
LLM
|
Multiple responses
|
v
Human evaluation
|
v
Reward Model
|
v
Model optimizationThe goal is to make responses:
- more useful;
- safer;
- more relevant;
- better aligned with instructions.
13. Inference
Inference is the process of using a trained model to generate a response.
Prompt
|
v
LLM
|
v
Token
|
v
Token
|
v
Token
|
v
ResponseTraining learns the parameters.
Inference uses those parameters to generate output.
14. Temperature
Temperature influences how deterministic or random the generation process is.
Simplified:
Low temperature
|
v
More deterministic responses
High temperature
|
v
More varied responsesA higher temperature does not automatically make the model "smarter".
It mainly changes the probability distribution used when selecting tokens.
15. Hallucination
A hallucination occurs when a model generates false or fabricated information while presenting it as if it were factual.
For example:
User:
"What book did X publish in 1987?"
LLM:
"X published Y in 1987."Even if the book does not exist, the model may generate a plausible-sounding answer.
This is an important consequence of the generative nature of LLMs.
16. RAG
RAG — Retrieval-Augmented Generation allows an LLM to use external information at inference time.
Documents
|
v
Embeddings
|
v
Vector Database
|
User question ──> Retrieval
|
v
Relevant Context
|
v
LLM
|
v
ResponseRAG is particularly useful for:
- documentation;
- knowledge bases;
- internal files;
- technical documentation;
- frequently changing information.
RAG does not retrain the model.
It provides additional context at inference time.
17. Vector Database
A vector database stores vector representations, usually embeddings.
Examples include:
- Pinecone;
- Qdrant;
- Weaviate;
- Milvus;
- pgvector.
Traditional search looks for matching words.
Vector search instead looks for semantic similarity.
Question
|
Embedding
|
v
[0.13, -0.42, 0.81, ...]
|
v
Find similar vectors
|
v
Relevant documents18. Prompt
A prompt is the set of instructions and information provided to the model.
A prompt can contain:
System instructions
+
Context
+
Examples
+
User requestA good prompt can specify:
- the model's role;
- the task;
- constraints;
- expected format;
- context;
- success criteria.
19. System Prompt
The system prompt contains general instructions defining the expected behavior of the model.
Simplified architecture:
System
|
+── behavior
+── rules
+── constraints
|
User
|
+── request
+── contextSystem instructions are particularly important in applications built around LLMs.
20. Tool Calling
An LLM can be given access to external tools.
For example:
User
|
v
LLM
|
| "I need the weather"
v
Weather Tool
|
v
Result
|
v
LLM
|
v
ResponseTools can allow a model to:
- search the web;
- call an API;
- query a database;
- execute code;
- send an email;
- create a file;
- interact with an application.
The LLM does not necessarily perform the action itself.
It can decide that a tool should be called, then use the result returned by that tool.
21. Function Calling
Function calling is a structured way for a model to request the execution of a function.
For example:
{
"name": "get_weather",
"arguments": {
"city": "Nantes"
}
}The application then executes the actual function and sends the result back to the model.
This makes it possible to connect an LLM to external systems in a controlled way.
22. Structured Output
An LLM can also be constrained to return structured data.
For example:
{
"name": "John",
"age": 32,
"city": "Paris"
}This is particularly useful when integrating an LLM into a software application.
Instead of parsing free-form text, the application can receive a predefined structure.
23. Memory
Memory allows an application using an LLM to retain information beyond the immediate interaction.
Several forms of memory can be distinguished.
Memory
|
┌───────────┴───────────┐
| |
Short-term Long-term
memory memory
| |
Context Database / StoreShort-term memory
Information available in the current context.
Long-term memory
Information stored externally and retrieved when needed.
Memory is therefore not necessarily an intrinsic property of the LLM itself.
24. Agent
An AI agent is generally a system capable of:
- understanding a goal;
- analyzing the situation;
- deciding on an action;
- using tools;
- observing the result;
- repeating the process when necessary;
- stopping when the goal is achieved.
Goal
|
v
LLM / Agent
|
┌─────┴─────┐
v v
Think Tool
^ |
| v
└── Result ─┘
|
v
DoneAn agent is therefore more than simply sending a prompt to an LLM.
25. Agentic AI
Agentic AI refers to an approach where AI systems have some degree of ability to:
- plan;
- make decisions;
- use tools;
- maintain state;
- observe their environment;
- pursue a goal.
The evolution can be represented as:
LLM
|
v
LLM + Prompt
|
v
LLM + Tools
|
v
LLM + Tools + Memory
|
v
Agent
|
v
Multi-Agent System26. Skills
A skill generally represents a specialized capability that an agent can use.
For example:
Agent
|
├── Search skill
├── GitHub skill
├── Email skill
├── Database skill
├── Browser skill
└── Coding skillA skill can contain:
- instructions;
- tools;
- knowledge;
- workflows;
- rules;
- reference files.
The goal is to make an agent's capabilities modular and reusable.
27. Workflow vs Agent
It is important to distinguish a deterministic workflow from an agent.
Workflow
The steps are predefined.
Input
↓
Step 1
↓
Step 2
↓
Step 3
↓
OutputAgent
The model can decide what action to take next.
Input
↓
Agent
↓
Decision
├── Tool A
├── Tool B
└── Tool C
↓
Observe
↓
Decision
↓
OutputA workflow is generally more predictable.
An agent is generally more flexible.
28. MCP
MCP — Model Context Protocol is a protocol designed to connect AI applications and models to external tools and data sources in a standardized way.
Simplified architecture:
AI Application
|
MCP
|
┌──────────┼──────────┐
v v v
GitHub Database FilesMCP can standardize how applications expose:
- tools;
- resources;
- prompts.
29. Multimodality
Modern AI models can sometimes process multiple types of data.
This is known as multimodal AI.
Text ───────┐
Image ──────┤
Audio ──────┼──> Model ──> Output
Video ──────┤
Files ──────┘Depending on the model, inputs and outputs can include:
- text;
- images;
- audio;
- video;
- structured files.
30. Latency
Latency is the time required to receive a response.
It depends on factors such as:
- the model;
- context length;
- number of generated tokens;
- provider;
- number of tool calls;
- application architecture.
An agent can be slower than a simple LLM call because it may perform multiple steps.
31. Cost
LLM usage costs are generally related to the number of tokens processed.
A simplified model:
Input tokens
+
Output tokens
=
UsageFor agentic applications, you also need to consider:
User
↓
LLM call
↓
Tool
↓
LLM call
↓
Tool
↓
LLM callThe more calls an application makes, the higher the potential cost and latency.
32. Evaluation
An LLM application needs to be evaluated.
You can measure:
- accuracy;
- relevance;
- factuality;
- format compliance;
- latency;
- cost;
- error rate;
- tool-call accuracy.
An LLM architecture without an evaluation system is difficult to improve reliably.
33. Fine-tuning vs RAG
It is important not to confuse the two.
| Fine-tuning | RAG |
|---|---|
| Changes the model | Does not change the model |
| Teaches behavior | Provides context |
| Good for behavior and specialization | Good for external knowledge |
| Requires training | Does not require retraining |
| Can be expensive | Usually simpler to update |
A simple rule:
I want to change the model's behavior
→ Fine-tuning
I want to provide external knowledge
→ RAG34. Complete AI Application Architecture
A modern AI application can combine many of these concepts:
User
|
v
AI Application
|
┌─────┴─────┐
| |
Memory RAG
| |
└─────┬─────┘
|
v
LLM
|
┌─────┴─────┐
| |
Tools Skills
| |
└─────┬─────┘
|
v
External SystemsThe LLM is therefore only one part of the overall system.
35. Key Concepts to Remember
If you want to understand the modern AI ecosystem, you should at least know:
LLM Fundamentals
- LLM
- Token
- Tokenizer
- Context Window
- Parameters
- Embeddings
- Transformer
- Attention
- Inference
- Training
- Pretraining
- Fine-tuning
- Instruction tuning
- RLHF
- Temperature
- Hallucination
AI Engineering
- Prompt
- System prompt
- Structured output
- Function calling
- Tool calling
- API
- Streaming
- Evaluation
- Observability
- Latency
- Token cost
Knowledge & Memory
- Embeddings
- Vector database
- Semantic search
- RAG
- Chunking
- Retrieval
- Reranking
- Short-term memory
- Long-term memory
Agents
- Agent
- Agentic AI
- Tool use
- Planning
- Reasoning
- Workflow
- Skills
- Memory
- Multi-agent system
- MCP
36. The Big Picture
The most important thing is to understand how all these concepts fit together.
AI
|
┌────────────┴────────────┐
| |
LLM Computer Vision
|
┌───────┼────────┐
| | |
Prompt RAG Tools
| | |
| Embeddings |
| | |
| Vector DB |
| | |
└───────┼────────┘
|
Agent
|
┌──────┼──────┐
| | |
Memory Skills MCP
| | |
└──────┼──────┘
|
AI ApplicationThe conceptual progression can be summarized as:
LLM
↓
Prompt
↓
Context
↓
RAG
↓
Tools
↓
Memory
↓
Agent
↓
Skills
↓
MCP
↓
Agentic AIThe goal is not simply to memorize what each term means.
The important part is understanding what problem each concept solves, when to use it, and how these components can be combined to build reliable AI applications.