Writing

Memory in LLM applications

LLMs are stateless by default. Memory is what turns them into coherent chatbots, personalized assistants and multi-turn applications, within context window and token-cost limits.

Table listing LangChain memory types: ConversationBufferMemory, ConversationBufferWindowMemory, ConversationSummaryMemory, ConversationSummaryBufferMemory, ConversationEntityMemory and VectorStoreRetrieverMemory.

By default, Large Language Models (LLMs) are stateless. This means each interaction is treated as a brand new request, with no memory of past conversations.

That’s where memory becomes absolutely essential in building robust LLM applications! It allows AI to retain context, providing a more coherent and natural user experience, especially in industrial settings.

  • Chatbots: Maintaining a seamless flow in conversations.
  • Personalized experiences: Remembering user preferences and past interactions.
  • Complex multi-turn applications: Tracking progress and information over several exchanges.

However, we need to be mindful of context window restrictions and token costs. Feeding the entire conversation history can quickly become expensive and hit prompt limits. This is why effective memory utilizations matter, and why frameworks like LangChain ship several common memory constructs to choose from.