A domain-specific RAG system for Masvingo City Council. Includes quantized civic data on by-laws, bill payments, licenses, water, departments, contacts, FAQs, glossary, and notices. Built for semantic search, chatbot integration, and public service transparency
# Masvingo City Council RAG-Based AI Assistant
## Overview
This project is a Retrieval-Augmented Generation (RAG) AI assistant designed for the Masvingo City Council. It allows you to ask questions about council documents and get answers based on the actual content of those documents.
The backend system loads, chunks, embeds, and searches through council documents, then uses a language model to generate answers using the most relevant information found.
## Features
- **Document Loading & Domain Classification:** Automatically assigns domain labels (by-laws, licensing, billing, notices, etc.) to documents during ingestion
- **Structured Data Integration:** Supports loading JSON and SQL data alongside text documents
- **Query Processing:** Classifies user queries into domains using keyword matching for targeted retrieval
- **Domain-Based Retrieval:** Filters search results by domain for more accurate responses
- **Retrieval Evaluation:** Built-in evaluation system with test queries, precision/recall metrics, and relevance scoring
- **Modular Architecture:** Separate modules for ingestion, classification, retrieval, and evaluation
## How It Works
1. **Document Ingestion:** Reads text files from the `data/` directory and assigns domain labels. Also loads structured data from JSON/SQL files.
2. **Domain Classification:** Documents are categorized into domains like "by-laws", "licensing", "billing", etc.
3. **Text Chunking:** Splits each document into smaller chunks for better search and retrieval.
4. **Embedding & Storage:** Chunks are embedded and stored in a vector database (ChromaDB) with domain metadata.
5. **Query Processing:** User queries are classified into domains before retrieval.
6. **Similarity Search:** Finds the most relevant chunks using vector similarity, filtered by domain.
7. **Answer Generation:** The language model uses the retrieved context to generate a response.
## Project Structure
```
Council Query Assistant/
├── src/
│ ├── …