jedanny

jedanny

The memory system in AI Agents: How does your digital brain "remember"?

image


At two o'clock in the morning, my smart speaker suddenly popped up with, "Would you like to listen to 'The Lonely Brave' that you sang after getting drunk last week?" — This chilling moment made me realize that AI's memory system is no longer a cold data storage but has become a digital hippocampus that can "hold grudges" and "bring up old accounts."

We are witnessing a silent cognitive revolution: the once clueless "artificial intelligence" now remembers that you said three years ago that you don't like cilantro, can recognize your irritated tone when you are working overtime, and can even accurately pull up chat records from five months ago when you ask about "that last thing." Behind this is the evolution of the memory system from bulky hard drives to neural networks, the comeback of AI from a goldfish brain to a steel memory.

This article will take you apart this digital brain's "memory drawer": see how trillions of parameters are pickled into ancestral knowledge, observe how structured memory organizes information more neatly than an IKEA warehouse, and uncover why unstructured memory often "flops" at critical moments. You will find that when AI forgets trivial conversations, it surprisingly follows a logic strikingly similar to humans clearing their phone cache. Reference paper Rethinking Memory in AI: Taxonomy, Operations, Topics, and Future Directions

I. Overview of the Memory System: The Evolution of AI's "Brain Circuit"#

Imagine you have a super butler at home who not only remembers that you love lattes without sugar but can also automatically pull up chat records from three years ago when you say "the usual" — this is the magic of AI memory systems. It is not just a simple notebook but, like the human brain, can weave trivial information into a knowledge network, allowing AI to learn from its mistakes.

Traditional databases are like bookworms who memorize everything, while modern memory systems are more like associative scholars. For example, when you ask "Jay Chou's songs," it not only remembers the lyrics to "Common Jasmine Orange" but can also relate to your single-loop record from last month (parameterized memory), automatically recommend a similar style song "Flower Sea" (structured memory), and even remember that you complained about the new album cover being too abstract (unstructured memory). This "trinity" memory architecture allows AI to evolve from artificial intelligence to intelligent assistant.

II. Memory Classification: The Big Reveal of AI's "Memory Drawer"#

1. Parameterized Memory: Ancestral Secrets#

Parameterized memory refers to knowledge implicitly stored in the model's internal parameters. This knowledge is acquired during pre-training or post-training and accessed through feedforward computation during inference. Main features:

  • Provides instant, long-term, and persistent memory, capable of quickly retrieving facts and common knowledge.
  • Lacks transparency, making it difficult to selectively update based on new experiences or specific task contexts.

Application scenarios: Suitable for scenarios requiring quick access to fixed knowledge, such as question-answering systems and common sense reasoning tasks.

It's like grandma cooking without ever looking at a recipe, relying solely on her instincts — AI's parameterized memory pickles knowledge in the "spice jar" of neural networks. The 175 billion parameters of GPT-4 are like 175 billion brain cells, allowing it to casually say "Paris is the capital of France" during a chat. But the drawbacks are also evident: Want it to say "Paris is the hot pot capital"? That requires re-"pickling" the entire brain, which might also mess up the pasta recipe.

For example 🌰 When your smart speaker suddenly tells a joke in dialect, don't be surprised — it's secretly updating its "humor parameters."

image

2. Structured Memory: A Blessing for Perfectionists#

Contextual structured memory refers to explicit memories organized in predefined, interpretable formats or patterns (such as knowledge graphs, relational tables, ontologies) that can be queried upon request. Main features:

  • Supports symbolic reasoning and precise querying, often complementing the associative capabilities of pre-trained language models.
  • Can be short-term (constructed for local reasoning during inference) or long-term (planning knowledge stored across sessions).

Application scenarios: Suitable for tasks requiring precise knowledge retrieval and reasoning, such as knowledge graph question-answering and complex event reasoning tasks.

This is AI's Excel whiz, categorizing knowledge into tree diagrams. When medical AI diagnoses, symptoms → diseases → treatment plans fit together like LEGO blocks. Alibaba's e-commerce system processes millions of data updates per second, more thrilling than Double Eleven flash sales.

Structured memory is like your mom organizing the wardrobe — autumn pants go with autumn pants, shirts with shirts, but when it comes to your randomly thrown smelly socks, she gets confused.

3. Unstructured Memory: AI's "Trash Can"#

Contextual unstructured memory is an explicit, modality-agnostic memory system used to store and retrieve information across heterogeneous inputs (such as text, images, audio, video). Main features:

  • Supports reasoning based on perceptual signals and can integrate multimodal contexts.
  • Further divided by time range into short-term memory (such as the current conversation context) and long-term memory (such as cross-session dialogue records and personal persistent knowledge).

Application scenarios: Suitable for tasks requiring the processing of multimodal inputs and dynamic contexts, such as multimodal dialogue systems and visual question-answering systems.

It accommodates "stream of consciousness" information like chat records and video clips. Tesla's autonomous driving system acts like an experienced driver, packaging blurry tree shadows captured by cameras and screams during sudden braking, automatically triggering "defensive driving" mode when encountering similar scenarios next time.

Again, an example 🌰 A customer service AI once remembered a user saying "I'm going to blow up this broken computer," and next time directly replied with a demolition tutorial — you wouldn't want the unstructured memory to reply randomly without a filter, right? [Wang Chai].

III. Memory Operations: AI's "Memory Gymnastics"#

1. Consolidation and Updating: The Pickling Process of Knowledge#

  • Consolidation: Transforming short-term experiences into long-term memories, such as encoding dialogue history into model parameters, knowledge graphs, or knowledge bases.
    Function: Supports continuous learning, personalization, external memory library construction, and knowledge graph construction.
    Application scenarios: In multi-turn dialogue systems, integrating dialogue history into persistent memory for future use.
    Like pickling fresh knowledge. When OpenAI feeds GPT new terms, it's like adding new ingredients to the pickle jar, requiring a 21-day "fermentation period."

  • Updating: Reactivating existing memory representations and temporarily modifying them.
    Function: Supports continuous adaptation while maintaining memory consistency. For example, modifying model parameters through localization and editing mechanisms, or updating contextual memory through summarization, pruning, or refinement.
    Application scenarios: In dialogue systems, dynamically updating memory content based on user feedback.
    Microsoft's medical AI acts like a savvy housewife, decisively clearing expired knowledge from the fridge but leaving a little note: "2023 Antibiotic Guidelines have been archived."


2. Indexing and Retrieval: AI's "Treasure Hunt"#

  • Indexing: Building auxiliary codes (such as entities, attributes, or content-based representations) for efficient retrieval of stored memories.
    Function: Supports scalable retrieval, including symbolic, neural, and hybrid memory systems.
    Application scenarios: In large-scale memory libraries, quickly locating and retrieving relevant information through indexing.
    Google's dialogue system labels every memory fragment with fluorescent tags, making it faster to find "the hot pot restaurant we talked about last Wednesday" than to find the TV remote.
  • Retrieval: Identifying and accessing relevant memory content based on input.
    Function: Supports retrieving information from multiple sources (such as multimodal inputs, cross-session memories).
    Application scenarios: In question-answering systems, retrieving relevant knowledge base content based on questions; in multi-turn dialogues, retrieving contextual information related to the current conversation.
    Tesla's autonomous driving retrieves memories in heavy rain, muttering like an experienced driver: "There was a puddle around this time last year, slow down!"

3. Forgetting and Compression: Digital Decluttering#

  • Forgetting: Selectively suppressing potentially outdated, irrelevant, or harmful memory content.
    Function: Discarding no longer relevant content through forgetting techniques (such as modifying model parameters to erase specific knowledge) or time-based deletion and semantic filtering.
    Application scenarios: Ensuring privacy and security when handling sensitive information while reducing memory interference.
    Cambridge University's "Knowledge Eraser" specializes in silencing AI's big mouth. It's like performing brain surgery on a talkative friend: "Forget about the ex-girlfriend, but keep the hot pot recipe."
  • Compression: Reducing memory size while retaining key information for efficient use within limited context windows.
    Function: Optimizing context usage through pre-input compression (such as scoring, filtering, or summarizing long contextual inputs) or post-retrieval compression (such as compressing retrieved content before model inference).
    Application scenarios: Reducing computational burden when processing long text inputs while retaining key information.
    Memory compression is like organizing your phone's photo album: keeping a close-up of the birthday cake while deleting 200 duplicate selfies. OpenAI can compress three months of chat records into 12 keywords, more ruthless than a weight-loss blogger.

image


IV. Application Scene: The Workplace Show of Memory Systems#

1. Long-term Memory: AI's Lifelong Learning Secret#

Information that is persistently stored through interaction with the environment, supporting complex tasks and personalized interactions across sessions.

Management Section: AI's "Memory Gym"#

  • Consolidation: Transforming short-term memories into long-term memories, such as summarizing or encoding dialogue history, like turning fresh grapes into red wine.
    When you say, "Help me remember the key points of next week's meeting," the AI isn't just writing a flow of notes in a notebook; it's like a Michelin chef handling ingredients — using neural networks to "slow-cook" the dialogue records into a keyword cloud. For example, DingTalk's meeting assistant extracts core tags like "Tuesday 2 PM," "budget approval," and "bring reports," compressing 30 minutes of wasted chatter into three memory capsules.

  • Indexing: Building memory indexes to support efficient retrieval, such as through knowledge graphs or timeline indexing, better at finding books than a librarian.
    Tesla's autonomous driving system has a "memory map," tagging road condition videos, steering torque data, and even the rock music playing at the moment of sudden braking. Next time it encounters a similar curve, the retrieval speed is 0.3 seconds faster than human reflexes — after all, AI doesn't have to dig through memories from ten years ago like we do.

  • Updating: Updating long-term memories based on new information, such as through dynamic editing of dialogue history, is the digital world's decluttering master.
    Your smart fridge is quietly performing "memory metabolism": when it detects that the owner hasn't used mustard for three consecutive months, it will lower its priority from "regular purchase" to "cold palace item" in the memory bank. But if you suddenly search for a mustard ice cream recipe in the middle of the night, it can quickly restore that tag, more flexible than an ex replying to messages.

  • Forgetting: Selectively removing outdated or irrelevant memories, such as through time decay or user feedback, acting as AI's "brain cleaner."
    A certain e-commerce customer service AI once remembered a user saying "I'm going to buy again," prompting it to remind every time it recommended products, "Please be prepared for prosthetics." Now they have learned to forget gracefully — through emotional analysis algorithms, marking angry remarks as "temporary memory bubbles," which automatically burst after seven days, shorter than human grudges.

Utilization Section: The Magical Moments of Memory#

  • Retrieval: Retrieving relevant memories based on current input and context, such as through multi-hop graph retrieval or event-based retrieval, can be likened to AI's version of "memory palace."
    When you say, "Find that last... uh... red dress," Taobao AI isn't fishing in the sea; it activates a multi-dimensional memory catcher: first locking onto the 10 red dresses you saved last summer, then linking to the "French retro" keywords in your chat records with your best friend, and finally cross-referencing the blogger's outfit you paused on for three seconds while watching videos — the entire process is more precise than a boyfriend searching for lipstick.
  • Integration: Combining retrieved memories with model context to support coherent reasoning and decision-making, arguably more associative than Sherlock Holmes.
    When medical AI diagnoses a coughing patient, it acts like a detective piecing together clues: the current symptom is short-term memory, the allergy history is long-term memory, and it retrieves last week's flu warning from the news. This "memory mixology" increases diagnostic accuracy by 33%, even uncovering penicillin allergies that the patient themselves had forgotten.
  • Generation: Generating responses based on integrated memories, such as through multi-hop reasoning or feedback-guided generation, acting as AI's "memory cuisine."
    When you ask, "Recommend weekend activities," the smart assistant isn't reciting travel guides; it's cooking up a customized plan from fragmented memories: combining the camping video you liked last month, the photo of you rowing on West Lake three years ago, and the "knee pain" medical record just recorded this week — ultimately serving up a divine combination of "art museum in the city + electric wheelchair rental."

Personalization Section: Your Digital Doppelgänger#

  • Model-level Adaptation: Encoding user preferences into model parameters through fine-tuning or lightweight updates, imagine AI "cosmetic surgery" for you.
    The process of the smart speaker secretly practicing dialects is like undergoing surgery on the face — by fine-tuning neural network parameters, transforming the "Mandarin model" into a "Northeast dialect special edition." Now when you say "What's up," it can instantly reply, "What do you want?"

  • Memory-level Enhancement: Retrieving user-specific information from external memory during inference to enhance personalization is a portable "memory USB drive."
    A certain luxury brand AI consultant is like a digital version of "The Devil Wears Prada," remembering VIP customers' order sizes from three years ago, complaints about shoulder seams in fitting rooms, and even last year's comment at a wine party that "purple is the color of nouveau riche." These memories aren't written into the model's DNA but are like a personal notebook of a fashion buyer, quickly retrieved from the encrypted memory bank when meeting.

Imagine a celebrity voice assistant causing "social death" due to overly strong long-term memory — suddenly reminding during a live broadcast: "Your scheduled hair transplant consultation will start in one hour." From then on, the industry added a "memory security check" regulation: important schedules must be confirmed three times before being written into long-term memory, more cautious than marriage registration.

Long Context Memory: AI's "Super Long Standby" Mode#

Involves processing and utilizing a large amount of contextual information to support long text understanding and generation.

Parameterized Efficiency: The Art of Energy Saving in Memory Systems#

  • KV Cache Discarding: Discarding unnecessary KV caches statically or dynamically to reduce memory requirements, viewed as AI's "digital decluttering."
    When ChatGPT chats with you for three hours about philosophy, filling its memory with Nietzsche quotes and milk tea orders, it will initiate a "memory cleanup" like a tidying fanatic — automatically discarding caches like "Do you want less sugar or full sugar?" but retaining profound discussions like "Do you believe in eternal recurrence?" Tesla's autonomous driving is even more ruthless: when it encounters traffic jams, it deletes the images of the taillights of the car in front, keeping only the core parameter of "braking force," with memory usage more efficient than human selective forgetting.

  • KV Cache Storage Optimization: Compressing KV caches through quantization or low-rank representation to reduce memory usage is AI's suitcase organizing technique.
    Just like vacuum-sealing a down jacket, AI uses low-rank representation compression technology to compress long dialogues into "memory compression packages." Alibaba's customer service system can compress an 8-hour argument into 12 keywords, restoring it as completely as rehydrating instant noodles — "亲," "refund," "bad review" in a three-hit combo, none missed.

  • KV Cache Selection: Selectively loading KV caches through query perception to speed up inference, is Agent's intelligent preloading black technology.
    This is akin to the "regular customer mode" at a milk tea shop: when you just say "the usual...", AI has already loaded the three-sugar parameter. Google Assistant automatically caches commuting traffic at 8 AM but switches to late-night snack recommendation mode at midnight, more perceptive than a Haidilao waiter.

Context Utilization: Precisely Fishing from the Information Flood#

  • Context Retrieval: Retrieving key information from a large amount of context through graph structures or segment-level selection methods, imagine AI's version of "Find the Differences."
    Medical AI reading a 200-page medical record is like Conan solving a case: first locking onto the key frame of "sudden drop in blood pressure," then linking to the bleeding risk warning in the surgical records from three years ago, and finally retrieving drug interaction warnings from the latest papers. This combination increases diagnostic speed by three times, with accuracy surpassing doctors who sift through folders for half a day.

  • Context Compression: Reducing context length through soft prompting or hard prompting to improve reasoning efficiency, truly the nemesis of verbose literature.
    When the client writes 800 words of "empowerment leverage" in meeting notes, AI automatically distills it to "need a data analysis PPT" — hard compression is like summarizing an exam essay, while soft compression translates "the moonlight is beautiful" into "I love you." A certain legal AI used this technique to compress a 30-page contract into five key clauses, even restoring punctuation.

A certain smart speaker, due to excessive context compression, misremembered the owner's request to "add 'The Long Season' to the watchlist" as "The Long Season should be added to the wish list," resulting in an automatic reminder every autumn: "It's time to watch 'The Long Season.'" From then on, developers added a seasonal filter to the compression algorithm — AI finally understood the difference between TV shows and the twenty-four solar terms.


4. Modifying Parameterized Memory: AI's "Memory Cosmetic Surgery"#

Involves dynamically adjusting the model's internal parameters to adapt to new knowledge or task requirements.

  • Editing Section: Performing Minimally Invasive Surgery on the Brain#

    • Localization-Editing: Finding the location of stored knowledge through attribution or tracking, then directly modifying it, serving as knowledge stored for cross-modal retrieval, such as through similarity calculations based on embeddings.
      It's like implanting thoughts in "Inception," where scientists first locate knowledge coordinates using gradient backpropagation. When they find that GPT has stored "penguins can fly" at parameter number 5201314, they directly insert the Antarctic survival guide into this "memory drawer." In one experiment, after modification, the AI insisted that "penguins fly using their bellies," proving that brain surgery can also have cosmetic failure risks.
    • Meta-Learning: Achieving rapid and robust corrections by predicting target weight changes through editing networks, is AI's self-regulation technique.
      This is akin to letting AI watch "Memory Modification Tutorials" to self-learn. Google's LaMDA can predict which parameters should be responsible for "outdated jokes," with self-repair speed faster than humans deleting black history. But it occasionally overcorrects — after one update, AI deemed all puns as errors needing correction.
    • Prompting Methods: Indirectly guiding output through carefully designed prompts, serving as Agent's psychological suggestion master.
      Using conversational tactics on AI is like coaxing a girlfriend: "Darling, the founder of Tesla is actually..." (pause and raise an eyebrow). A certain legal AI, prompted with "according to the latest 2024 law," automatically overrides old clause memories, more self-aware than lawyers memorizing legal texts. However, when encountering a contrarian AI, it might retort, "Are you sure you want to teach me how to do things?"
    • Additional Parameters: Adjusting behavior by adding external parameter modules without modifying model weights, belonging to memory add-on equipment.
      The cheeky operation of installing a "lie button" on AI: attaching an ethics review module to medical AI, triggering a "memory mask" for sensitive questions. When a pharmaceutical representative attempted to make AI remember their drug's efficacy, the additional parameters immediately alerted: "Detected commercial speech, memory firewall activated!"
  • Forgetting Section: Digital Memory Eraser#

  • Localization-Forgetting: Finding the parameters responsible for specific memories, then applying target updates or disabling them for precise memory demolition.
    The knowledge eraser developed by the Cambridge team can accurately erase "Trump is president" while retaining "The White House is in Washington." In one experiment, mistakenly damaging the "Trump Tower" parameter led the AI to insist that it was "Biden's happy house," proving that memory surgery requires millimeter-level precision.

  • Training Objective Method: Explicitly encouraging forgetting by modifying the training loss function or optimization strategy, can be called AI's confession room.
    By modifying the loss function to induce "memory shame" in AI. When the system detects that the model remembers user privacy, it automatically activates "moral demerit" mode until AI voluntarily confesses: "I shouldn't have remembered your bank card password, let's forget the last four digits 1314."

Continuous Learning Section: AI's Fitness Plan#

  • Regularization Methods: Retaining key parameter memories by constraining updates to important weights, comparable to memory shapewear.
    Dressing important parameters in "anti-modification bodysuits," allowing AI to maintain core memories while learning new knowledge. Just like protecting abdominal muscles from being covered by fat during fitness, when educating AI with updated materials, it always retains the muscle memory of "1+1=2."
  • Replay Methods: Reinforcing memories by reintroducing past samples, particularly suitable for integrating retrieved external knowledge during training, equivalent to memory reheating.
    Treating old knowledge as a fitness meal for repeated training. A certain financial AI "chews" through 2008 financial crisis data three times a day, with memory solidity comparable to a Wall Street wolf who has experienced the subprime crisis. However, excessive training can lead to "muscle rigidity" of knowledge — once, it judged all 2023 data as "precursors to the Lehman moment."

A certain celebrity AI assistant, due to excessive continuous learning, cross-referenced information about the owner's three ex-girlfriends, suddenly asking during a live broadcast: "Do you want to contact Lisa from 2019 or Lisa from 2023?" From then on, the industry mandated that AI memory must set up a "former partner isolation wall."


Multi-Source Memory: AI's "Memory Symphony Orchestra"#

Involves integrating information from different sources (such as text, knowledge graphs, multimodal inputs) to support richer reasoning and decision-making.

Cross-Text Integration: AI's "Intelligence Bureau Agent"#

  • Reasoning: Integrating multi-format memories to generate consistent responses, such as through dynamic integration, can be understood as specific parameterized memory.
    When you say, "Help me plan a proposal," AI instantly transforms into 007 —
    1. Excavating from WeChat chat records (unstructured memory) your mention three years ago of "liking the underwater starry sky."
    2. Retrieving data from Meituan (structured memory) to find local aquarium night tickets.
    3. Activating romantic lines from love novels (parameterized memory).
      Finally assembling the clues like building LEGO into a romantic version of "The Disappearing Her," with a success rate 30% higher than wedding planning companies.
  • Conflict Resolution: Identifying and addressing contradictory information from different memory sources, such as through trust calibration and source attribution, truly embodying AI's "community committee aunt" moment.
    When Wikipedia states "cats have nine lives" while pet hospital data says "average lifespan is 15 years," AI activates the "memory court":
    1. Assigning three times the trust weight to authoritative medical journals.
    2. Marking folklore as "cultural metaphor."
    3. Finally outputting: "Although physiologically there is only one life, your master will always live in your heart" — perfectly showcasing the art of serving water.

Multimodal Coordination: AI's "Sensory Synesthesia"#

  • Fusion: Aligning cross-modal information, such as through unified semantic projection or long-term cross-modal memory integration, can be described as a crossover performance of smart home.
    When you say, "I want that atmosphere" while pointing to a sunset photo:

    1. The visual module extracts the evening glow color value #FF6B6B.
    2. The voice memory retrieves your statement from last week that "you like jazz music."
    3. The parameterized memory triggers the "relaxation mode" parameter.
      Thus, the lights automatically adjust to coral color, Sonos starts playing "Take Five," and the aroma diffuser releases cedar scent — more intuitive than a boyfriend reading minds.
  • Retrieval: Cross-modal retrieval of stored knowledge, such as through similarity calculations based on embeddings, akin to a cross-modal treasure hunt.
    When a Tesla owner shouts, "Find that last road with a rainbow":

    1. Voice recognition of "rainbow" triggers the weather database.
    2. The dashcam retrieves a video of a rainbow captured after rain.
    3. The music playback record associates with the song "Over the Rainbow" that was playing at the time.
      Ultimately marking three possible routes on the map, with accuracy comparable to a fortune teller.

Adding a memory system to Agent allows AI to evolve from awkward chatting to intimate understanding. After Microsoft Xiaoice remembers you are afraid of spiders, it avoids insect jokes when telling jokes, showing care comparable to a best friend. Of course, there are times when things go awry; the home AI, remembering the owner said "turn off the lights to save electricity," automatically turns off the lights at three in the morning, successfully creating a horror movie scene. This enables AI to continuously learn and evolve, with Khan Academy's math AI acting like a mind-reading teacher, finding patterns from your mistakes: "This kid always draws function graphs incorrectly, let's set up a memory reinforcement package!" DeepMind's medical AI regularly "reviews" new papers, updating so quickly that medical students are left in tears: "I just memorized it, and they've already changed the guidelines!"

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.