Memories for Your AI Agent
A New Frontier in Personalized Assistance
Artificial Intelligence is increasingly becoming an integral part of our daily lives, but one crucial aspect is often missing from our interaction with these systems: memory. Imagine interacting with an AI that doesn’t just answer your questions, but also remembers important details about you, adapting over time to become more helpful, intuitive, and tailored to your needs. This is where the concept of "memories for AI Agents" comes into play.
The idea of memory in an AI context involves the capability of retaining information from past interactions, which allows the agent to build a more personalized relationship with the user. Unlike traditional AI models, which treat every interaction independently, an AI agent with memory can remember your preferences, context, and unique circumstances. This capability can improve user experience dramatically, as the AI can recall your past conversations, favorite topics, or even specific instructions you've given. For example, an AI that remembers your favorite restaurants or your go-to workout schedule can provide more personalized suggestions without requiring you to input the same information over and over again.
Creating memories for AI Agents is more than just storing data – it involves striking a careful balance between usefulness, privacy, and trust. The challenge lies in developing a system where users feel secure sharing information, knowing that it’s used only to enhance their experience. Transparency about how data is stored and used, alongside the ability for users to edit or delete memories, is crucial to building this trust. This opens up exciting possibilities, not just in customer service or virtual assistance, but in areas like healthcare, education, and mental health, where AI that truly "knows" you can make a real difference.
The future of AI might not just be about intelligence but also about the depth of connection it can foster. Memories for AI Agents represent a step toward a more nuanced, human-like interaction?– one where the agent not only processes information but also understands, learns, and grows alongside you.
Current State and Technology
OpenAI 's ChatGPT and 谷歌 's Gemini are two prominent AI systems that have integrated memory capabilities to enhance user experience. Both systems allow users to ask the AI to remember specific details resulting in a more personalized interaction over time.
Both systems can remember user preferences for meeting notes, such as including headlines, bullet points, and action items. They can also recall specific details about your business, like owning a neighborhood coffee shop, to provide more relevant messaging suggestions. And they can remember personal details such as your favorite foods, which helps tailor recommendations, like suggesting restaurants more precisely.
In both systems, memories are stored as a list of statements that become part of the conversation context. It's like adding relevant information to your chat manually, but here it's done automatically. When the AI thinks something is worth remembering, it uses an internal tool to summarize and store the memory. This memory is then saved in a list and used in future conversations.
These stored memories allow the AI to better understand user needs and provide more relevant responses, similar to how knowledge is built and utilized in human interactions. By leveraging these memories, the AI can add depth and personalization to its suggestions, enhancing its role as a helpful assistant in various aspects of users' lives.
If you'd like to explore an example of memory following the steps outlined below, just contact me, and I can provide the example project as a package.
Rebuilding and Using Memory for Enterprise
In Cognigy.AI, memories are stored as part of the user's contact profile, giving you full control and the ability to provide users with the tools they need to manage their information. While this article does not cover legal aspects such as the General Data Protection Regulation (GDPR) or the AI Act, it is important to consider the relevant requirements for such compliance.
In Cognigy , you can access the current user profile through the interaction panel and manage all user profiles in the Contact Profiles view. In the contact profiles view you can also edit or delete profile details. Additionally, there is an API available for managing all of these actions.
To incorporate the user's memories into the current conversation, you can either access the user profile directly or inject the required aspects through the AI Agent node in the Memory Handling section as Long-Term Memory. You can also adjust memory usage settings both in the AI Agent and in the AI Agent node.
Long-Term Memory and Short-Term Memory: If you're curious about the difference between Long-Term and Short-Term Memory: They both integrate data into the context of your conversation in a technically similar way. The main difference is that Long-Term Memory leverages the user's contact profile information, making it available across multiple conversations and bots (long-term), while Short-Term Memory focuses on a single conversation, for example to track a selection (i.e. selected plan) or the current topic (i.e. claiming an incident).
Although using memory is easy, one question remains: How do you add, update, and delete memories?
Add Memory
The simplest way to add memories is by using the Add Memory Node, which allows you to store any text in the user's memory. Once stored, it is immediately available via the Long-Term Memory of your agent.
To automate memory creation, you can use an AI Agent Tool Action. An add_memory action can be described as follows:
领英推荐
This tool stores user-provided information such as facts, preferences (e.g., "I want", "I like"), events, hobbies, or specific requests (e.g., "vegan"). It captures key details shared by the user. For instance, if the user says, "I love science fiction," it stores: "User enjoys science fiction as a genre."
Additionally, a memory parameter is required, such as:
User-related fact or memory in one sentence.
The value for the ?memory parameter is generated by the Large Language Model as outlined. This parameter can then be utilized in the Add Memory Node to update the memory with a new value:
{{input.aiAgent.toolArgs.memory}}
This short CognigyScript retrieves the memory generated by the generative language model to be added to the user contact profile.
Tools, Parameters, and Prompt Engineering: The "magic" of this process lies in leveraging the Large Language Model (LLM) and the applied prompt engineering. The model works by interpreting user input and attempting to match it to a tool action based on its description, filling in the defined parameters as specified. Sometimes the model can accomplish this on its own, if not, a hint like "Remember this." can do the trick. However, if this does not work as expected, you can refine the descriptions or provide additional instructions to the AI agent node according to your use case to improve the results. The details may vary depending on the model used and the total set of descriptions and instructions and their possible interactions.
Update Memory
An update_memory action works very similar to the add_message action, its description is:
This tool updates a user's memory, a fact about the user, or details shared by the user.
In addition to the memory parameter (used for updating memory), a timestamp parameter is required to identify the specific old memory to be updated. Since memories are stored with their associated creation date (timestamp), the LLM can retrieve this detail from the context and automatically populate it in the corresponding parameter.
The update itself is now just a small script:
// The profile memories have to be changed on the Array level (here using lodash)
const memories = _.clone(profile.memories);
const memory = _.find(memories, function(item) {return item.timestamp === input.aiAgent.toolArgs.timestamp});
memory.text = input.aiAgent.toolArgs.memory;
profile.memories = memories;
Delete Memory
A delete_memory action is even easier. The description only changes from update to delete:
This tool deletes or forgets a user's memory, a fact about the user, or details shared by the user.
And the timestamp is the only needed parameter to identify the memory to be deleted through the following code in a code node:
// The profile memories have to be changed on the Array level (here using lodash)
const memories = _.clone(profile.memories);
profile.memories = _.filter(memories, function(item) {return item.timestamp !== input.aiAgent.toolArgs.timestamp});
Conclusion
While using Long-Term Memory and Contact Profile information with an Cognigy AI Agent requires just a simple setting, creating, updating, and deleting memories involves some additional effort. This is not intended to make it less accessible but to provide maximum control based on your use case and legal requirements.
So, what will you build to make your AI Agents more memorable?
Customization Engineer at 8x8
1 个月Clear and Concise - thanks Sascha
It is much simpler than I thought. Thanks for sharing.
VP of AI Transformation at Cognigy
3 个月Thanks for sharing! Great article.
Activate Innovation Ecosystems | Tech Ambassador | Founder of Alchemy Crew Ventures + Scouting for Growth Podcast | Chair, Board Member, Advisor | Honorary Senior Visiting Fellow-Bayes Business School (formerly CASS)
3 个月Implementing memory capabilities in AI systems represents a significant advancement towards more personalized and efficient business interactions. #AIInnovation