Back to Mem0

Llama2

embedchain/notebooks/llama2.ipynb

2.0.11.2 KB
Original Source

Cookbook for using LLAMA2 with Embedchain

Step-1: Install embedchain package

python
!pip install embedchain[llama2]

You can find OPENAI_API_KEY on your OpenAI dashboard and REPLICATE_API_TOKEN key on your Replicate dashboard.

python
import os
from embedchain import App

os.environ["OPENAI_API_KEY"] = "sk-xxx"
os.environ["REPLICATE_API_TOKEN"] = "xxx"

Step-3 Create embedchain app and define your config

python
app = App.from_config(config={
    "provider": "llama2",
    "config": {
        "model": "a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5",
        "temperature": 0.5,
        "max_tokens": 1000,
        "top_p": 0.5,
        "stream": False
    }
})

Step-4: Add data sources to your app

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