Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Banking FAQ Chatbot (RAG-Based)

A Retrieval-Augmented Generation (RAG) chatbot that answers customer questions about banking products, policies, and services using internal bank documents as the knowledge source.

Python LangChain FastAPI ChromaDB

Overview

Banks receive thousands of repetitive customer inquiries daily about interest rates, account types, fees, and regulations. This RAG chatbot retrieves relevant information from internal bank documents and generates accurate, sourced answers — reducing call center load while ensuring compliance-safe responses.

Key Features

  • Document Ingestion: Processes PDF, DOCX, and TXT banking documents
  • Semantic Search: ChromaDB vector store with sentence-transformer embeddings
  • Grounded Answers: Every response includes source document references
  • Hallucination Guard: Built-in checks to prevent fabricated information
  • Multi-Turn Chat: Maintains conversation context for follow-up questions
  • Turkish Language Support: Optimized for Turkish banking terminology
  • REST API: FastAPI endpoint for integration with banking channels

Architecture

Customer Query
     │
     ▼
┌─────────────┐     ┌──────────────┐     ┌─────────────┐
│  Query      │────▶│  Vector      │────▶│  LLM        │
│  Processing │     │  Search      │     │  Generation  │
│  (Embedding)│     │  (ChromaDB)  │     │  (Context +  │
│             │     │  Top-K Docs  │     │   Sources)   │
└─────────────┘     └──────────────┘     └─────────────┘
                                                │
                                                ▼
                                         Grounded Answer
                                         with Sources

Project Structure

banking-chatbot-rag/
├── data/
│   └── sample_docs/              # Sample banking documents
│       ├── account_types.txt
│       ├── credit_policies.txt
│       ├── fee_schedule.txt
│       └── faq.txt
├── src/
│   ├── __init__.py               # Package init
│   ├── ingest.py                 # Document loader & chunker
│   ├── retriever.py              # Vector store & semantic search
│   ├── chatbot.py                # Main chatbot orchestrator
│   ├── guardrails.py             # Hallucination prevention & compliance
│   └── api.py                    # FastAPI chat endpoint
├── tests/
│   └── test_pipeline.py          # Pipeline integration tests
├── docs/
├── requirements.txt
├── Dockerfile
└── README.md

Quick Start

1. Install

git clone https://github.com/metehanulusoy/banking-chatbot-rag.git
cd banking-chatbot-rag
pip install -r requirements.txt

2. Ingest Documents

python src/ingest.py --docs-dir data/sample_docs

3. Run the API

export OPENAI_API_KEY=your_key  # or use local model
uvicorn src.api:app --reload

4. Chat

curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "Vadesiz hesap açmak için ne gerekiyor?", "session_id": "user_123"}'

Response:

{
  "answer": "Vadesiz hesap açmak için kimlik belgesi (TC kimlik kartı veya pasaport) ve adınıza kayıtlı bir telefon numarası yeterlidir. 18 yaş üstü tüm Türkiye Cumhuriyeti vatandaşları herhangi bir şubeye gelerek veya mobil uygulama üzerinden vadesiz hesap açabilir. Hesap açılışında herhangi bir ücret alınmamaktadır.",
  "sources": [
    {"document": "account_types.txt", "chunk": "Vadesiz Mevduat Hesabı", "relevance": 0.94},
    {"document": "fee_schedule.txt", "chunk": "Hesap Açılış Ücretleri", "relevance": 0.87}
  ],
  "confidence": 0.91,
  "session_id": "user_123"
}

Supported Question Types

  • Account opening requirements and types
  • Interest rates and deposit conditions
  • Fee schedules and commissions
  • Credit card features and limits
  • Loan application requirements
  • SWIFT/EFT/Havale procedures
  • ATM and branch information
  • Digital banking features

Guardrails

The chatbot implements several safety measures for banking compliance:

  1. Source Grounding: Only answers using retrieved documents, never invents information
  2. Confidence Scoring: Returns confidence level; low-confidence answers trigger "Please contact a representative"
  3. Scope Detection: Detects out-of-scope questions (investment advice, legal matters) and redirects
  4. PII Protection: Does not store or reveal customer personal information
  5. Regulatory Compliance: Adds disclaimers for interest rate and fee information

Tech Stack

  • LLM: OpenAI GPT-4 / Local (Ollama) compatible
  • Embeddings: sentence-transformers (multilingual)
  • Vector Store: ChromaDB
  • Framework: LangChain
  • API: FastAPI
  • Document Processing: PyPDF2, python-docx

License

MIT License

Author

Metehan Ulusoy - Computer Engineering Student

About

RAG-based banking FAQ chatbot — ChromaDB, LangChain, Turkish NLP, guardrails, BDDK-compliant disclaimer system

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages