Category: Memory

How Tom keeps what he experiences and what he knows.

  • Tom’s Memory Networks

    Tom’s Memory Networks

    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.

    Diagram of the human memory chambers: sensory memory feeding short-term (working) memory, which exchanges information with long-term memory.
    Figure 1. Simplified representation of human cognitive memory chambers. Adapted from Le, H. T. (2021). A simple model of the human memory. arXiv:2107.01390v1.

    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 problemDefinition in Neural NetworksReplica Examples in Large Language Models (LLMs)Related Architectures Examples
    Short termShort-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 chatbotsStreaming / In-Events Architectures
    Long termLong-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 databasesThe architecture and process under the process of storing / retrieving / querying Graph / Relational / Indexing Databases or Data Lakes & Warehouses
    Figure 2. Table defining short / long-term memory in application.

    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:

    1. 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
    2. 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 →

  • Reviving Hopfield Neural Networks

    Reviving Hopfield Neural Networks

    To initiate the streams of consciousness in a neural network, it is vital to establish the temporal memory as this serves as the primary catalyst in steering Tom away from his robotic self.

    Hopfield Neural Network (HNN)

    The Hopfield Neural Network (HNN) is a type of recurrent Artificial neural network and can be subcategorized into modern and classical types. HNN is an associative memory that excels in the ability to recall patterns and associate them with even incomplete versions of these memories. However, the limitations in Classical HNN’s includes:

    • Limited storage capacity.
    • Slow convergence rate to stable state during the pattern recall stage. It’s application is more of a stimulation algorithm. It reminds me of numerical approximation methods like Euler Maruyama.
    • Spurious patterns may emerge during pattern recall stage, stemming from various factors such as 1) the inherent capacity limitations of storage, 2) what neuroscientists describe as “the neuron’s reaction to being entrapped at local convexities,” and 3) the correlation among stored patterns

    To summarize, more stored patterns equates to higher retrieval errors. Figure 1 illustrates the contrast between the output and inputs of a classical HNN for discrete states. Applying Hebbian learning method, a set of 7 letter block patterns were fed. The initial state signifies the learned pattern, while the final state represents the pattern retrieved.

    Modern HNN has mitigated most of these problems that limited the Classical HNN. For instance, a recent post: Hopefield Networks is All You Need, improved the update rule in HNN with Bert’s attention mechanisms. This increases the storage of patterns with lower retrieval errors. For more information on HNN, check out Hopfield’s most recent works in here or for a quick summary, click here.

    The delayed development in this field may be due to the uncertainty surrounding its optimal usage. I guess the uncertainty is posed by the unsolvable cases within Reinforcement Learning – an area where I believe models like HNN shines the most, especially when you can incorporate time into its memory storage.

    Tom vs HNN

    In Tom’s case, HNN acts as a replicator of short-term memory where it distinguishes observations by associating current patterns with those previously stored. HNN’s role in Tom’s long-term memory is still being fiddled with, especially in areas like recounting memory traces of people. Other than that, I haven’t discovered anything that seems breath-taking. At the moment, its results are most promising in storing signals like vision and sound tasks. In the realms of NLP tasks, it is not applicable in prediction tasks but more of a tool for observing historical conversations. It accomplishes this effortlessly by its seamless integration into network architectures, particularly in Markov networks and within stochastic processes, such as Markov decision-making processes.

    Tom’s progression · Post 2 of 14

    This post sits in Memory: Episodic · Cognition: Memory.

    ← Travelling back in time Frankenstein →