An open API service indexing awesome lists of open source software.

https://github.com/deypadma2020/banking-faq-rag-system

An end-to-end NLP-based Banking FAQ Intent Classification System using TF-IDF, Machine Learning, Ensemble Models, and Streamlit deployment for real-time banking query intent prediction and bulk CSV classification.
https://github.com/deypadma2020/banking-faq-rag-system

banking-applications nlp-machine-learning supervised-machine-learning

Last synced: about 2 months ago
JSON representation

An end-to-end NLP-based Banking FAQ Intent Classification System using TF-IDF, Machine Learning, Ensemble Models, and Streamlit deployment for real-time banking query intent prediction and bulk CSV classification.

Awesome Lists containing this project

README

          

# ๐Ÿฆ Banking FAQ Intent Classification System

An end-to-end NLP-based Banking FAQ Intent Classification System built using:

- TF-IDF Feature Engineering
- Machine Learning Models
- Ensemble Learning
- Streamlit Deployment
- Render Cloud Hosting

The project classifies banking-related customer queries into predefined intent categories such as:
- UPI Services
- Loans
- Debit Card
- Mutual Funds
- Account Services
- Financial Markets
- and more.

---

# ๐Ÿš€ Project Overview

This project demonstrates a complete NLP pipeline for banking query intent classification.

The system:
- preprocesses banking text data
- generates TF-IDF features
- trains multiple ML models
- evaluates model performance
- predicts intents for new queries
- supports bulk CSV prediction
- deploys as a Streamlit web application

---

# ๐Ÿ“Œ Features

## โœ… Single Question Prediction
Users can enter a banking question and instantly receive the predicted intent.

Example:
```text
How can I block my debit card?
```

Output:
```text
Debit Card Services
```

---

## โœ… Bulk CSV Prediction
Users can upload a CSV file containing multiple banking questions.

The application:
- predicts intents for all questions
- displays total predictions
- allows downloading the predicted CSV file

---

## โœ… NLP Pipeline
Implemented:
- text preprocessing
- regex cleaning
- TF-IDF vectorization
- word-level features
- character-level features

---

## โœ… Machine Learning Models
Models evaluated:
- Logistic Regression
- Naive Bayes
- Random Forest
- LinearSVC
- Ensemble Voting Classifier

---

## โœ… Best Performing Model
`LinearSVC` achieved the best overall performance for sparse TF-IDF text classification.

---

# ๐Ÿง  Technologies Used

- Python
- Pandas
- NumPy
- Scikit-learn
- SciPy
- Streamlit
- Pickle
- Render

---

# ๐Ÿ“‚ Project Structure

```text
BANKING-FAQ-RAG-SYSTEM/
โ”‚
โ”œโ”€โ”€ app/
โ”‚ โ””โ”€โ”€ streamlit_app.py
โ”‚
โ”œโ”€โ”€ data/
โ”‚ โ”œโ”€โ”€ raw_data/
โ”‚ โ”œโ”€โ”€ verification_data/
โ”‚ โ”œโ”€โ”€ banking_cleaned.csv
โ”‚ โ””โ”€โ”€ banking_processed.csv
โ”‚
โ”œโ”€โ”€ models/
โ”‚ โ”œโ”€โ”€ best_model.pkl
โ”‚ โ”œโ”€โ”€ word_vectorizer.pkl
โ”‚ โ”œโ”€โ”€ char_vectorizer.pkl
โ”‚ โ””โ”€โ”€ label_encoder.pkl
โ”‚
โ”œโ”€โ”€ notebooks/
โ”‚ โ”œโ”€โ”€ 01_eda.ipynb
โ”‚ โ”œโ”€โ”€ 02_preprocessing.ipynb
โ”‚ โ”œโ”€โ”€ 03_intent_classification.ipynb
โ”‚ โ””โ”€โ”€ 04_model_acc_verification.ipynb
โ”‚
โ”œโ”€โ”€ scripts/
โ”‚ โ”œโ”€โ”€ download_nlp_resources.py
โ”‚ โ”œโ”€โ”€ setup_nltk.py
โ”‚ โ””โ”€โ”€ setup_spacy.py
โ”‚
โ”œโ”€โ”€ test/
โ”‚ โ””โ”€โ”€ test.ipynb
โ”‚
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ render.yaml
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ runtime.txt
โ”œโ”€โ”€ setup.py
โ””โ”€โ”€ template.sh
```

---

# โš™๏ธ Installation

## 1๏ธโƒฃ Clone Repository

```bash
git clone https://github.com/your-username/Banking-FAQ-RAG-System.git
```

---

## 2๏ธโƒฃ Create Virtual Environment

```bash
python -m venv venv
```

Activate environment:

### Windows
```bash
venv\Scripts\activate
```

### Linux / Mac
```bash
source venv/bin/activate
```

---

## 3๏ธโƒฃ Install Requirements

```bash
pip install -r requirements.txt
```

---

# โ–ถ๏ธ Run Streamlit Application

```bash
streamlit run app/streamlit_app.py
```

---

# ๐ŸŒ Render Deployment

This project is deployment-ready for Render.

## Deployment Files Included

- `render.yaml`
- `runtime.txt`
- `requirements.txt`

---

# ๐Ÿ“Š Machine Learning Workflow

## 1. Data Preprocessing
- lowercasing
- punctuation removal
- whitespace normalization

---

## 2. Feature Engineering

### Word-Level TF-IDF
```python
ngram_range=(1,3)
```

### Character-Level TF-IDF
```python
analyzer='char_wb'
ngram_range=(3,5)
```

---

## 3. Sparse Feature Combination

```python
hstack([word_features, char_features])
```

---

## 4. Model Training

Trained Models:
- Logistic Regression
- Naive Bayes
- LinearSVC
- Ensemble Voting Classifier

---

# ๐Ÿ“ˆ Model Evaluation

Evaluation Metrics:
- Training Accuracy
- Testing Accuracy
- Cross Validation Accuracy
- Classification Report
- Overfitting Gap

---

# ๐Ÿงช Verification System

A separate verification dataset was used to:
- validate predictions
- calculate real-world accuracy
- generate classification reports

---

# ๐Ÿ“ฆ Model Artifacts

Saved using `pickle`:
- trained model
- vectorizers
- label encoder

These files are used directly during Streamlit inference.

---

# ๐Ÿ–ฅ๏ธ Streamlit Application Functionalities

## Single Query Prediction
Input:
```text
How to activate UPI?
```

Output:
```text
UPI Services
```

---

## Bulk CSV Prediction

Input CSV:
```csv
Question
How to activate UPI?
What is SWIFT transfer?
```

Output CSV:
```csv
Question,Predicted_Intent
How to activate UPI?,UPI Services
What is SWIFT transfer?,International Banking
```

---

# ๐Ÿ“Œ Future Improvements

Possible future enhancements:
- BERT / Transformer Models
- Semantic Search
- FAISS Vector Database
- Retrieval-Augmented Generation (RAG)
- Banking Chatbot Integration
- FastAPI Backend
- Docker Deployment

---

# ๐Ÿ‘จโ€๐Ÿ’ป Author

**Tuktuki Halder**

---

# ๐Ÿ“œ License

This project is licensed under the MIT License.

---

# โญ If You Like This Project

Please consider giving this repository a โญ on GitHub.