llama_index icon indicating copy to clipboard operation
llama_index copied to clipboard

Implement vector memory

Open jerryjliu opened this issue 9 months ago • 1 comments

UPDATE

  • Re-jigged vector memory to only supply list of chat messages and not handle any thing having to do with composing messages
  • Added BaseComposableMemory and SimpleComposableMemory for better separation of concerns
    • With this class, now we can pass a VectorMemory and ChatMemoryBuffer to a SimpleComposableMemory which will do a simple composition on the messages that are retrieved by all of its memory sources
  • Modified vector_memory.ipynb and added new composable_memory.ipynb (added these to docs as well)
  • Added these classes to api reference (I think?)

OLDER

was way harder than i originally anticipated, summary of main changes:

general interface stuff:

  • added input argument to get function in memory
  • added put_messages to memory
  • replaced all memory.set(..) calls in the agent with memory.put_messages in terms of updating state
  • added BaseChatStoreMemory for all memory modules that depend on a chat store

implemented vector memory:

  • track each "node" in a vector index
  • each "node" is by default a group of messages, instead of a single message. this is because if we index individual messages, we'll retrieve just the user message or just the assistant message, but not both. you may end up retrieving a user message and an unrelated assistant message leading to hallucinations
  • we track the current "message batch" in the chat store, to accumulate user message, then assistant/tool msgs, etc.
  • we also track all message ids in a separate collection in the chat store. this is to allow us to perform deletes, which right now consists of deleting messages one by one.
  • NOTE: deletes from vector stores are hard, we do some hacks to make delete_ref_doc work

jerryjliu avatar May 08 '24 04:05 jerryjliu

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB