🤖 Self-hosted, community-driven, local OpenAI-compatible API with Keycloak Auth Flak app as frontend. 🏠
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
FlaskAI/examples/query_data
Ettore Di Giacinto 05a3d569b0
feat: allow to override model config (#323)
1 year ago
..
data example(add): document query example 1 year ago
models feat: add bert.cpp embeddings (#222) 1 year ago
.gitignore example(add): document query example 1 year ago
README.md feat: allow to override model config (#323) 1 year ago
docker-compose.yml docs: fix langchain-chroma example (#298) 1 year ago
query.py feat: add bert.cpp embeddings (#222) 1 year ago
store.py feat: add bert.cpp embeddings (#222) 1 year ago
update.py examples: fix default parameter 1 year ago

README.md

Data query example

This example makes use of Llama-Index to enable question answering on a set of documents.

It loosely follows the quickstart.

Summary of the steps:

  • prepare the dataset (and store it into data)
  • prepare a vector index database to run queries on
  • run queries

Requirements

You will need a training data set. Copy that over data.

Setup

Start the API:

# Clone LocalAI
git clone https://github.com/go-skynet/LocalAI

cd LocalAI/examples/query_data

wget https://huggingface.co/skeskinen/ggml/resolve/main/all-MiniLM-L6-v2/ggml-model-q4_0.bin -O models/bert
wget https://gpt4all.io/models/ggml-gpt4all-j.bin -O models/ggml-gpt4all-j

# start with docker-compose
docker-compose up -d --build

Create a storage

In this step we will create a local vector database from our document set, so later we can ask questions on it with the LLM.

Note: OPENAI_API_KEY is not required. However the library might fail if no API_KEY is passed by, so an arbitrary string can be used.

export OPENAI_API_BASE=http://localhost:8080/v1
export OPENAI_API_KEY=sk-

python store.py

After it finishes, a directory "storage" will be created with the vector index database.

Query

We can now query the dataset.

export OPENAI_API_BASE=http://localhost:8080/v1
export OPENAI_API_KEY=sk-

python query.py

Update

To update our vector database, run update.py

export OPENAI_API_BASE=http://localhost:8080/v1
export OPENAI_API_KEY=sk-

python update.py