3

I have created a retrieval QA Chain which uses chromadb as vector DB for storing embeddings of "abc.txt" file. What if I want to dynamically add more document embeddings of let's say another file "def.txt"? How to do that? I don't want to reload the abc.txt embeddings and then def.txt embeddings and then put it in chroma db instance. I just want to reuse the same chroma db instance(which already has embeddings of abc.txt) and add more document embeddings of def.txt and then do retrieval using the same.

loader = UnstructuredFileLoader('abc.txt', mode='elements')
documents= loader.load()

text_splitter = RecursiveCharacterTextSplitter(chunk_size=1500, chunk_overlap=150)
texts = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
vectordb = Chroma.from_documents(texts,embeddings)
chain = RetrievalQA.from_chain_type(llm=OpenAI(temperature=0.0),chain_type="stuff", retriever=vectordb.as_retriever(search_type="mmr"),return_source_documents=True)
Jason
  • 676
  • 1
  • 12
  • 34

0 Answers0