AI Personal Learning
and practical guidance

LangFriend: a diary with long-term memory function

Original: https://blog.langchain.dev/langfriend/?t=ZMdNze4qQKvNzUMHPhQRfg

 


LangChain is very much focused on the concept of memory, and it is customary for us to create sample apps to demonstrate the concepts we are focusing on. For Memory, we chose to create a journaling application (LangFriend)! We've made a tryable version available to anyone, and have already started developing a developer-facing API with some early adopters.If you're interested in this, sign up below to participate.

 

Main Links.

 

💡 We're also planning a meme-related hackathon on April 6, 2024 with New Computer, MongoDB and Anthropic. You can find out more about the hackathon at [here are] sign up to participate.

 

We have high hopes for this part of the LLM system, memory. Much of the power of generative AI comes from its ability to generate unique content at any time, which is very powerful for customizing the user experience. This can be accomplished not only by accessing existing information about the user, but also by remembering previous interactions with the user and learning from them.

 

It's this "memory" type of exploration that we're looking forward to. We think there will be more and more interactions between users and LLM - chatbots are becoming the main form of LLM applications. This means that more and more valuable user information will be exchanged in these conversations - such as a person's likes and dislikes, who their friends are, what their goals are, and so on. Learning and understanding these attributes, and then incorporating them into applications, can greatly improve the user experience.

 

In exploring memory, we thought that incorporating a concrete example of a use case would be a good way to motivate and guide our work. We chose to create a diary app. We named the app "LangFriend" and made it available to the public today. Although this is only a small research preview, we hope to gather feedback from the community on what works well and what needs to be improved before making it open source.

 

In this post, we'll talk about some of the academic research on memory, some of the other interesting things companies are doing in related fields, and why we chose to focus on developing a diary app. We'll then take a deep dive into this diary app and show off its features. If you are interested in exploring memory with us, feel free to get in touch.

 

 

academic research

In the course of our work in memory research, we have found two scholarly papers that have been very inspiring to our work.

First up is a piece from researchers at the University of California, Berkeley [MemGPT] The key idea of this paper is that they equip LLMs with the ability to perform several functions, such as memorizing specific facts, recalling relevant matters, and so on.

 

Large Language Models (LLMs) have revolutionized AI, but being constrained by a limited context window hampers the utility of AI for tasks like lengthy conversations and document analysis. To address this problem, we propose a technique called virtual context management, inspired by hierarchical memory systems in traditional operating systems that utilize scheduling between physical memories and disks to achieve the effect of infinitely scalable virtual memories. Utilizing this technique, we have developed MemGPT (Memory GPT), a memory layer management system that effectively provides extended contexts within the limited context window of LLM.

 

The other is from researchers at Stanford University [Generating Agents] The key idea of this paper is that they form memories by reflecting on past experiences and then store and programmatically retrieve the memories.

 

We demonstrate empirically that our agent architecture works through various parts of observation, planning, and reflection, each of which has a significant impact on the accuracy of the behavior of the generated agent. By fusing large-scale language models with computational interaction agents, we introduce in this work the generation of architectures and interaction patterns that accurately model human behavior.

 

An interesting difference between these two papers is the extent to which LLM actively uses memory versus the extent to which it does so more as a background process. memGPT forces LLM to use the memory function, whereas the generative agent is more of a background process.

 

 

firms

There are several companies that have distinguished themselves in the field of memory technology.

Plastic Labs is a company that specializes in the development of products such as [...TutorGPT] of innovative programs for startups.

 

LangChain LLM app. This is a dynamic meta-prompting feature for theoretical thinking tutoring.

 

[Good AI] is a startup that has recently open-sourced a chat assistant with long-term memory capabilities.

At first glance, Charlie may look similar to existing LLM agents such as ChatGPT, Claude and Gemini. However, its uniqueness lies in the fact that it introduces an LTM implementation that allows it toLearn from every interaction. This includesStore and integrate user messages, assistant responses and environmental feedback into LTMin order to make inquiries about relevant tasks when needed.

 

OpenAIThe memory function has also recently been integratedEnter ChatGPT.

 

From the perspective of these companies, there is a difference between two ways of realizing memory functionality: an active way in which the LLM must be consciously invoked (e.g., ChatGPT) and a passive way in which it is automatically fused into a background process (e.g., TutorGPT).

 

 

Why choose Diary App?

When considering a good scenario to implement and test long-term memory, a diary app immediately jumped into our thoughts. The main reason for this was that we thought the app would contain more relevant information for the interaction to be remembered than a regular chat app.

 

Compared to a regular chat app, the latter may have a lot of everyday pleasantries that don't need to be memorized - "Hey!" , "Hi", "How's it going", and so on. And in diary apps, you're more likely to reach the stage of sharing real, interesting emotions and insights.

 

Despite this - we wanted to add a chat component to this app. The main reason for this is that we wanted to show that our app is capable of learning and remembering user information. The app will use this information to generate a personalized response for the user.

You can see that this app remembers me as a lover of Italian food and how refreshed I feel after a workout.

 

LangFriend: a diary with long-term memory-1

 

After you add your first journal entry and talk to our companion, you will see a "Memories" button in the navigation bar. Click on it and you'll see all the key memories we've extracted from your journal.

 

LangFriend: a diary with long-term memory-2

 

You will find the list concise and not too informative. These are just some of the most important basic information we've extracted. Actually, behind the scenes, we've extracted a lot more information than that from your logs, and you can find them by searching for them!

In "Search memories... (Search memories...)" in the input box and you'll be able to see in real time the wide variety of information LangFriend has stored about you:

 

LangFriend: a diary with long-term memory-3

 

 

customizable

We want to make LangFriend attractive to all users. Therefore, we allow users to adjust the system messages that will serve as the start and tone of all chats with our chat partners. We provide a default setting that has been carefully designed to meet the needs of most users. However, if you expect something slightly different, or completely different, you can change any part to your liking.

 

You can find and update your system alerts by visiting the Logs page and clicking the Configure button. Here, a dialog box will pop up containing your system alerts.

 

LangFriend: a diary with long-term memory -4

 

Any changes you make will be maintained from session to session and become the start of all your future chat conversations!

 

 

reach a verdict

LangFriend is a glimpse into the future of research previewing the vast potential of incorporating long-term memory into LLM applications. By focusing on the development of note-taking apps designed to capture meaningful user information to provide personalized responses and enhance the user experience, LangFriend is an excellent demonstration of how we can actively leverage memory, or incorporate it into apps as a contextual process, to create interactive experiences that are engaging and adaptive to change. We warmly invite the community to participate in exploring LangFriend, provide feedback, and join us in advancing the possibilities of memory in LLM apps, tapping into the full potential of generative AI to deliver more powerful, personalized, and valuable experiences for users.

AI Easy Learning

The layman's guide to getting started with AI

Help you learn how to utilize AI tools at a low cost and from a zero base.AI, like office software, is an essential skill for everyone. Mastering AI will give you an edge in your job search and half the effort in your future work and studies.

View Details>
May not be reproduced without permission:Chief AI Sharing Circle " LangFriend: a diary with long-term memory function

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish