This project focuses on building an end-to-end Retrieval-Augmented Generation (RAG) system for a diabetes Q&A application. The system leverages a diabetes-related dataset, ingests it into a knowledge base, and implements a RAG flow that retrieves relevant information and generates answers to user queries using a Large Language Model (LLM). The project also includes evaluation metrics, a user interface, monitoring features, and detailed instructions for reproducing the results.
The aim of this project is to create a system that can provide accurate and relevant answers to diabetes-related questions by combining retrieval and generation techniques. The system is designed to enhance the accuracy of responses by integrating information from a pre-ingested knowledge base and refining the output using a Cohere LLM API.
- LLM: Cohere API
- Knowledge Base: Qdrant and Elasticsearch
- Monitoring: Streamlit and Plotly
- Interface: Streamlit
- Ingestion Pipeline: Python scripts (
ingestion_with_qdrant.py
,ingestion_with_elasticsearch.py
)
├── scripts
│ ├── ingestion_with_qdrant.py
│ ├── ingestion_with_elasticsearch.py
│ ├── retrieval_evaluator_qdrant.py
│ ├── retrieval_evaluator_elasticsearch.py
│ ├── rag_evaluator.py
│ ├── dashboard.py
│ ├── diabetesRag.py
├── diabetesRag.py
├── dashboard.py
├── README.md
├── requirements.txt
├── docker-compose.yaml
├── .streamlit
│ └── config.toml
├── database.db
└── images
│ ├── dashboard.jpg
│ ├── user_feedback.jpg
git clone https://github.com/Alonge9500/LLMZoomcampProject.git
cd LLMZoomcampProject.git
Make sure you have Python 3.8+ installed. Install the required Python packages:
pip install -r requirements.txt
To Load and add Index To your DATA and save as CSV file
python scripts/base_file_indexing.py
To Load data with index and create vectors embeddings and save the result as a CSV file
python scripts/create_vectors.py
To ingest data into Qdrant:
python scripts/ingestion_with_qdrant.py
To ingest data into Elasticsearch:
python scripts/ingestion_with_elasticsearch.py
To evaluate the Qdrant retrieval:
python scripts/retrieval_evaluator_qdrant.py
Qdrant Evaluation Results:
- HitRATE: 0.6375
- MRR: 0.4593
To evaluate Elasticsearch retrieval (both hybrid and vector-only search):
python scripts/retrieval_evaluator_elasticsearch.py
Elasticsearch Evaluation Results:
- Hybrid Search:
- HitRATE: 0.64375
- MRR: 0.4605
- Vector-Only Search:
- HitRATE: 0.6375
- MRR: 0.4593
To evaluate the RAG flow:
python scripts/rag_evaluator.py
RAG Evaluation Results:
- Average Cosine Similarity: 0.85 (across 30 questions)
Launch the Streamlit app to interact with the RAG system:
streamlit run diabetesRag.py
Or Start with Docker Compose
To monitor the application and view user feedback, run the dashboard:
streamlit run monitoring_dashboard.py
The monitoring dashboard collects user feedback and some other metrics, store it in the database using sqlite3 and visualizes it using Plotly charts as shown in the image below.
The application interface is built using Streamlit, providing an easy-to-use platform for users to interact with the RAG system. The interface allows users to ask questions, view answers, and submit feedback.
The system includes a monitoring feature that collects user feedback and displays it on a dashboard created with Streamlit and Plotly. The dashboard includes various charts to track system performance and user interactions. Link to Monitoring Dashboard -> https://monitoringdashboard.streamlit.app/
This project is fully reproducible. All necessary instructions for running the code, from setting up the environment to executing the scripts, are provided. The dataset used is accessible, and the code is organized for easy execution.
The project includes a docker-compose
for managing dependencies.
- Hybrid Search: Implemented and evaluated
The application can be deployed to the cloud using Streamlit Cloud: https://llmzoomcampprojectdiabetesapp.streamlit.app/
This project put to use all the knowledege gathered in LLMZOOMCAMP 2024 by DATATALKS, it demonstrates the effective use of RAG techniques to build a robust Q&A system for diabetes-related queries. It includes comprehensive evaluation metrics, a user-friendly interface, and a detailed monitoring dashboard, making it a valuable tool for both end-users and developers.