0
0
Agentic AIml~12 mins

Short-term memory (conversation context) in Agentic AI - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Short-term memory (conversation context)

This pipeline shows how an AI agent keeps track of recent conversation to understand and respond better. It stores recent messages, processes them, and uses this memory to predict the next reply.

Data Flow - 5 Stages
1Input conversation
1 conversation with 5 recent messagesCollect recent messages as text strings5 messages as text array
["Hi!", "How are you?", "What's the weather?", "It's sunny.", "Great!"]
2Preprocessing
5 messages as text arrayConvert text to token IDs using tokenizer5 sequences of token IDs
[[101, 7632, 999], [101, 2129, 2024, 2017, 1029], ...]
3Short-term memory encoding
5 sequences of token IDsEncode sequences into fixed-size memory vectors5 vectors of size 128
[[0.12, -0.05, ...], [0.08, 0.11, ...], ...]
4Memory aggregation
5 vectors of size 128Combine vectors into one context vector1 vector of size 128
[0.10, 0.02, -0.01, ...]
5Next response prediction
1 context vector of size 128Use context vector to predict next reply tokensSequence of predicted token IDs
[101, 2204, 2017, 2064, 2173, 102]
Training Trace - Epoch by Epoch

1.2 |***************
1.0 |************
0.8 |**********
0.6 |*******
0.4 |****
    +----------------
     1  2  3  4  5  epochs
EpochLoss ↓Accuracy ↑Observation
11.200.45Model starts learning conversation patterns
20.950.60Loss decreases, accuracy improves
30.750.70Model better understands short-term context
40.600.78Continued improvement in prediction
50.500.83Model converges with good accuracy
Prediction Trace - 5 Layers
Layer 1: Input recent messages
Layer 2: Tokenization
Layer 3: Encoding messages
Layer 4: Aggregate memory
Layer 5: Predict next reply tokens
Model Quiz - 3 Questions
Test your understanding
What does the short-term memory encoding stage do?
ACombines all vectors into one
BTurns text messages into vectors
CPredicts the next reply tokens
DCollects recent messages
Key Insight
Short-term memory helps AI agents remember recent conversation parts as vectors. This memory guides better predictions for the next reply, improving with training as loss decreases and accuracy rises.