Memory in LangChain | Deep dive (python)
HTML-код
- Опубликовано: 5 сен 2024
- ConversationBufferMemory
ConversationBufferMemory is a memory utility in the Langchain package that allows for storing messages in a buffer and extracting them as a string or a list of messages. It is useful for storing conversation history in a chatbot or conversational AI system.
It simply keeps a buffer of all the interactions in a conversation. It does not have a limit on the number of interactions it can store
ConversationBufferWindowMemory
ConversationBufferWindowMemory is a type of memory in the LangChain package that keeps a list of the interactions of a conversation over time, but only uses the last K interactions. This can be useful for keeping a sliding window of the most recent interactions, so the buffer does not get too large. On the other hand, ConversationBufferMemory is a different type of memory that simply keeps a buffer of all the interactions in a conversation. It does not have a limit on the number of interactions it can store.
ConversationTokenBufferMemory
ConversationTokenBufferMemory is a buffer for storing conversation memory that keeps a buffer of recent interactions in memory, and uses token length rather than the number of interactions to determine when to flush interactions. It is a class in the langchain.memory.token_buffer module and is used in conversational AI applications to store and retrieve conversation history.
ConversationSummaryMemory
ConversationSummaryMemory is a type of memory utility in the LangChain package that creates a summary of the conversation over time. It condenses information from the conversation over time and can be useful for keeping track of the conversation history. It differs from other memory utilities in LangChain in that it specifically focuses on creating a summary of the conversation, whereas other memory utilities may focus on different aspects of the conversation, such as keeping a buffer of recent interactions or using token length to determine when to flush interactions.
ConversationSummaryBufferMemory
ConversationSummaryBufferMemory is a type of memory utility in the LangChain package that keeps a buffer of recent interactions in memory and compiles them into a summary, using token length rather than the number of interactions to determine when to flush interactions. It differs from other memory utilities in that it combines the functionality of keeping a buffer of recent interactions with the ability to summarize the conversation over time. Other memory utilities in the package include ConversationSummaryMemory, which creates a summary of the conversation over time, and ConversationBufferMemory, which keeps a buffer of recent interactions in memory.
Entity Memory
Entity Memory is a memory module in LangChain that remembers information about specific entities. It uses LLMs to extract information on entities and builds up its knowledge about that entity over time. It is designed to be used in chains and provides easy ways to incorporate its utilities into chains. Compared to other memory utilities in LangChain, Entity Memory is focused on remembering information about specific entities, while other memory utilities are more general and can be used to manage and manipulate previous chat messages. Additionally, Entity Memory is designed to be used in chains, while other memory utilities can be used in a variety of contexts.
VectorStore-Backed Memory
VectorStore-Backed Memory is a memory component in LangChain that stores memories in a VectorDB and queries the top-K most “salient” docs every time it is called. It differs from most of the other Memory classes in that it doesn’t explicitly track the order of interactions. In this case, the “docs” are previous conversation snippets. This can be useful to refer to relevant pieces of information that the AI was told earlier in the conversation.
This was an awesome way of explaining it. Basically learned as much as 4 other videos by leaving out the code samples. Love it. Subbed.
That was a great lecture, thank you. I like it that you focus more on how it works instead of just going through a notebook with code. This channel is seriously underrated. Please keep up the good work and you'll gain more subscribers in no time. You earned my sub!
you made my day :) thank you!
@@EdenMarco My pleasure. Just stating the facts though. :) Looking forward to your next videos!
Hi Eden. I'm really happy I took your Udemy class on Langchain. Well worth the money. Lots of great information. Thanks for making it.
the best tutorial so fat about langchain , well done , make everything about memory very clear , i love u !
very nice explanation of all supported memories. Thank you and keep up the good work!
This is great! Answers some questions that have come up recently from me. Thank you.
Very neatly put together brother
Hey Eden, I know its late to ask but have you ever used the ReadOnlyMemory and how is it different compared to standard memory like ConversationBufferMemory for their agents/tools?
Cuz I'm reading that ReadOnlyMemory is better for agents/tools and standard memory is better for non-agents but I'm confused as in why. Does that mean my agent can delete or change the chat history if I dont use ReadOnlyMemory?
At 13:49 when you're referencing the SUMMARY_PROMPT, you read _DEFAULT_ENTITY_EXTRACTION_TEMPLATE but it's actually using _DEFAULT_SUMMARIZER_TEMPLATE
Can someone pls tell me what course is being talked about here .... i really loved how you explained instead of just showing ... i want to buy that course
Here is a discount coupon :) www.udemy.com/course/langchain/?referralCode=D981B8213164A3EA91AC
i noticed lm studio has a memory that only cuts out the middle, keeps the first few and last message history.
how i can pre load a memory? im deploying this on a backend but the buffermemory is the same for 2 session user for example
is there a way to carry the system message forward as the conversation goes on?