Files
mem0/notebooks/gpt4all.ipynb
T

4.9 KiB

Cookbook for using GPT4All with Embedchain

Step-1: Install embedchain package

In [ ]:
!pip install embedchain
In [ ]:
!pip install embedchain[dataloaders]

GPT4All is free for all and doesn't require any API Key to use it. Just import the dependencies.

In [ ]:
!pip install --upgrade embedchain[opensource]
In [ ]:
from embedchain import Pipeline as App

Step-3: Define your llm and embedding model config

In [ ]:
config = """
llm:
  provider: gpt4all
  config:
    model: 'orca-mini-3b.ggmlv3.q4_0.bin'
    temperature: 0.5
    max_tokens: 1000
    top_p: 1
    stream: false

embedder:
  provider: gpt4all
  config:
    model: 'all-MiniLM-L6-v2'
"""

# Write the multi-line string to a YAML file
with open('gpt4all.yaml', 'w') as file:
    file.write(config)

Step-4 Create embedchain app based on the config

In [ ]:
app = App.from_config(yaml_path="gpt4all.yaml")

Step-5: Add data sources to your app

In [ ]:
app.add("https://www.forbes.com/profile/elon-musk")
In [ ]:
while(True):
    question = input("Enter question: ")
    if question in ['q', 'exit', 'quit']:
        break
    answer = app.query(question)
    print(answer)