ConnectionResetError when using GTP4AllEmbedding

72 Views Asked by At

I have this code to run a langchain sample code.

def load_db(files, chain_type, k):
    # load documents
    loaders = [PyPDFLoader(file) for file in files]
    documents = []
    for loader in loaders:
        documents.extend(loader.load())
    
    # split documents
    text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=150)
    docs = text_splitter.split_documents(documents)

    # define embedding
    embeddings = GPT4AllEmbeddings()

    # create vector database from data
    db = DocArrayInMemorySearch.from_documents(docs, embeddings)

    # define retriever
    retriever = db.as_retriever(search_type="mmr", search_kwargs={"k": k})

    llm = GPT4All(model="C:/Users/shang/Downloads/mistral-7b-openorca.Q4_0.gguf",
                  callbacks=[StreamingStdOutCallbackHandler()],
                  verbose=True)

    # create a chatbot chain. Memory is managed externally.
    qa = ConversationalRetrievalChain.from_llm(
        llm=llm,
        chain_type=chain_type, 
        retriever=retriever, 
        return_source_documents=True,
        return_generated_question=True,
    )
    return qa 

It runs into error at the embedding step

embeddings = GPT4AllEmbeddings()

Error: requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Anything I missed here?

0

There are 0 best solutions below