Production-ready Explainable AI platform combining LoRA-fine-tuned DistilBERT for financial sentiment analysis with XGBoost credit risk prediction — featuring real-time SHAP & LIME explanations and Fairlearn bias auditing, all served through an interactive Streamlit dashboard.
┌──────────────────────────────────────────────────────────────────────┐
│ FinSentinel Pipeline │
├──────────────┬───────────────┬──────────────────┬───────────────────┤
│ DATA LAYER │ TRAINING LAYER│ EXPLAINABILITY │ DASHBOARD LAYER │
│ │ │ LAYER │ │
│ HuggingFace │ DistilBERT + │ SHAP Text & │ Streamlit App │
│ Datasets │ LoRA/PEFT │ TreeExplainer │ (4 pages) │
│ │ │ │ │
│ Synthetic │ XGBoost │ LIME Text & │ ┌── Sentiment ──┐ │
│ Credit Data │ Classifier │ Tabular │ ├── Credit Risk ┤ │
│ (sklearn) │ │ │ ├── Fairness ───┤ │
│ │ │ Fairlearn │ └── Metrics ────┘ │
│ │ │ Bias Audit │ │
└──────────────┴───────────────┴──────────────────┴───────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
data/*.csv models/ outputs/*.png localhost:8501
finsentinel- outputs/*.json
lora/ outputs/*.html
- LoRA Fine-Tuning — Parameter-efficient fine-tuning of DistilBERT using PEFT (r=8, alpha=16) for 3-class financial sentiment classification
- SHAP Explainability — Token-level SHAP values for text predictions + TreeExplainer waterfall & beeswarm plots for credit risk
- LIME Explainability — LIME text explanations for sentiment + tabular explanations for credit risk
- Fairlearn Bias Auditing — Demographic parity & equalized odds evaluation across age groups
- Interactive Dashboard — 4-page Streamlit app with real-time inference, SHAP/LIME visualizations, and fairness reporting
- Docker Ready — Single-command deployment with Docker
FinSentinel/
├── data/
│ └── prepare_data.py # Download & generate datasets
├── training/
│ └── finetune.py # LoRA/PEFT fine-tuning
├── explainability/
│ ├── shap_explainer.py # SHAP explanations
│ └── lime_explainer.py # LIME explanations
├── fairness/
│ └── fairness_eval.py # Fairlearn bias audit
├── dashboard/
│ └── app.py # Streamlit multi-page dashboard
├── models/ # Saved model weights (auto-downloaded)
├── outputs/ # Generated plots & metrics
├── .streamlit/config.toml # Streamlit theme config
├── packages.txt # System deps for Streamlit Cloud
├── requirements.txt
├── Dockerfile
├── .gitignore
└── README.md
git clone https://github.com/Purnachander-Konda/FinSentinel.git
cd FinSentinel
pip install -r requirements.txtpython data/prepare_data.pyDownloads financial_phrasebank from HuggingFace and generates a synthetic credit risk dataset (500 rows).
python training/finetune.pyFine-tunes DistilBERT with LoRA on financial sentiment data (3 epochs). Saves model to models/finsentinel-lora/.
python explainability/shap_explainer.py
python explainability/lime_explainer.py
python fairness/fairness_eval.pystreamlit run dashboard/app.pyOpen http://localhost:8501 in your browser.
docker build -t finsentinel .
docker run -p 8501:8501 finsentinelNote: Run data preparation and training steps before building the Docker image (or mount volumes for models/outputs).
| Sentiment Analyzer | Credit Risk Predictor |
|---|---|
![]() |
![]() |
| Fairness Report | Training Metrics |
|---|---|
![]() |
![]() |
| Metric | Value |
|---|---|
| Sentiment Accuracy | 93.82% |
| Sentiment F1 (weighted) | 93.85% |
| Sentiment Precision | 93.97% |
| Sentiment Recall | 93.82% |
| Demographic Parity Diff | 0.4701 |
| Equalized Odds Diff | 0.3333 |
| Trainable Parameters | ~1.09% (LoRA) |
| Component | Technology |
|---|---|
| Base Model | DistilBERT (HuggingFace) |
| Fine-Tuning | PEFT / LoRA |
| Credit Risk Model | XGBoost |
| Explainability | SHAP, LIME |
| Fairness | Fairlearn |
| Dashboard | Streamlit |
| Data | HuggingFace Datasets, scikit-learn |
| Containerization | Docker |
| Deployment | Streamlit Cloud |
| Language | Python 3.14 |
Poorna Chander Konda
This project is licensed under the MIT License. See LICENSE for details.



