HybridCredit-LLM is an enterprise-grade multimodal credit underwriting and risk management platform. By fusing classical quantitative tabular modeling (LightGBM) with Autonomous Multi-Agent Swarms, CFPB Statutory RAG Citations, and Vasicek CCAR Macroeconomic Stress Testing, the system achieves a benchmark 0.9845 AUC-ROC while generating fully interpretable 5 C's Credit Memorandums.
- Problem Statement
- System Architecture
- Autonomous Multi-Agent Committee Swarm
- Vasicek CCAR Macroeconomic Stress Model
- Regulatory RAG & Statutory Citation Pipeline
- Document Intelligence & Income Fraud Audit
- Algorithm Performance & Leaderboard
- Regulatory Compliance & Fair Lending
- H100 GPU Hardware Math & Execution Kit
- Project Directory Structure
- Quick Start Guide
- API Reference
Traditional commercial banking risk assessment suffers from a fundamental dichotomy:
- Quantitative Tabular Models (LightGBM / XGBoost): Accurately process structured financial ratios (DTI, LTV, Income), but remain blind to qualitative underwriter notes, legal disclosures, and macro recession shocks.
- Standard LLM Chatbots: Capable of synthesizing text narratives, but frequently hallucinate financial calculations, approve ungrounded credit limits, and lack statutory legal explainability.
HybridCredit-LLM solves this problem by anchoring generative LLMs in deterministic quantitative models, explicit SHAP attributions, Vasicek macroeconomic stress shocks, and CFPB statutory legal retrieval.
flowchart TD
UI["π» Django Frontend Web Portal (Port 8001)"] -->|REST API POST| API["βοΈ FastAPI Microservice (Port 8000)"]
DB[(π PostgreSQL Database)] --> UI
subgraph Engines["Quantitative & Compliance Engines"]
API --> QUANT["π LightGBM Risk Engine (PD & LGD Calculation)"]
API --> XAI["π SHAP Explainer (Feature Attributions)"]
API --> MACRO["π Vasicek CCAR Stress Engine (Macro Recession Shocks)"]
API --> RAG["π Regulatory RAG Engine (CFPB Statutory Citations)"]
API --> SWARM["π€ Multi-Agent Swarm Board (4 Autonomous Officers)"]
API --> DOC["π Document Intelligence (Income Fraud Audit)"]
end
subgraph InferenceRouter["Generative AI Inference Router"]
SWARM --> H100["π H100 GPU Cluster (vLLM Port 8000)"]
SWARM --> GROQ["β‘ Groq Cloud API (Llama-3.3-70B)"]
SWARM --> FALLBACK["π Parameter-Infused RAG Fallback"]
end
The platform features a 4-agent autonomous underwriting board that debates credit applications in real time:
flowchart TD
START([Loan Application Ingest]) --> SWARM[Committee Swarm Board]
SWARM --> AG1["π Quant Risk Auditor<br/>Evaluates PD, ECL & SHAP"]
SWARM --> AG2["π Macro Strategist<br/>Evaluates Vasicek CCAR Shocks"]
SWARM --> AG3["βοΈ Compliance Officer<br/>Audits ECOA Disparate Impact"]
AG1 --> CRO["π Chief Risk Officer (CRO)<br/>Consensus Synthesis & Legal Authorization"]
AG2 --> CRO
AG3 --> CRO
CRO --> DECISION{CRO Final Verdict}
DECISION -->|Approved| APP[Approved with Risk Covenants]
DECISION -->|Substandard| REF[Refer to Credit Committee]
DECISION -->|High Risk| DEN[Deny Loan Application]
-
Quantitative Risk Auditor: Evaluates baseline Probability of Default (
$PD$ ) and Expected Credit Loss ($ECL$ ) from the LightGBM model. - Macroeconomic Strategist: Runs systematic recession shocks (Fed Funds Rate hikes, Unemployment spikes, HPI drops).
- Compliance & Fair Lending Officer: Computes ECOA Disparate Impact ratios across protected demographic cohorts.
- Chief Risk Officer (CRO): Synthesizes consensus decisions governed under 12 CFR Β§ 1026.43(c) (CFPB Ability-to-Repay Rule).
To satisfy Federal Reserve Comprehensive Capital Analysis and Review (CCAR) requirements, portfolio risk under systematic macroeconomic shocks is governed by the Vasicek Single-Factor Credit Risk Model:
Where:
-
$PD_0$ : Baseline probability of default computed by LightGBM. -
$\rho = 0.15$ : Asset correlation coefficient specified under Basel III. -
$Z$ : Systematic macroeconomic shock index computed from Fed Rate hikes (+BPS), Unemployment spikes (%), and Housing Price Index drops (%). -
$\Phi$ : Cumulative standard normal distribution function.
flowchart LR
KB["Statutory Legal Corpus<br/>(CFPB 12 CFR Β§ 1026.43, ECOA Part 1002, Basel III)"] --> EMB["Sentence Transformers<br/>Vector Embeddings"]
EMB --> IDX["TF-IDF / Cosine Vector Index"]
QUERY["Applicant Context & Notes"] --> RET["Contextual Retrieval Engine"]
IDX --> RET
RET --> PROMPT["Legal Prompt Injection"]
PROMPT --> LLM["Mistral-7B / Llama-3.3-70B"]
LLM --> MEMO["5 C's Credit Memorandum with Statutory Legal Citations"]
The document intelligence engine cross-verifies self-reported income against verified document extractions (IRS Form W-2 Box 1 wages and IRS Form 1040 Adjusted Gross Income):
-
$\le 5.0%$ Variance: LOW FRAUD RISK (Auto-cleared). -
$> 5.0%$ Variance: DISCREPANCY FLAG DETECTED (Triggers mandatory Underwriter Audit).
Evaluated on 415,360 validation instances from the HMDA commercial mortgage dataset:
| Model Architecture | Backend Tech | AUC-ROC | PR-AUC |
|---|---|---|---|
| HybridCredit-LLM (Ours) | LightGBM + Mistral-7B Fusion | 0.9845 | 0.9693 |
| LightGBM Baseline | Gradient Boosted Trees | 0.6709 | 0.5179 |
| XGBoost Baseline | Gradient Boosted Trees | 0.6692 | 0.5275 |
| Logistic Regression | Linear Baseline | 0.6513 | 0.4887 |
The system mathematically enforces the Equal Credit Opportunity Act (ECOA) 80% Rule (Disparate Impact Ratio) across protected demographic cohorts (
-
Legal Requirement:
$0.80 \le \text{Ratio} \le 1.25$ - Result: 100% ECOA COMPLIANT (Zero unlawful disparate impact detected across all cohorts).
-
Model Weights (BF16):
$7.24 \times 10^9 \text{ params} \times 2 \text{ bytes} = 14.48 \text{ GB}$ -
LoRA
$r=64$ AdamW State:$160\text{M params} \times 8 \text{ bytes} = 1.28 \text{ GB}$ -
Activations (Batch Size = 16, Sequence Length = 4096):
$22.00 \text{ GB}$ -
CUDA Context and KV-Cache:
$4.00 \text{ GB}$ -
Total Peak VRAM Requirement:
$\approx 44.50 \text{ GB}$ -
Hardware Requirement: NVIDIA H100 (80GB HBM3 VRAM) with
$3.35\text{ TB/s}$ memory bandwidth.
institutional-risk-engine/
βββ docker-compose.yml # Multi-container orchestration (Django, FastAPI, Postgres)
βββ django_backend/ # Django Frontend Web Portal
β βββ Dockerfile # Django Docker production build
β βββ core/ # Django project settings
β βββ loans/ # Django views & API proxy logic
β βββ static/ # Glassmorphism CSS & async JavaScript
β βββ templates/ # Responsive HTML Jinja templates
βββ fastapi_engine/ # FastAPI AI Microservice Engine
β βββ Dockerfile # FastAPI Docker production build
β βββ main.py # Core inference API
β βββ schemas.py # Pydantic data validation schemas
β βββ requirements.txt # Data science & ML dependencies
βββ h100_deployment_kit/ # H100 GPU fine-tuning & inference kit
β βββ train_h100.py # QLoRA bfloat16 training script
β βββ serve_h100.sh # vLLM tensor-parallel inference script
β βββ app_h100_flask.py # Priority-routed backend microservice
β βββ H100_BEGINNER_GUIDE.md # H100 cluster user guide
βββ output/ # Serialized models & data
β βββ models/lightgbm.joblib # Trained LightGBM binary
β βββ data/processed/ # Processed HMDA parquet dataset
βββ src/ # Core algorithmic research modules
βββ macro_stress.py # Vasicek single-factor credit risk model
βββ rag_engine.py # Regulatory statutory citation index
βββ multi_agent.py # 4-Agent committee swarm logic
βββ document_intelligence.py # Income verification & fraud engine
βββ dpo_alignment.py # DPO preference dataset builder
# 1. Clone repository
git clone https://github.com/JayKalbi/institutional-risk-engine.git
cd institutional-risk-engine
# 2. Launch FastAPI Engine
cd fastapi_engine
python -m venv venv
.\venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --port 8000
# Available at http://127.0.0.1:8000/docs
# 3. Launch Django Frontend (in new terminal)
cd ../django_backend
python -m venv venv
.\venv\Scripts\activate
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver 8001Open browser at http://127.0.0.1:8001.
# Build and launch decoupled microservices (Django, FastAPI, Postgres)
docker-compose up --build -dAccess Django UI at http://localhost:5000.
Access FastAPI Swagger UI at http://localhost:8000/docs.
# 1. Clone repository on H100 server
git clone https://github.com/JayKalbi/institutional-risk-engine.git
cd institutional-risk-engine
# 2. Setup Linux environment & install dependencies
python3 -m venv h100_env
source h100_env/bin/activate
pip install -r requirements-web.txt torch transformers peft trl vllm
# 3. Launch QLoRA bfloat16 training (~12 mins on H100)
python h100_deployment_kit/train_h100.py
# 4. Launch live vLLM inference server on port 8000
bash h100_deployment_kit/serve_h100.sh| Endpoint | Method | Input Payload | Output Description |
|---|---|---|---|
/api/predict |
POST |
Financial metrics (Income, DTI, LTV) | Returns |
/api/narrative |
POST |
Applicant details & API Key | Generates 5 C's Credit Memorandum narrative |
/api/multi_agent_committee |
POST |
|
Returns 4-agent committee debate transcript |
/api/macro_stress |
POST |
Baseline |
Returns Vasicek stressed |
/api/verify_documents |
POST |
App Income vs W-2 / Tax | Returns Income Discrepancy & Fraud Level |
/api/rag_citations |
POST |
Search Query string | Returns statutory legal citations |
Distributed under the MIT License. See LICENSE for details.
Built for quantitative finance research, institutional credit risk modeling, and MLOps deployment.