Enhancing RAG: LlamaIndex and Ollama for On-Premise Data Extraction
From Text to Vectors: Leveraging Weaviate for local RAG Implementation with LlamaIndex
- Install Weaviate local DB with Docker:
docker compose up -d
- Install the requirements:
pip install -r requirements.txt
-
Install Ollama and pull LLM model specified in config.yml
-
Copy text PDF files to the
data
folder -
Run the script, to convert text to vector embeddings and save in Weaviate:
python ingest.py
- Run the script, to process data with LLM RAG and return the answer:
python main.py "retrieve invoice_number, invoice_date, client_name, client_address, client_tax_id, seller_name,
seller_address, seller_tax_id, iban, names_of_invoice_items, gross_worth_of_invoice_items and total_gross_worth"
Answer:
{
"invoice_number": 61356291,
"invoice_date": "09/06/2012",
"client_name": "Rodriguez-Stevens",
"client_address": "2280 Angela Plain, Hortonshire, MS 93248",
"client_tax_id": "939-98-8477",
"seller_name": "Chapman, Kim and Green",
"seller_address": "64731 James Branch, Smithmouth, NC 26872",
"seller_tax_id": "949-84-9105",
"iban": "GB50ACIE59715038217063",
"names_of_invoice_items": [
"Wine Glasses Goblets Pair Clear Glass",
"With Hooks Stemware Storage Multiple Uses Iron Wine Rack Hanging Glass",
"Replacement Corkscrew Parts Spiral Worm Wine Opener Bottle Houdini",
"HOME ESSENTIALS GRADIENT STEMLESS WINE GLASSES SET OF 4 20 FL OZ (591 ml) NEW"
],
"gross_worth_of_invoice_items": [
66.0,
123.55,
8.25,
14.29
],
"total_gross_worth": "$212,09"
}