Defining Tom’s memory in application is crucial before proceeding to the steps of building his decision-making components. In fact, I wish I could stress my older self more on how important its role is in influencing the other builds.
To intuitively build Tom’s memory architecture, I eased the task by simplifying the human’s mind (ironically) and reframed the task as one of replication. Figure 1, adapted from Hung Thai Le (2021) simplifies the cognitive memory chambers of the human’s mind.

The main chambers, Short-term and Long-term memory can be defined as follows:
- Short term: responsible of processing and navigating sensory information (sensory memory / temporal lobe), and acts as the temporal storage for live information for language comprehension, learning and reasoning (working memory).
- Long term: responsible of everything else that is not in the short term memory or i.e. a filing cabinet that enjoys filing / updating itself with all memories including past trauma.
Extending this diagram into application for a bot entails building intuition based on the following table, figure 2.
| Definition as a data problem | Definition in Neural Networks | Replica Examples in Large Language Models (LLMs) | Related Architectures Examples | |
|---|---|---|---|---|
| Short term | Short-term memory can be understood as a temporary, capacity-limited data buffer subject to decay, interference, and selective transfer. | RNNs like LTSM or gated models temporarily storing previous data batch(es) to learn the next batch(es). | Persistent Session Cache for streaming chatbots | Streaming / In-Events Architectures |
| Long term | Long-term memory equips similar builds to short-term memory except that the data cycles are completed over extended periods. The data selections from short-term memory are more biased to the human individual’s emotional responses or environment influences. | Fed datasets to a neural networks during training. | Data Retrieval / Manipulations from Vector databases | The architecture and process under the process of storing / retrieving / querying Graph / Relational / Indexing Databases or Data Lakes & Warehouses |
Challenge: But which model is most efficient?
Intuitively, replicating the long-term memory leads me to setting up a simple indexing database system, but the short-term memory was personally more difficult due to the following reasons:
- Collecting real-time information from human’s sensory tools like vision and sound, where depending on the computer architecture you choose to interact on, requires running multiprocess in parallel. and Even if with that part backlogged for another day, problem
- Differences between session dataset. If you segment the day by hours, you can also segment by minutes and so forth. The question here is, which segmented data is more prioritized in the next inferencing window? Simply, the answer would be that the features would relate to the type of users the bot interact with for instance, it would not prioritize another’s opinion over mine when reranking its own preferences.
The following lists the possible builds that replicate the short-term memory:
- Database retrieval + Prompting mini agent: This requires setting up a database (of any type) and a light-weight agent acting as a gate keeper of this database (or receptionist). This agent sits between the database and the main agents / humans. This means that a human would not need any prior knowledge of SQL to query databases but instead treat the gatekeeper as their virtual Librarian.
- Session Cache Models (KV-Caches): This involves reranking the KV caches within LLMs during chat sessions to increase / steer its text generations. This only works for short chat sessions as prolonged use could lead the model in generating gibberish.
- System Prompt Extensions: Over the user sessions, the main chatting agent can be restored as a new model and its system prompt is periodically updated with past chats/highlights. This method is compute extensive in the sense that the contextual window continuously increases, and that no data is actually being retained here. Although, for parts in the future that requires short-term solutions, this method could be ideal.
- Methods related to weight learning:
- Multi-head attention networks as ranking model: This method relies on learning data with weights and given its dense architecture, it is better off as an offline learning model. Mentioning this method is probably motivated by my own interests for attentions over the task’s feasibility at hand. I strongly believe that if you can capture chat histories, text-generation caches ..etc., then such a model (built in alike manner) can act as both the database and the assisting model that provides the conditioning vectors to steer text generations of the main agent – one stone and two birds solution. I am still tinkering around different methods and while some may work with the current synthetic data, I am still unsure on how it would perform on large datasets. The ambiguity is based on the generic data problem where the noise imputed in the mock dataset doesn’t completely resonate with real-life situations.
Over the past year, it was difficult to build this part due to the constant updates in machine learning / AI. It often seemed that many papers and articles echoed each other, merely rebranding the same methods or that readings could lead one to believe that there’s no alternate solution – but there always is. For instance, using vector database storages to store the vector representation of sequence of texts. Simply, this is a solution like SQL databases but with extra steps which given the compute cost of running large models, you would want to preserve as much as possible during the data processing / cycles.
For the sake of simplicity, I decided to build the database (build translates to pulling dockers image so ain’t I existing in the most fortunate timeline?) independently for both short and long term storages at this stage. This should leave me more time in reading and tinkering around with different methods. Currently, my works in going forward to stages of streaming live data from sensory tools are hindered by the challenge in defining the function / algorithm that sits in between large models and the database. Despite noting that I bear no patience for looking at algebra as a beginner, I still did what felt right (but in code). One thing I deeply hate is completing a part of the agent and staring at the screen, knowing that I cannot extend it any further as it (all) relies on this part.
My Foot
- H. T. Le, “A simple model of the human memory,” arXiv preprint arXiv:2107.01390v1, 2021. Available: arxiv.org/abs/2107.01390v1
Tom’s progression · Post 13 of 14
This post sits in AI › Memory: Episodic, Semantic.
← Decoding Parameters to persist Language model’s emotions Tom’s Social Circle: Retaining Data from External Sources →
