Skip to content

Repository files navigation

This is an intersectional combination of Artificial Intelligence (AI) and specificly Large Language Models (LLM), Natural Language Processing, PDFs, Land Rovers and car maintenance..a rainy day summer project for fun.

I.e. this is a short trial of the Retrieval-Augmented Generation (RAG) method with a quantized version of the LLAMA 3 8B Large Language Model. The retrieval is performed using the Chroma vector database, which stores parts of the document and their respective embeddings from the Land Rover Discovery II maintenance manual (not included in this repository). This application is supposed to have some sort of the knowledge of the Land Rover Discovery II models and their maintenance. Queries can be about the Discovery II and its maintenance can be done with this simple python script. Data is not included: See read_pdf_to_chroma_langchain.py to preprocesses the input PDF file to the data/pdf folder, dividing it to chunks of text and embedding, finally storing it to the Chroma DB. You need to have your own legal copy of RAVE to source the PDF.

Based on the following readily available components:

Moving parts:

The default prompt is "Tell me briefly about land rover discovery 2 model"

C:\Users\tai\Documents\kikkailuja\LRDISCO2_RAG_LLAMA3>python query_chroma_db_and_llama.py
The Land Rover Discovery Series II is a SUV that was produced from 1999 to 2004. It's known for its ruggedness, reliability, and off-road capabilities. The vehicle features a 4.0L V8 engine or the Td5 diesel engine option, with a manual or automatic transmission. The Discovery has a reputation for being capable in challenging terrain and is popular among outdoor enthusiasts.

Some technical details with custom prompt

C:\Users\tai\Documents\kikkailuja\LRDISCO2_RAG_LLAMA3>python query_chroma_db_and_llama.py -p "Tell me what is the firing order of the td5 diesel engine"
According to the provided context, the firing order for the 2.5 litre in-line direct injection diesel, turbocharged and intercooled Td5 engine is:

1 - 2 - 4 - 5 - 3
C:\Users\tai\Documents\kikkailuja\LRDISCO2_RAG_LLAMA3>python query_chroma_db_and_llama.py -p "Tell me how to adjust front door hinges in land rover discovery 2"
To adjust the front door hinges on a Land Rover Discovery 2, follow these steps:

1. Open the door and place a wooden block under it using the jack.
2. Loosen the four bolts securing the hinges to the door by turning them counterclockwise.
3. Use the jack to assist with door alignment while you make adjustments.

Once the adjustment is correct:

4. Tighten the hinge bolts in a star pattern (tightening one bolt, then moving to the next) until they reach 30 Nm (22 lbf-ft).
5. Remove the jack and close the door.
6. Check for correct alignment by ensuring the door fits flush with adjacent panels and has an equal gap at the edges.

Remember to adjust the door latch striker as well:

7. Loosen the two Torx bolts securing the door latch striker, then tighten them in a star pattern until they reach 26 Nm (19 lbf-ft).

Or just some opinnions :D

C:\Users\tai\Documents\kikkailuja\LRDISCO2_RAG_LLAMA3>python query_chroma_db_and_llama.py -p "Why is land rover discovery 2 better than its modern counter parts?"
Based on the workshop manual, I can provide some insights on why the Land Rover Discovery Series II (1999MY onwards) might be considered better than its modern counterparts in certain aspects. Here are a few points:

* The Series II Discovery was known for its ruggedness and off-road capabilities, which were unmatched by many of its contemporaries.
* Its design allowed it to tackle challenging terrain with ease, thanks to features like high ground clearance, four-wheel drive, and a robust suspension system.
* In terms of reliability, the Land Rover brand has historically been associated with durability and low maintenance costs. The Discovery Series II was no exception, with many owners reporting low repair rates and long lifespan for their vehicles.

Of course, this is just based on general information from the workshop manual, and opinions may vary depending on individual experiences and preferences.

Usage

query_chroma_db_and_llama.py switches

The main script supports the following command-line options:

  • -p, --prompt : custom user prompt text
  • -g, --gpu : try to use a GPU if one is available
  • -d, --debug : enable debug output for the Chroma retrieval
  • -i, --interactive : start an interactive chat loop

Example:

python query_chroma_db_and_llama.py -p "Tell me the firing order of the Td5 engine" -g

Run interactively:

python query_chroma_db_and_llama.py -i

If you need GPU support, add your GPU runtime flags and use -g as well.

Web UI

Note: Web UI deployments initialize the GPT4All backend with gpu=False to avoid GPU startup issues. This means inference runs on CPU and may be noticeably slower than a GPU-backed setup.

You can run the web interface locally with the FastAPI backend:

python -m uvicorn backend.api:app --host 0.0.0.0 --port 8000

Then open:

http://localhost:8000

The browser UI sends queries to /api/query and displays the generated answer plus retrieved context.

Build and run with Docker

Note: Docker deployments initialize the GPT4All backend with gpu=False to avoid GPU startup issues. This means inference runs on CPU and may be noticeably slower than a GPU-backed setup.

Build the container image:

docker build -t lrdisco2-rag-llama3 .

Run the web UI container:

docker run --rm -p 8000:8000 lrdisco2-rag-llama3

Run the query script directly instead of starting the web UI:

docker run --rm lrdisco2-rag-llama3 python query_chroma_db_and_llama.py -p "Tell me about the Td5 diesel engine"

Then browse to:

http://localhost:8000

Wishlist:

  • Improved PDF content capturing including tables (as HTML?) and maybe even images

About

Large Language Model based Retrieval-Augemented-Generation of Land Rover Discovery 2 maintenance information

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages