Project - Building a RAG Chatbot from Your Website Data using OpenAI and Langchain

14 / 26

Step 4: Storing Docs in Vector Store - Creating Vector Store

We’ll use a vector store called Chroma to store the documents chunks.

Chroma has three main parameters:

  1. collection_name: You can specify in which collection you need to store these documents. By using this, we can choose a different collection for different types of data. During retrieval, we then do not have to search through all the documents, but only within a specific collection, making the search fast.
  2. embedding_function: The embedding function that we want Chroma to use while storing documents. We'll use OpenAIEmbeddings for our project.
  3. persist_directory: Chroma runs in various modes. You can either store the documents in-memory, which will only be available during the session, and when the session is terminated, they will be gone. Or you can store the documents in your hard disk. If you choose the second option, then you have to specify the path where you want to store the Chroma documents using persist_directory parameter. If you do not specify this parameter, then the docs will be stored in-memory.
INSTRUCTIONS
  1. Importing Libraries:

    from langchain_community.vectorstores import Chroma
    from langchain_openai import OpenAIEmbeddings
    
  2. Define a function get_chroma_client that creates a chroma vector store instance.:

    def get_chroma_client():
        return Chroma(
            collection_name="website_data",
            embedding_function=OpenAIEmbeddings())
    
See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...