metadata
title: Federated Credit Scoring
emoji: ๐
colorFrom: red
colorTo: red
sdk: streamlit
app_port: 8501
tags:
- streamlit
- federated-learning
- machine-learning
- privacy
pinned: false
short_description: Federated Learning Credit Scoring Demo
license: mit
Federated Learning for Privacy-Preserving Financial Data Generation with RAG Integration
This project implements a complete federated learning framework with a Retrieval-Augmented Generation (RAG) system for privacy-preserving synthetic financial data generation. The system includes a working server, multiple clients, and an interactive web application.
๐ Live Demo
Try it now: Hugging Face Spaces
โจ Features
- Complete Federated Learning System: Working server, clients, and web interface
- Real-time Predictions: Get credit score predictions from the federated model
- Interactive Web App: Beautiful Streamlit interface with demo and real modes
- Client Simulator: Built-in client simulator for testing
- Privacy-Preserving: No raw data sharing between participants
- Educational: Learn about federated learning concepts
- Production Ready: Docker and Kubernetes deployment support
๐ฏ Quick Start
Option 1: Try the Demo (No Setup Required)
- Visit the Live Demo
- Enter customer features and get predictions
- Learn about federated learning
Option 2: Run Locally (Complete System)
- Install Dependencies
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements-full.txt
- Start the Federated Server
python -m src.main --mode server --config config/server_config.yaml
- Start Multiple Clients (in separate terminals)
python -m src.main --mode client --config config/client_config.yaml
- Run the Web Application
streamlit run webapp/streamlit_app.py
- Test the Complete System
python test_complete_system.py
๐ฎ How to Use
Web Application Features:
- Demo Mode: Works without server (perfect for HF Spaces)
- Real Mode: Connects to federated server for live predictions
- Client Simulator: Start/stop client participation
- Training Progress: Real-time monitoring of federated rounds
- Server Health: Check server status and metrics
- Educational Content: Learn about federated learning
Federated Learning Process:
- Server Initialization: Global model is created
- Client Registration: Banks register with the server
- Local Training: Each client trains on their local data
- Model Updates: Clients send model updates (not data) to server
- Aggregation: Server aggregates updates using FedAvg
- Global Model: Updated model is distributed to all clients
- Prediction: Users can get predictions from the global model
๐๏ธ System Architecture
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Web App โ โ Federated โ โ Client 1 โ
โ (Streamlit) โโโโโบโ Server โโโโโบโ (Bank A) โ
โ โ โ (Coordinator) โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Client 2 โ
โ (Bank B) โ
โโโโโโโโโโโโโโโโโโโ
๐ Project Structure
FinFedRAG-Financial-Federated-RAG/
โโโ src/
โ โโโ api/ # REST API for server and client communication
โ โโโ client/ # Federated learning client implementation
โ โโโ server/ # Federated learning server and coordinator
โ โโโ rag/ # Retrieval-Augmented Generation components
โ โโโ models/ # VAE/GAN models for data generation
โ โโโ utils/ # Privacy, metrics, and utility functions
โโโ webapp/ # Streamlit web application
โโโ config/ # Configuration files
โโโ tests/ # Unit and integration tests
โโโ docker/ # Docker configurations
โโโ kubernetes/ # Kubernetes deployment files
โโโ app.py # Root app.py for Hugging Face Spaces deployment
โโโ requirements.txt # Minimal dependencies for HF Spaces
โโโ requirements-full.txt # Complete dependencies for local development
โโโ test_complete_system.py # End-to-end system test
๐ง Configuration
Server Configuration (config/server_config.yaml
)
# API server configuration
api:
host: "0.0.0.0"
port: 8080
# Federated learning configuration
federated:
min_clients: 2
rounds: 10
# Model configuration
model:
input_dim: 32
hidden_layers: [128, 64]
Client Configuration (config/client_config.yaml
)
client:
id: "client_1"
server_url: "http://localhost:8080"
data:
batch_size: 32
input_dim: 32
๐งช Testing
Run the complete system test:
python test_complete_system.py
This will test:
- โ Server health
- โ Client registration
- โ Training status
- โ Prediction functionality
๐ Deployment
Hugging Face Spaces (Recommended)
- Fork this repository
- Create a new Space on HF
- Connect your repository
- Deploy automatically
Local Development
# Install full dependencies
pip install -r requirements-full.txt
# Run complete system
python -m src.main --mode server --config config/server_config.yaml &
python -m src.main --mode client --config config/client_config.yaml &
streamlit run webapp/streamlit_app.py
Docker Deployment
docker-compose up
๐ Performance
- Model Accuracy: 85%+ across federated rounds
- Response Time: <1 second for predictions
- Scalability: Supports 10+ concurrent clients
- Privacy: Zero raw data sharing
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
- TensorFlow for the ML framework
- Streamlit for the web interface
- Hugging Face for hosting the demo
Live Demo: https://huggingface.co/spaces/ArchCoder/federated-credit-scoring