End-to-End LLM Decision Engine for Insurance, Legal & HR Docs
Hackathon-Ready | Gemini-Powered | PDF-to-Decision in Seconds
git clone https://github.com/vanstyagi/policy-llm-decision-engine.git
cd policy-query-system
pip install -r requirement.txt
echo "GEMINI_API_KEY=YOUR_KEY_HERE" > .env
python src/main.py "46-year-old male, knee surgery in Pune, 3-month policy"βοΈ Output will show in terminal and outputs/final.json like:
{
"decision": "approved",
"amount": null,
"justification": "Knee surgery is covered. Age & location are valid per policy clauses.",
"clauses": ["data_chunk95.txt", "data4_chunk56.txt", "data_chunk52.txt"]
}| Folder / File | Purpose |
|---|---|
| data/ | Input folder for PDF / DOCX / EML |
| outputs/chunks/ | Auto-generated document chunks (300 words) |
| outputs/final.json | Final structured JSON output |
| src/check_data.py | List available documents |
| src/chunk_docs.py | Split documents into chunks |
| src/load_docs.py | Extract raw text |
| src/load_chunks.py | Load all chunk files |
| src/parse_query.py | Parse natural query β structured JSON |
| src/retrieve.py | Semantic search via sentence-transformers |
| src/decide.py | LLM (Gemini) generates decision JSON |
| src/main.py | CLI entry point for full pipeline |
| .env | Store API Key (never commit) |
| requirement.txt | All dependencies |
| README.md |
| π§© Step | π οΈ Command |
| 1οΈβ£ Clone | git clone <repo-url> |
| 2οΈβ£ Install Deps | pip install -r requirement.txt |
| 3οΈβ£ Set API Key | echo "GEMINI_API_KEY=YOUR_KEY" > .env |
| 4οΈβ£ Run | python src/main.py "<your query>" |
| 5οΈβ£ Output | cat outputs/final.json |
| Capability | β Status |
|---|---|
| Natural-language query (free-text) | β |
| Parse age, gender, location, procedure | β |
| Ingest PDF, DOCX, and EML | β |
| Semantic search using embeddings | β |
| Gemini-based approve/reject reasoning | β |
| Clause-level mapping | β |
| JSON output for downstream usage | β |
python src/main.py "46-year-old male, knee surgery in Pune, 3-month policy"
python src/main.py "23-year-old female, cardiac surgery, Mumbai, 6-month policy"
python src/main.py "60-year-old man, hip replacement, Delhi, 1-year policy"- Python 3.11
- PyPDF2, python-docx β document ingestion
- Sentence-Transformers β semantic similarity search
- Google Gemini 1.5 Flash β final decision reasoning
- dotenv β key management
| π§© Stage | π Description |
|---|---|
| parse_query.py | Regex / NLP β extract query entities |
| retrieve.py | Embed + semantic search over document chunks |
| decide.py | Gemini generates final structured JSON |
| final.json | Output β usable by any downstream system |
π§Ύ Flow:
Plain-English Query
β
parse_query.py
β
retrieve.py (embedding + search)
β
decide.py (LLM reasoning)
β
final.json
MIT Β© VANSH TYAGI