Evening-Truth

LLM and Memory

Back to LLM 101

What AI remembers

The mean truth is... AI remembers nothing about your chat.
I know what you're thinking.

"But it does remember what I said 12 messages earlier. Evening-Truth... don't lie to me!!!"

Fact is, the human concept of "remembering" is different to how LLMs "remember".

The LLM doesn't have a specific place on the server for your conversation with it, so it does something that seems strange from a human perspective but is actually very smart from the technical side.

When you send your message, that message is only one part of what is sent to the LLM in what is called a request.

You only see your conversation with the bot. The LLM receives a ton of data with every request that includes technical stuff like Sampler Values, model ID, a set of rules that explains the AI what it has to do, the character descriptions of your bot, the description of your persona, descriptions of the world and lore, all the messages you have exchanged with the bot so far, and the message you just wrote.

Imagine this big pile of data like a book.

Now, every time you send a new message you are writing it into the first free line in that book and send it back to the LLM.
Since the LLM is computing big amounts of requests every second of the day, it takes the book you just send and reads it from front to end to generate a message that fits to everything that it just read.

You receive that message but only have to read that one message to know that it fits with what happened before.
Because your brain is fucking awesome.

Your next message to the model will be processed exactly the same... the entire book is sent, the LLM reads it again from front to back and generates the reply.

If you leave the chat or switch to another character, the LLM gets a completely different book to read and reply to.

"But what about this prompt caching thing?"

Listen... I'm not gonna throw words like Intermediate Computation at you here. If you want to know about that, go ahead. But here and now we are staying with the book metaphor.

While processing your book the LLM writes note cards.
Not a summary of the conversation though. More like note cards with the results of mathematical calculations it did. A ton of them.
You remember how I talked about tokens and boring math before? That math is doing its job here. And the results are on these index cards.
It's complicated, only numbers, and not once is the color of your persona's eyes mentioned. But it works.

The system can store these note cards and use them for your next message instead of creating new ones for every message.
They also expire after a while. Sometimes after five minutes, sometimes after hours.

For our creative writing and roleplay sessions this doesn't have really interesting benefits other than this.... cached tokens are cheaper than newly send ones.
Caching is more interesting for tasks with extremely big contexts that don't change much over time. In that case it helps significantly with processing speed and price.

And here's another important fact.
These note cards do absolutely nothing while they are not being used. They just chill on the server. They don't contemplate the meaning of life or think about their next trip to Disney World. They just... are.


"What is context size?"

There are LLM's that have a context size of 2 million tokens, and others that have 30.000 tokens.

To put that into perspective

  • Shakespear's Hamlet is approximately 40.000 tokens,
  • The Great Gatsby by F. Scott Fitzgerald is somewhere around 63.000 tokens.

The context size tells you how big the book you send to the LLM can be. How much data/tokens/words it can process overall... but that's just technical.

For roleplay and creative writing, context coherency is more important.


"What is context coherency?"

This tells you how good the LLM is in "remembering" or focusing on details of what you talked about earlier in your roleplay and that number is drastically lower than the context size.

LLMs try to understand what parts of your conversation are important. Which is relatively easy in factual tasks like coding, statistic analysis, technical documentation and so on. In creative writing and roleplay, that's a tricky bit since there is a lot of prose, background info and rules to stay on top of.

In the olden days (Translate: In 2025) context coherency could start to drop around 9K tokens already.
So the AI very very soon would start to mix up details or entire events. To stay with the book metaphor, it couldn't properly remember whatt it read 5 pages earlier.

With all the magic and mysteries and shenanigans happening in the AI world, we now have models that can handle up to 30K tokens and process them coherently in roleplay and creative writing.

That's almost the entire play of Hamlet and the AI still would know that Claudius is the bad guy!

If you want to know more about this, you can look up Transformer attention mechanisms, self-attention, and attention weights.
Only if you're curious. 😘


"What happens when the context size is full? Do I lose the chat?"

No. Your chat will always go on. But the AI will start to forget things. To make sure it doesn't forget the important parts, smart brains made a difference between permanent tokens and temporary tokens.

Permanent tokens are information that will always be sent in your requests to AI. Things like the system prompt, character descriptions, designated memories, and other technical bits and pieces, depending on the platform you chat on.

Your chat history with the bot are temporary tokens or temporary information. That means when the context size of your chat is filled and to keep the chat running, the oldest messages of the conversation drop out of the book. AI nerds call it the rolling context window

Here's a little bit of math for you.

Let's say you use an LLM with 24K tokens context size.
The bot you're talking to contains 3.000 permanent tokens. The initial message from that companion has 600 tokens.
You have system instructions of 2.500 permanent tokens (which you don't because you are using my prompts that are highly token efficient, right? RIGHT???)
The conversation you had so far with the bot is roughly 3.000 tokens. (approximately three to five back and forth messages.)

That's
3.000 + 600 + 2.500 + 3.000
= 9.100 tokens in total

The context size of your llm is 24.000 tokens.
So you have a decent amount of tokens free for shenanigans with your bot without even coming close to the context window. 😉

Now go forth and traumatize some algorithms.
 
Back to LLM 101

Edit

Pub: 21 Oct 2026 14:25 UTC

Edit: 22 Oct 2026 18:02 UTC

Views: 299