A sophisticated Retrieval-Augmented Generation (RAG) system designed for Australian building regulatory compliance queries. This system combines multimodal document processing with AI-powered question answering to provide expert guidance on building massing, setbacks, and compliance requirements.
# Clone the repository
git clone <repository-url>
cd mmrag_hackathon
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Create a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key_here
QDRANT_API_KEY=your_qdrant_api_key_here
HF_TOKEN=your_huggingface_token_here
# Place your PDF documents in the regulations folder
mkdir -p regulations/
# Copy your building regulation PDFs to this folder
# Run the database update script to process and index documents
python update_db.py
# Launch the Flask API
python app.py
The API will be available at http://localhost:5000
Main RAG endpoint for building regulatory queries.
Request Format:
{
"query": "What are the setback requirements for a 2-storey residential building in NSW?"
}
Response Format:
{
"response": "**COMPLIANCE ASSESSMENT:** Requires Clarification...",
"docs": [
{
"filename": "nsw_building_code.pdf",
"page_number": 15,
"score": 0.89,
"image": "base64_encoded_image_data"
}
]
}
Get summary information about regulations.
Request Format:
{
"language": "en"
}
import requests
import json
def query_regulations(question):
url = "http://localhost:5000/query"
headers = {"Content-Type": "application/json"}
data = {"query": question}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
result = response.json()
print("Expert Analysis:", result["response"])
print(f"Found {len(result['docs'])} relevant documents")
return result
else:
print(f"Error: {response.status_code}")
return None
# Example usage
question = """
I have a 800mΒ² site in Melbourne, VIC. I want to build a 3-storey apartment building
with 60% site coverage. What are the required setbacks and height limits?
"""
result = query_regulations(question)
curl -X POST http://localhost:5000/query \
-H "Content-Type: application/json" \
-d '{
"query": "What is the maximum building height allowed in R3 Medium Density Residential zones in NSW?"
}'
Use the provided test script for quick validation:
python api_test.py
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RAG SYSTEM ARCHITECTURE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π PDF Documents β π ColPali Processing β ποΈ Qdrant β
β (Building Codes) (Visual + Text) (Vector DB) β
β β
β π€ User Query β π Similarity Search β π Results β
β β
β π Retrieved Docs β π€ GPT-4o Analysis β β
Response β
β (Relevant Pages) (Expert System) (Compliance) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1. Document Processing Pipeline:
update_db.py - Indexes PDFs and creates vector embeddingsmultimodal_utils.py - Handles PDF to image conversionmodels.py - Defines ColPali model configurations2. RAG Query Engine:
rag_retrieval.py - Implements retrieval and response generationapp.py - Flask API endpoints and routing3. Utilities:
api_test.py - Testing and validation scriptsThis system provides general guidance based on available regulatory documents. Always consult with:
OpenAI API Timeout:
rag_retrieval.pyQdrant Connection Issues:
.envGPU Memory Issues:
update_db.pyDocument Processing Errors:
We welcome contributions to improve the system:
2 commits
Python
39.8%
HTML
35.4%
TypeScript
21.4%
CSS
2.3%
A sophisticated Retrieval-Augmented Generation (RAG) system designed for Australian building regulatory compliance queries. This system combines multimodal document processing with AI-powered question answering to provide expert guidance on building massing, setbacks, and compliance requirements.
# Clone the repository
git clone <repository-url>
cd mmrag_hackathon
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Create a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key_here
QDRANT_API_KEY=your_qdrant_api_key_here
HF_TOKEN=your_huggingface_token_here
# Place your PDF documents in the regulations folder
mkdir -p regulations/
# Copy your building regulation PDFs to this folder
# Run the database update script to process and index documents
python update_db.py
# Launch the Flask API
python app.py
The API will be available at http://localhost:5000
Main RAG endpoint for building regulatory queries.
Request Format:
{
"query": "What are the setback requirements for a 2-storey residential building in NSW?"
}
Response Format:
{
"response": "**COMPLIANCE ASSESSMENT:** Requires Clarification...",
"docs": [
{
"filename": "nsw_building_code.pdf",
"page_number": 15,
"score": 0.89,
"image": "base64_encoded_image_data"
}
]
}
Get summary information about regulations.
Request Format:
{
"language": "en"
}
import requests
import json
def query_regulations(question):
url = "http://localhost:5000/query"
headers = {"Content-Type": "application/json"}
data = {"query": question}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
result = response.json()
print("Expert Analysis:", result["response"])
print(f"Found {len(result['docs'])} relevant documents")
return result
else:
print(f"Error: {response.status_code}")
return None
# Example usage
question = """
I have a 800mΒ² site in Melbourne, VIC. I want to build a 3-storey apartment building
with 60% site coverage. What are the required setbacks and height limits?
"""
result = query_regulations(question)
curl -X POST http://localhost:5000/query \
-H "Content-Type: application/json" \
-d '{
"query": "What is the maximum building height allowed in R3 Medium Density Residential zones in NSW?"
}'
Use the provided test script for quick validation:
python api_test.py
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RAG SYSTEM ARCHITECTURE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π PDF Documents β π ColPali Processing β ποΈ Qdrant β
β (Building Codes) (Visual + Text) (Vector DB) β
β β
β π€ User Query β π Similarity Search β π Results β
β β
β π Retrieved Docs β π€ GPT-4o Analysis β β
Response β
β (Relevant Pages) (Expert System) (Compliance) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1. Document Processing Pipeline:
update_db.py - Indexes PDFs and creates vector embeddingsmultimodal_utils.py - Handles PDF to image conversionmodels.py - Defines ColPali model configurations2. RAG Query Engine:
rag_retrieval.py - Implements retrieval and response generationapp.py - Flask API endpoints and routing3. Utilities:
api_test.py - Testing and validation scriptsThis system provides general guidance based on available regulatory documents. Always consult with:
OpenAI API Timeout:
rag_retrieval.pyQdrant Connection Issues:
.envGPU Memory Issues:
update_db.pyDocument Processing Errors:
We welcome contributions to improve the system:
2 commits
Python
39.8%
HTML
35.4%
TypeScript
21.4%
CSS
2.3%