# 🧠 LLM-Based Insurance Policy Decision System
A document query system powered by large language models (LLMs) that extracts structured information from natural language insurance-related queries and returns clause-level decisions with justifications.
---
## 🚀 Features
- Parses age, gender, procedure, location, and policy duration from queries
- Uses semantic similarity to match insurance clauses
- Makes approval/rejection decisions based on rules
- Provides clause-level justifications
- Includes integration and performance testing
---
## 🗃️ Project Structure
| File/Folder | Description |
|-------------------------------------|------------------------------------------|
| `everything.py` | Main orchestrator |
| `parse.py` | Extracts structured data from query |
| `test_parser.py` | Unit tests for parser |
| `test_decision_engine.py` | Tests for decision logic |
| `test_integration.py` | End-to-end system test |
| `test_performance.py` | Performance evaluation |
| `enter_query.py` | Manual query entry for testing |
| `all_clauses.json` | Raw clauses |
| `all_clauses_with_embeddings.json` | Clause embeddings |
| `clauses/` | Individual clause text files |
| `models/` | Saved models and embeddings |
| `output/` | Output and logs |
| `myenv/` | Virtual environment (ignored) |
---
## 💻 How to Run
1. **Create a virtual environment**
```bash
python -m venv myenv
source myenv/bin/activate # On Windows: myenv\Scripts\activate-
Install dependencies
pip install -r requirements.txt
-
Run the system
python everything.py
-
Enter test query manually
python enter_query.py
"A 60-year-old male wants a knee replacement in Bangalore, 8 months into his policy."
Output:
- Decision: Approved ❎ / Rejected ✅
- Clause:
"Treatment covered after 6 months for age > 50" - Explanation:
"The user's policy duration satisfies the clause condition for coverage."
- LLM used:
sentence-transformers/all-MiniLM-L6-v2 - Clause embedding file is precomputed and saved in JSON format
- Performance tests benchmark query time and decision speed