AI / LangGraph LangChain Interview questions II
What are the different memory types in LangChain?
LangChain provides several memory classes that differ in how they store and compress conversation history. Choosing the right one involves balancing context quality, token cost, and retrieval precision.
| Memory Type | How It Works | Best For |
|---|---|---|
| ConversationBufferMemory | Stores every message verbatim | Short conversations where full context matters |
| ConversationBufferWindowMemory | Keeps only the last k messages | Long conversations; avoids context overflow |
| ConversationSummaryMemory | Uses an LLM to summarise older messages | Very long sessions; quality over token savings |
| ConversationSummaryBufferMemory | Summarises messages beyond a token limit; keeps recent messages verbatim | Balance between detail and cost |
| VectorStoreRetrieverMemory | Stores messages as embeddings; retrieves semantically relevant past context | Long-running assistants that need to recall specific facts |
| ConversationEntityMemory | Extracts and tracks named entities (people, places, concepts) from conversation | Personal assistants that must remember facts about people/topics |
In LCEL-based applications, the memory pattern has shifted from these classes towards explicitly managing a messages list in chain state (with RunnableWithMessageHistory for automatic persistence per session ID), or using LangGraph's checkpointing for full state persistence.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
