Spaces:
Sleeping
Sleeping
File size: 3,527 Bytes
b9eafd0 cffeaa1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
---
title: GenAI Loan Advisor
emoji: π¦
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
---
# π¦ GenAI Loan Advisor
A robust Multi-Agent System built with **CrewAI** and **Mistral** that automates the bank loan underwriting process. This system executes a strict sequential pipeline to retrieve customer data, consult internal policy documents (RAG), and determine risk levels with zero human intervention.
## ποΈ Architecture: The "Plan & Execute" Model
To prevent "infinite thinking loops" common in pure hierarchical systems, this project splits the workflow into two distinct phases:
USER QUERY: "Can Andy get a loan?"
β
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β PHASE 1: THE BRAIN (Strategy) β
β Agent: Senior Context Analyst β
β "I see a loan request. I will β
β activate the Application Pipeline." β
βββββββββββββββββ¬ββββββββββββββββββββββββ
β Pass JSON Plan
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β PHASE 2: THE MUSCLE (Execution) β
β (Strict Sequential Assembly Line) β
β β
β 1. DATA AGENT βββΆ Fetches PII & Scoreβ
β (Output: Score 780, Good Status) β
β β
β 2. RAG AGENT βββΆ Checks Policy β
β (Output: "750+ is Low Risk") β
β β
β 3. JUDGE AGENT βββΆ Makes Decision β
β (Output: "Approved @ 3.175%") β
β β
β 4. RESOLUTION AGENT βββΆ Final Report β
βββββββββββββββββββββββββββββββββββββββββ
Key Features
Smart Orchestration: The "Strategy Agent" acts as a Manager effectively by deciding the intent before the crew starts, eliminating the risk of the AI getting confused during execution.
Whole-Sheet RAG: Implements a specialized 1500-character chunking strategy to preserve entire "Risk Matrix" tables from PDF policies, preventing the AI from seeing fragmented data.
Hallucination Guardrails: The Data Agent is strictly bound to real customer lookups, preventing the invention of fake customers (like "John Doe").
Professional Reporting: The Resolution Agent ensures the final output is a clean, client-facing communication.
Project Structure
Quick Start
1. Environment Setup
Create a .env file in the root:
MISTRAL_API_KEY=your_api_key_here
CODE=Access_code
3. Ingest Policy Documents
Crucial Step: Run this once to build the Vector Database.
python rag/ingest_policies.py
4. Installation
pip install -r requirements.txt
python app.py
Sample Interaction
User: "Can Andy get a loan?"
System Logs:
Context Analyst: Intent detected: Loan Application. Data Agent: Successfully retrieved Customer ID 9982 (Andy). Score: 780. RAG Agent: Found rule: "Credit Score 750-850 = Low Risk". Underwriter: Mapping "Low Risk" to Interest Rate Table -> 3.175%.
Final Output:
"We are pleased to inform you that Andy's loan application has been APPROVED. Based on a credit score of 780, he qualifies for our Low Risk tier with an interest rate of 3.175%." |