Performance: Memory-augmented retrieval
MEDIUM IMPACT
This concept affects the speed and responsiveness of retrieving relevant information by augmenting queries with stored memory, impacting interaction responsiveness and load times.
from langchain.chains import ConversationalRetrievalChain from langchain.memory import ConversationBufferMemory from langchain.vectorstores import FAISS llm = some_llm # assume LLM instance memory = ConversationBufferMemory() indexed_retriever = FAISS.load_local('index_path').as_retriever() qa = ConversationalRetrievalChain.from_llm(llm, retriever=indexed_retriever, memory=memory) # Uses indexed vector store for fast retrieval and memory to avoid redundant fetches
from langchain.chains import ConversationalRetrievalChain from langchain.memory import ConversationBufferMemory llm = some_llm # assume LLM instance memory = ConversationBufferMemory() qa = ConversationalRetrievalChain.from_llm(llm, retriever=some_retriever, memory=memory) # Each query triggers full retriever call without caching or indexing
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full retrieval on every query | N/A | N/A | N/A | [X] Bad |
| Indexed retrieval with memory caching | N/A | N/A | N/A | [OK] Good |