Human Memory, Machine Memory: What AI Forgets That Brains Don't
A computational neurobiologist and a developer compare notes on how brains and LLMs encode, consolidate, and retrieve information — and why context windows are nothing like hippocampi.
Introduction to Artificial Intelligence
Unlike the human brain, Large Language Models (LLMs) do not have a biological memory or a brain that stores information. AI memory is not an illusion; it is simply a mathematical, non-biological form of memory.
We can divide an AI’s memory into three distinct sections:
- Learned knowledge (static): This represents the model’s deep structure. We can think of it as our own memory, which learns new information over the course of our lives. It’s the same for LLMs, except that to gain experience and learn new concepts, they need to be trained. This memory is represented by the model’s weights and its billions of parameters;
- Working memory (dynamic): we can think of this as the model’s ability to maintain a logical and coherent thread during a conversation with an interlocutor, except that as soon as the conversation ends, it forgets what was discussed. This memory is represented by the context window;
- Long-term (external) memory: This is the equivalent of our library or our notes. Since an LLM cannot update its internal weights in real time and does not have access to our private data, it relies on vector databases or external wikis to retrieve the missing information needed to respond.
The Mechanics of Memory in AI
To understand how an LLM remembers and manages information, we must analyze the system’s mathematical architecture. AI memory does not operate randomly, but follows a set of precise and distinct mathematical rules.
Static Parametric Memory (Long-term Memory)
This is the long-term memory of the LLM model, and it is also the primary memory. The model’s overall knowledge is shaped solely during two distinct macro-phases: Training and Fine-tuning. This process is based on error quantification and backpropagation within the neural network.
- Training (pre-training): a phase in which the model starts from scratch. At the beginning, its billions of weights are just random numbers. The AI is fed enormous amounts of general data from the internet to learn grammar and logic; it’s a bit like our own schooling;
- Fine-tuning: involves taking an existing model and subjecting it to targeted training on specific data. The model doesn’t start from scratch; instead, it refines its weights to specialize in a specific vertical—much like choosing a major in college.
Let’s take a closer look at the mechanism behind these stages. AI is like a child: it knows nothing about the world, so it does what is known in technical terms as “trial and error.” Just like a child, it performs random actions, except that a mathematical function called the Loss Function is what signals its errors. The function doesn’t just tell the AI that it’s making a mistake; it quantifies the error with extreme precision.
Let’s look at a concrete example: imagine teaching AI to read and respond. When the AI generates an incorrect word, the system measures how far that choice deviates from the correct one.
Once the error is measured, the core of the learning process kicks in: Backpropagation, which travels backward through the entire neural network, calculating the gradient for each of its billions of weights! We can think of it as a compass that tells the algorithm in which direction and by how much each of the countless virtual knobs should be turned to reduce the error in the next attempt.
This correction is performed according to the following optimization formula:
In this equation, the new weight value () is calculated by subtracting a fraction of the loss gradient () from the old value, scaled by a factor called the learning rate (), which determines how drastic the algorithm’s course correction should be after each step.
By repeating this cycle billions of times across numerous texts, those numbers—which were initially completely random—begin to organize themselves, creating a dense network of semantic and logical relationships. When the engineers decide that the model has learned enough, the process is halted and the learning stops. The weights are permanently locked into read-only (non-editable) files. From that point on, the AI’s static memory will remain fixed, becoming a library that the model will faithfully consult in response to every request we make, without being able to add any new deep memories on its own.
Dynamic Working Memory (Context Window and Self-Attention)
While the static memory of weights represents everything the artificial intelligence has learned during its training, there is an obvious limitation: this knowledge is static, unable to change or expand during a normal conversation with a user. In order to actively interact with a human being, the algorithm requires a second type of architecture: a dynamic working memory capable of handling the “here and now” of the conversation. This vital function is performed by what is known as the context window.
There is a deeply fascinating—and in some ways counterintuitive—aspect to how this mechanism works. When we interact with a chatbot, we have the distinct impression that the system “remembers” what we wrote a few lines earlier, but in reality, this is a computational illusion. AI does not maintain a continuous stream of consciousness or a vivid memory of the past. Every time we hit enter and send a new message, the entire chat history is repackaged from scratch and sent back to the model along with the latest sentence. In simple terms, the AI isn’t remembering the past; it’s re-reading it from the beginning every single time at extremely high speed.
To keep track of this ongoing reinterpretation—and to understand what distant pronouns or concepts in the text refer to—the models rely on a mechanism called Self-Attention. In practice, at every step, the algorithm measures how relevant each word is relative to all the others in the conversation. In a sentence like “I adopted a cat, and ever since then he’s been sleeping on the couch”, it is thanks to Self-Attention that the model understands that the “he”—which appears a few words later—refers specifically to the cat and not to something else.
Each word, or token, is first converted into a vector: a string of numbers that maps its meaning within a multidimensional space. For each vector, the model calculates, using specific weight matrices, three distinct projections—the Query, the Key, and the Value. The query is the information that the word is searching for in the rest of the text; the key serves as an index of what that word contains; the value is the actual content it provides if deemed relevant.
All of this is encapsulated in a single formula, the Scaled Dot-Product Attention:
The core is the dot product between the query matrix and the transpose of the key matrix (): it generates a matrix of scores that measures how closely each word is related to all the others. The result is divided by a scaling factor () to stabilize the calculation and normalized by the softmax, which transforms the raw scores into probabilities between zero and one. Finally, these probabilities weight the Value vectors (), allowing the model to assess the importance of each concept and generate a response consistent with the overall context.
However, just like our short-term memory, this dynamic memory also has an insurmountable physical limit. As soon as the conversation extends beyond the maximum capacity of the context window, the oldest messages begin to be excluded from the data sent to the model and are forgotten forever. Furthermore, since this is purely computational and session-based memory, the moment the user closes the chat or resets the conversation, the entire matrix vanishes instantly, leaving the model with no recollection of our interaction and ready to start from scratch.
External Long-Term Memory (Vector Databases and RAG)
There is a third scenario in which both the stability of weights and the transience of the context window fail. What happens if we need the AI to answer a question based on private data, such as our company’s articles of incorporation, or on breaking news not included in its frozen training data? Adjusting the model’s weights would require days of computation and millions of dollars, while loading the entire corporate encyclopedia directly into the context window would instantly exhaust the available space, driving up computational costs. To resolve this impasse, software engineers have paired the models with an external long-term memory—an independent architecture known as Retrieval-Augmented Generation (RAG) that relies on vector databases.
This repository operates on a purely computational and systems-based principle. Private documents, websites, or corporate wikis are broken down into small blocks of text and converted into strings of numbers called embeddings, which capture their conceptual meaning. These static vectors are then indexed within a specialized database. When a user asks a complex question, the system does not immediately consult the LLM’s weights, but instead converts the query into a vector and searches the external database for the most geometrically similar and relevant document fragments. Once the correct paragraphs are found, the system extracts them and “injects” them in real time directly into the model’s context window. At this point, the AI has the updated data right in front of it and can use it to formulate the response.
The distinction between what the AI processes internally and what it retrieves from this archive is clear-cut, both in terms of their intrinsic nature and their impact on computational resources. On the one hand, internal memory has a mathematical and algorithmic structure, organized into temporary tensors and dense matrices of real numbers; on the other hand, external memory follows traditional systems and computing logic, consisting of static files saved on disk.
This difference has a significant impact on the system’s costs and flexibility. Calculating attention within the model’s native memory incurs a very high computational cost, which scales quadratically with the amount of text input. In contrast, searching an external vector database is an extremely lightweight and fast operation, driven by search algorithms that require very few resources. Furthermore, while updating the internal memory is a monumental task that requires new training cycles and gradient calculations, modifying the external memory is instantaneous: simply overwriting a file or adding a new row to the database is enough to update the entire body of knowledge available to the system.
Thanks to this clear separation, internal memory remains the logical and rational framework through which the AI computes relationships in real time, while external memory serves as a flexible library. It is the digital equivalent of our paper notes or a file folder pulled from a shelf: AI doesn’t need to store that information deep within its systems to use it; it simply needs to access it when needed, vastly expanding its cognitive capabilities without altering its original structure.