MortgageUnderwritingSwarm is a multi-agent mortgage underwriting system built with swarms.ai. It leverages a modular multi-agent architecture to analyze mortgage documents, evaluate risk, and produce final underwriting decisions—all in less than 24 hours. The system supports PDF-to-text conversion, autosaving of intermediate results, flexible output formats (PDF/JSON), and batch processing for multiple applications.
MortgageUnderwritingSwarm automates the mortgage underwriting process using three specialized agents:
-
Document Analyzer Agent
Extracts and validates key information from mortgage documents (text or PDF). -
Risk Evaluator Agent
Analyzes the extracted data to compute a detailed risk score and evaluation. -
Mortgage Underwriter Agent
Integrates all data to render a final underwriting decision (Approved, Conditionally Approved, or Denied).
These agents work sequentially and collaboratively to ensure that the entire underwriting process is both robust and transparent.
-
Advanced Document Processing:
Supports both text and PDF documents with built-in PDF-to-text conversion. -
Comprehensive Risk Evaluation:
Detailed analysis of financial, credit, and property data to generate a risk score. -
Automated Underwriting Decisions:
Final decisions include exhaustive explanations that adhere to industry standards. -
Autosaving & Batch Processing:
Automatically saves intermediate results and supports processing multiple applications concurrently. -
Flexible Output Formats:
Generate final reports as PDF documents or JSON data structures for seamless integration with other systems.
Below is a high-level overview of how the system processes an application:
flowchart TD
A[Mortgage Application Documents]
B[PDF-to-Text Conversion]
C[Document Analyzer Agent]
D[Risk Evaluator Agent]
E[Mortgage Underwriter Agent]
F[Autosave Intermediate Results]
G[Final Output Generation]
A -->|Text or PDF| B
B --> C
C --> F
F --> D
D --> F
F --> E
E --> F
E --> G
The following sequence diagram shows how data flows through the system:
sequenceDiagram
participant U as User/Application
participant D as Document Analyzer Agent
participant R as Risk Evaluator Agent
participant M as Mortgage Underwriter Agent
participant S as Autosave & Batch Processor
participant O as Output Generator
U->>D: Submit Mortgage Documents
D->>S: Save Document Analysis Output
D->>R: Forward Analysis Summary
R->>S: Save Risk Evaluation Output
R->>M: Forward Risk Evaluation Report
M->>S: Save Underwriting Decision Output
M->>O: Generate PDF/JSON Report
O->>U: Return Final Underwriting Decision
-
Clone the Repository
git clone https://github.com/The-Swarm-Corporation/MortgageUnderwritingSwarm.git cd MortgageUnderwritingSwarm
-
Install Dependencies
This project requires Python 3.8+ along with several libraries:
swarms
(from swarms.ai)PyPDF2
reportlab
Install dependencies using pip:
pip install -r requirements.txt
-
Set Up Your Environment
Ensure that any necessary environment variables are configured, particularly if your
swarms.ai
setup requires authentication or API keys.
To process a single mortgage application, you can run the script directly:
python mortgage_underwriting_swarm.py
Alternatively, import the class into your own Python script:
from mortgage_underwriting_swarm import MortgageUnderwritingSwarm
# Initialize the swarm with a designated autosave directory
swarm = MortgageUnderwritingSwarm(save_directory="./autosave_results")
# Process a single mortgage application
final_pdf_path = swarm.process_application(
application_data="Your application document text here...",
return_format="pdf",
output_filename="Applicant_UnderwritingDecision"
)
print(f"PDF generated at: {final_pdf_path}")
For processing multiple applications simultaneously:
applications = [
"Application data for Applicant 1...",
"Application data for Applicant 2...",
# Add more application texts as needed
]
# Process applications in batch and return JSON results
results = swarm.process_applications_in_batch(applications, return_format="json")
for result in results:
print(result)
If your input documents are in PDF format, convert them to text using:
text_from_pdf = swarm.pdf_to_text("path_to_document.pdf")
print(text_from_pdf)
-
Multi-Agent Architecture:
The system employs three dedicated agents that each focus on a specific task (document analysis, risk evaluation, and final underwriting). Each agent is powered by a GPT-4o-mini model provided by swarms.ai. -
Autosaving:
Intermediate outputs are autosaved as text files to ensure auditability and traceability. -
Flexible Output:
The final underwriting decision can be generated as either a PDF report (using ReportLab) or as a JSON object. -
Batch Processing:
The system supports batch processing, allowing multiple mortgage applications to be processed in a single run. -
PDF-to-Text Conversion:
Using PyPDF2, the system can convert PDF documents into plain text for further processing by the agents.
Contributions are highly welcome! Please follow these guidelines:
- Fork the repository.
- Create a feature branch for your changes.
- Write tests to validate your changes.
- Submit a pull request with detailed information about your changes.
For any questions or discussion, please open an issue in the repository.
- Swarms Framework
- Python 3.10+
- GROQ API Key or you can change it to use any model from Swarm Models
Questions? Reach out:
- Twitter: @kyegomez
Book a call with here for real-time assistance:
⭐ Star us on GitHub if this project helped you!
Built with ♥ using Swarms Framework