eeshanyaj commited on
Commit
0c73a18
Β·
1 Parent(s): eddc8a4

hf_space readme changed

Browse files
Files changed (1) hide show
  1. README.md +589 -21
README.md CHANGED
@@ -1,28 +1,596 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- title: QUESTRAG Backend
3
- emoji: 🏦
4
- colorFrom: blue
5
- colorTo: green
6
- sdk: docker
7
- pinned: false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ---
9
 
10
- # QUESTRAG Banking Chatbot Backend
 
 
11
 
12
- FastAPI backend for QUESTRAG - Banking RAG Chatbot with Reinforcement Learning.
13
 
14
- ## Features
15
- - πŸ€– RAG Pipeline with FAISS
16
- - 🧠 RL-based Policy Network
17
- - ⚑ Groq (Llama 3) + HuggingFace fallback
18
- - πŸ” JWT Authentication
19
- - πŸ“Š MongoDB Atlas
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- ## API Documentation
22
- Visit `/docs` for interactive Swagger UI.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- ## Endpoints
25
- - `POST /api/v1/auth/register` - Register new user
26
- - `POST /api/v1/auth/login` - Login
27
- - `POST /api/v1/chat/` - Send message (requires auth)
28
- - `GET /health` - Health check
 
1
+ # 🏦 QUESTRAG - Banking QUEries and Support system via Trained Reinforced RAG
2
+
3
+ [![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/)
4
+ [![FastAPI](https://img.shields.io/badge/FastAPI-0.104.1-green.svg)](https://fastapi.tiangolo.com/)
5
+ [![React](https://img.shields.io/badge/React-18.3.1-blue.svg)](https://reactjs.org/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![Deployed on HuggingFace](https://img.shields.io/badge/πŸ€—-HuggingFace%20Spaces-yellow)](https://huggingface.co/spaces/eeshanyaj/questrag-backend)
8
+
9
+ > An intelligent banking chatbot powered by **Retrieval-Augmented Generation (RAG)** and **Reinforcement Learning (RL)** to provide accurate, context-aware responses to Indian banking queries while optimizing token costs.
10
+
11
+ ---
12
+
13
+ ## πŸ“‹ Table of Contents
14
+ - [Overview](#overview)
15
+ - [Key Features](#key-features)
16
+ - [System Architecture](#system-architecture)
17
+ - [Technology Stack](#technology-stack)
18
+ - [Installation](#installation)
19
+ - [Configuration](#configuration)
20
+ - [Usage](#usage)
21
+ - [Project Structure](#project-structure)
22
+ - [Datasets](#datasets)
23
+ - [Performance Metrics](#performance-metrics)
24
+ - [API Documentation](#api-documentation)
25
+ - [Deployment](#deployment)
26
+ - [Contributing](#contributing)
27
+ - [License](#license)
28
+ - [Acknowledgments](#acknowledgments)
29
+ - [Contact](#contact)
30
+ - [Status](#status)
31
+ - [Links](#links)
32
+
33
+ ---
34
+
35
+ ## 🎯 Overview
36
+ QUESTRAG is an **advanced banking chatbot** designed to revolutionize customer support in the Indian banking sector. By combining **Retrieval-Augmented Generation (RAG)** with **Reinforcement Learning (RL)**, the system intelligently decides when to fetch external context from a knowledge base and when to respond directly, **reducing token costs by up to 31%** while maintaining high accuracy.
37
+
38
+ ### Problem Statement
39
+ Existing banking chatbots suffer from:
40
+ - ❌ Limited response flexibility (rigid, rule-based systems)
41
+ - ❌ Poor handling of informal/real-world queries
42
+ - ❌ Lack of contextual understanding
43
+ - ❌ High operational costs due to inefficient token usage
44
+ - ❌ Low user satisfaction and trust
45
+
46
+ ### Solution
47
+ QUESTRAG addresses these challenges through:
48
+ - βœ… **Domain-specific RAG** trained on 19,000+ banking queries / support data
49
+ - βœ… **RL-optimized policy network** (BERT-based) for smart context-fetching decisions
50
+ - βœ… **Fine-tuned retriever model** (E5-base-v2) using InfoNCE + Triplet Loss
51
+ - βœ… **Groq LLM with HuggingFace fallback** for reliable, fast responses
52
+ - βœ… **Full-stack web application** with modern UI/UX and JWT authentication
53
+
54
+ ---
55
+
56
+ ## 🌟 Key Features
57
+
58
+ ### πŸ€– Intelligent RAG Pipeline
59
+ - **FAISS-powered retrieval** for fast similarity search across 19,352 documents
60
+ - **Fine-tuned embedding model** (`e5-base-v2`) trained on English + Hinglish paraphrases
61
+ - **Context-aware response generation** using Llama 3 models (8B & 70B) via Groq
62
+
63
+ ### 🧠 Reinforcement Learning System
64
+ - **BERT-based policy network** (`bert-base-uncased`) for FETCH/NO_FETCH decisions
65
+ - **Reward-driven optimization** (+2.0 accurate, +0.5 needed fetch, -0.5 incorrect)
66
+ - **31% token cost reduction** via optimized retrieval
67
+
68
+ ### 🎨 Modern Web Interface
69
+ - **React 18 + Vite** with Tailwind CSS
70
+ - **Real-time chat**, conversation history, JWT authentication
71
+ - **Responsive design** for desktop and mobile
72
+
73
+ ### πŸ” Enterprise-Ready Backend
74
+ - **FastAPI + MongoDB Atlas** for scalable async operations
75
+ - **JWT authentication** with secure password hashing (bcrypt)
76
+ - **Multi-provider LLM** (Groq β†’ HuggingFace automatic fallback)
77
+ - **Deployed on HuggingFace Spaces** with Docker containerization
78
+
79
+ ---
80
+
81
+ ## πŸ—οΈ System Architecture
82
+
83
+ <p align="center">
84
+ <img src="./assets/system.png" alt="System Architecture Diagram" width="750"/>
85
+ </p>
86
+
87
+ ### πŸ”„ Workflow
88
+ 1. **User Query** β†’ FastAPI receives query via REST API
89
+ 2. **Policy Decision** β†’ BERT-based RL model decides FETCH or NO_FETCH
90
+ 3. **Conditional Retrieval** β†’ If FETCH β†’ Retrieve top-5 docs from FAISS using E5-base-v2
91
+ 4. **Response Generation** β†’ Llama 3 (via Groq) generates final answer
92
+ 5. **Evaluation & Logging** β†’ Logged in MongoDB + reward-based model update
93
+
94
+ ---
95
+
96
+ ## πŸ”„ Sequence Diagram
97
+
98
+ <p align="center">
99
+ <img src="./assets/sequence_diagram.png" alt="Sequence Diagram" width="750"/>
100
+ </p>
101
+
102
+ ---
103
+
104
+ ## πŸ› οΈ Technology Stack
105
+
106
+ ### **Frontend**
107
+ - βš›οΈ React 18.3.1 + Vite 5.4.2
108
+ - 🎨 Tailwind CSS 3.4.1
109
+ - πŸ”„ React Context API + Axios + React Router DOM
110
+
111
+ ### **Backend**
112
+ - πŸš€ FastAPI 0.104.1
113
+ - πŸ—„οΈ MongoDB Atlas + Motor (async driver)
114
+ - πŸ”‘ JWT Auth + Passlib (bcrypt)
115
+ - πŸ€– PyTorch 2.9.1, Transformers 4.57, FAISS 1.13.0
116
+ - πŸ’¬ Groq (Llama 3.1 8B Instant / Llama 3.3 70B Versatile)
117
+ - 🎯 Sentence Transformers 5.1.2
118
+
119
+ ### **Machine Learning**
120
+ - 🧠 **Policy Network**: BERT-base-uncased (trained with RL)
121
+ - πŸ” **Retriever**: E5-base-v2 (fine-tuned with InfoNCE + Triplet Loss)
122
+ - πŸ“Š **Vector Store**: FAISS (19,352 documents)
123
+
124
+ ### **Deployment**
125
+ - 🐳 Docker (HuggingFace Spaces)
126
+ - πŸ€— HuggingFace Hub (model storage)
127
+ - ☁️ MongoDB Atlas (cloud database)
128
+ - 🌐 Python 3.12 + uvicorn
129
+
130
+ ---
131
+
132
+ ## βš™οΈ Installation
133
+
134
+ ### 🧩 Prerequisites
135
+ - Python 3.12+
136
+ - Node.js 18+
137
+ - MongoDB Atlas account (or local MongoDB 6.0+)
138
+ - Groq API key (or HuggingFace token)
139
+
140
+ ### πŸ”§ Backend Setup (Local Development)
141
+
142
+ ```bash
143
+ # Navigate to backend
144
+ cd backend
145
+
146
+ # Create virtual environment
147
+ python -m venv venv
148
+
149
+ # Activate it
150
+ source venv/bin/activate # Linux/Mac
151
+ venv\Scripts\activate # Windows
152
+
153
+ # Install dependencies
154
+ pip install -r requirements.txt
155
+
156
+ # Create environment file
157
+ cp .env.example .env
158
+ # Edit .env with your credentials (see Configuration section)
159
+
160
+ # Build FAISS index (one-time setup)
161
+ python build_faiss_index.py
162
+
163
+ # Start backend server
164
+ uvicorn app.main:app --reload --port 8000
165
+ ```
166
+
167
+ ### πŸ’» Frontend Setup
168
+
169
+ ```bash
170
+ # Navigate to frontend
171
+ cd frontend
172
+
173
+ # Install dependencies
174
+ npm install
175
+
176
+ # Create environment file
177
+ cp .env.example .env
178
+ # Update VITE_API_URL to point to your backend
179
+
180
+ # Start dev server
181
+ npm run dev
182
+ ```
183
+
184
  ---
185
+
186
+ ## βš™οΈ Configuration
187
+
188
+ ### πŸ”‘ Backend `.env` (Key Parameters)
189
+
190
+ | **Category** | **Key** | **Example / Description** |
191
+ |-------------------|----------------------------------|--------------------------------------------------|
192
+ | Environment | `ENVIRONMENT` | `development` or `production` |
193
+ | MongoDB | `MONGODB_URI` | `mongodb+srv://user:[email protected]/` |
194
+ | Authentication | `SECRET_KEY` | Generate with `python -c "import secrets; print(secrets.token_urlsafe(32))"` |
195
+ | | `ALGORITHM` | `HS256` |
196
+ | | `ACCESS_TOKEN_EXPIRE_MINUTES` | `1440` (24 hours) |
197
+ | Groq API | `GROQ_API_KEY_1` | Your primary Groq API key |
198
+ | | `GROQ_API_KEY_2` | Secondary key (optional) |
199
+ | | `GROQ_API_KEY_3` | Tertiary key (optional) |
200
+ | | `GROQ_CHAT_MODEL` | `llama-3.1-8b-instant` |
201
+ | | `GROQ_EVAL_MODEL` | `llama-3.3-70b-versatile` |
202
+ | HuggingFace | `HF_TOKEN_1` | HuggingFace token (fallback LLM) |
203
+ | | `HF_MODEL_REPO` | `eeshanyaj/questrag_models` (for model download) |
204
+ | Model Paths | `POLICY_MODEL_PATH` | `app/models/best_policy_model.pth` |
205
+ | | `RETRIEVER_MODEL_PATH` | `app/models/best_retriever_model.pth` |
206
+ | | `FAISS_INDEX_PATH` | `app/models/faiss_index.pkl` |
207
+ | | `KB_PATH` | `app/data/final_knowledge_base.jsonl` |
208
+ | Device | `DEVICE` | `cpu` or `cuda` |
209
+ | RAG Params | `TOP_K` | `5` (number of documents to retrieve) |
210
+ | | `SIMILARITY_THRESHOLD` | `0.5` (minimum similarity score) |
211
+ | Policy Network | `CONFIDENCE_THRESHOLD` | `0.7` (policy decision confidence) |
212
+ | CORS | `ALLOWED_ORIGINS` | `http://localhost:5173` or `*` |
213
+
214
+ ### 🌐 Frontend `.env`
215
+
216
+ ```bash
217
+ # Local development
218
+ VITE_API_URL=http://localhost:8000
219
+
220
+ # Production (HuggingFace Spaces)
221
+ VITE_API_URL=https://eeshanyaj-questrag-backend.hf.space
222
+ ```
223
+
224
  ---
225
 
226
+ ## πŸš€ Usage
227
+
228
+ ### πŸ–₯️ Local Development
229
 
230
+ #### Start Backend Server
231
 
232
+ ```bash
233
+ cd backend
234
+ source venv/bin/activate # or venv\Scripts\activate
235
+ uvicorn app.main:app --reload --port 8000
236
+ ```
237
+
238
+ - **Backend**: http://localhost:8000
239
+ - **API Docs**: http://localhost:8000/docs
240
+ - **Health Check**: http://localhost:8000/health
241
+
242
+ #### Start Frontend Dev Server
243
+
244
+ ```bash
245
+ cd frontend
246
+ npm run dev
247
+ ```
248
+
249
+ - **Frontend**: http://localhost:5173
250
+
251
+ ### 🌐 Production (HuggingFace Spaces)
252
+
253
+ **Backend API**:
254
+ - **Base URL**: https://eeshanyaj-questrag-backend.hf.space
255
+ - **API Docs**: https://eeshanyaj-questrag-backend.hf.space/docs
256
+ - **Health Check**: https://eeshanyaj-questrag-backend.hf.space/health
257
+
258
+ **Frontend** (Coming Soon):
259
+ - Will be deployed on Vercel/Netlify
260
+
261
+ ---
262
+
263
+ ## πŸ“ Project Structure
264
+
265
+ ```
266
+ questrag/
267
+ β”‚
268
+ β”œβ”€β”€ backend/
269
+ β”‚ β”œβ”€β”€ app/
270
+ β”‚ β”‚ β”œβ”€β”€ api/v1/
271
+ β”‚ β”‚ β”‚ β”œβ”€β”€ auth.py # Auth endpoints (register, login)
272
+ β”‚ β”‚ β”‚ └── chat.py # Chat endpoints
273
+ β”‚ β”‚ β”œβ”€β”€ core/
274
+ β”‚ β”‚ β”‚ β”œβ”€β”€ llm_manager.py # Groq + HF LLM orchestration
275
+ β”‚ β”‚ β”‚ └── security.py # JWT & password hashing
276
+ β”‚ β”‚ β”œβ”€β”€ ml/
277
+ β”‚ β”‚ β”‚ β”œβ”€β”€ policy_network.py # RL Policy model (BERT)
278
+ β”‚ β”‚ β”‚ └── retriever.py # E5-base-v2 retriever
279
+ β”‚ β”‚ β”œβ”€β”€ db/
280
+ β”‚ β”‚ β”‚ β”œβ”€β”€ mongodb.py # MongoDB connection
281
+ β”‚ β”‚ β”‚ └── repositories/ # User & conversation repos
282
+ β”‚ β”‚ β”œβ”€β”€ services/
283
+ β”‚ β”‚ β”‚ └── chat_service.py # Orchestration logic
284
+ β”‚ β”‚ β”œβ”€β”€ models/
285
+ β”‚ β”‚ β”‚ β”œβ”€β”€ best_policy_model.pth # Trained policy network
286
+ β”‚ β”‚ β”‚ β”œβ”€β”€ best_retriever_model.pth # Fine-tuned retriever
287
+ β”‚ β”‚ β”‚ └── faiss_index.pkl # FAISS vector store
288
+ β”‚ β”‚ β”œβ”€β”€ data/
289
+ β”‚ β”‚ β”‚ └── final_knowledge_base.jsonl # 19,352 Q&A pairs
290
+ β”‚ β”‚ β”œβ”€β”€ config.py # Settings & env vars
291
+ β”‚ β”‚ └── main.py # FastAPI app entry point
292
+ β”‚ β”œβ”€β”€ Dockerfile # Docker config for HF Spaces
293
+ β”‚ β”œβ”€β”€ requirements.txt
294
+ β”‚ └── .env.example
295
+ β”‚
296
+ └── frontend/
297
+ β”œβ”€β”€ src/
298
+ β”‚ β”œβ”€β”€ components/ # UI Components
299
+ β”‚ β”œβ”€β”€ context/ # Auth Context
300
+ β”‚ β”œβ”€β”€ pages/ # Login, Register, Chat
301
+ β”‚ β”œβ”€β”€ services/api.js # Axios Client
302
+ β”‚ β”œβ”€β”€ App.jsx
303
+ β”‚ └── main.jsx
304
+ β”œβ”€β”€ package.json
305
+ └── .env
306
+ ```
307
+
308
+ ---
309
+
310
+ ## πŸ“Š Datasets
311
+
312
+ ### 1. Final Knowledge Base
313
+ - **Size**: 19,352 question-answer pairs
314
+ - **Categories**: 15 banking categories
315
+ - **Intents**: 22 unique intents (ATM, CARD, LOAN, ACCOUNT, etc.)
316
+ - **Source**: Combination of:
317
+ - Bitext Retail Banking Dataset (Hugging Face)
318
+ - RetailBanking-Conversations Dataset
319
+ - Manually curated FAQs from SBI, ICICI, HDFC, Yes Bank, Axis Bank
320
+
321
+ ### 2. Retriever Training Dataset
322
+ - **Size**: 11,655 paraphrases
323
+ - **Source**: 1,665 unique FAQs from knowledge base
324
+ - **Paraphrases per FAQ**:
325
+ - 4 English paraphrases
326
+ - 2 Hinglish paraphrases
327
+ - Original FAQ
328
+ - **Training**: InfoNCE Loss + Triplet Loss with E5-base-v2
329
+
330
+ ### 3. Policy Network Training Dataset
331
+ - **Size**: 182 queries from 6 chat sessions
332
+ - **Format**: (state, action, reward) tuples
333
+ - **Actions**: FETCH (1) or NO_FETCH (0)
334
+ - **Rewards**: +2.0 (correct), +0.5 (needed fetch), -0.5 (incorrect)
335
+
336
+ ---
337
 
338
+ ## πŸ“ˆ Performance Metrics
339
+
340
+ *Coming soon: Detailed performance metrics including accuracy, response time, token cost reduction, and user satisfaction scores.*
341
+
342
+ ---
343
+
344
+ ## πŸ“š API Documentation
345
+
346
+ ### Authentication
347
+
348
+ #### Register
349
+
350
+ ```http
351
+ POST /api/v1/auth/register
352
+ Content-Type: application/json
353
+
354
+ {
355
+ "username": "john_doe",
356
+ "email": "[email protected]",
357
+ "password": "securepassword123"
358
+ }
359
+ ```
360
+
361
+ **Response:**
362
+
363
+ ```json
364
+ {
365
+ "message": "User registered successfully",
366
+ "user_id": "507f1f77bcf86cd799439011"
367
+ }
368
+ ```
369
+
370
+ #### Login
371
+
372
+ ```http
373
+ POST /api/v1/auth/login
374
+ Content-Type: application/json
375
+
376
+ {
377
+ "username": "john_doe",
378
+ "password": "securepassword123"
379
+ }
380
+ ```
381
+
382
+ **Response:**
383
+
384
+ ```json
385
+ {
386
+ "access_token": "eyJhbGciOiJIUzI1NiIs...",
387
+ "token_type": "bearer"
388
+ }
389
+ ```
390
+
391
+ ---
392
+
393
+ ### Chat
394
+
395
+ #### Send Message
396
+
397
+ ```http
398
+ POST /api/v1/chat/
399
+ Authorization: Bearer <token>
400
+ Content-Type: application/json
401
+
402
+ {
403
+ "query": "What are the interest rates for home loans?",
404
+ "conversation_id": "optional-session-id"
405
+ }
406
+ ```
407
+
408
+ **Response:**
409
+
410
+ ```json
411
+ {
412
+ "response": "Current home loan interest rates range from 8.5% to 9.5% per annum...",
413
+ "conversation_id": "abc123",
414
+ "metadata": {
415
+ "policy_action": "FETCH",
416
+ "retrieval_score": 0.89,
417
+ "documents_retrieved": 5,
418
+ "llm_provider": "groq"
419
+ }
420
+ }
421
+ ```
422
+
423
+ #### Get Conversation History
424
+
425
+ ```http
426
+ GET /api/v1/chat/conversations/{conversation_id}
427
+ Authorization: Bearer <token>
428
+ ```
429
+
430
+ **Response:**
431
+
432
+ ```json
433
+ {
434
+ "conversation_id": "abc123",
435
+ "messages": [
436
+ {
437
+ "role": "user",
438
+ "content": "What are the interest rates?",
439
+ "timestamp": "2025-11-28T10:30:00Z"
440
+ },
441
+ {
442
+ "role": "assistant",
443
+ "content": "Current rates are...",
444
+ "timestamp": "2025-11-28T10:30:05Z",
445
+ "metadata": {
446
+ "policy_action": "FETCH"
447
+ }
448
+ }
449
+ ]
450
+ }
451
+ ```
452
+
453
+ #### List All Conversations
454
+
455
+ ```http
456
+ GET /api/v1/chat/conversations
457
+ Authorization: Bearer <token>
458
+ ```
459
+
460
+ #### Delete Conversation
461
+
462
+ ```http
463
+ DELETE /api/v1/chat/conversation/{conversation_id}
464
+ Authorization: Bearer <token>
465
+ ```
466
+
467
+ ---
468
+
469
+ ## πŸš€ Deployment
470
+
471
+ ### HuggingFace Spaces (Backend)
472
+
473
+ The backend is deployed on HuggingFace Spaces using Docker:
474
+
475
+ 1. **Models are stored** on HuggingFace Hub: `eeshanyaj/questrag_models`
476
+ 2. **On first startup**, models are automatically downloaded from HF Hub
477
+ 3. **Docker container** runs FastAPI with uvicorn on port 7860
478
+ 4. **Environment secrets** are securely managed in HF Space settings
479
+
480
+ **Deployment Steps:**
481
+
482
+ ```bash
483
+ # 1. Upload models to HuggingFace Hub
484
+ huggingface-cli upload eeshanyaj/questrag_models \
485
+ app/models/best_policy_model.pth \
486
+ models/best_policy_model.pth
487
+
488
+ # 2. Push backend code to HF Space
489
+ git remote add space https://huggingface.co/spaces/eeshanyaj/questrag-backend
490
+ git push space main
491
+
492
+ # 3. Add environment secrets in HF Space Settings
493
+ # (MongoDB URI, Groq keys, JWT secret, etc.)
494
+ ```
495
+
496
+ ### Frontend Deployment (Vercel/Netlify)
497
+
498
+ ```bash
499
+ # Build for production
500
+ npm run build
501
+
502
+ # Deploy to Vercel
503
+ vercel --prod
504
+
505
+ # Update .env.production with backend URL
506
+ VITE_API_URL=https://eeshanyaj-questrag-backend.hf.space
507
+ ```
508
+
509
+ ---
510
+
511
+ ## 🀝 Contributing
512
+
513
+ Contributions are welcome! Please follow these steps:
514
+
515
+ 1. Fork the repository
516
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
517
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
518
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
519
+ 5. Open a Pull Request
520
+
521
+ ### Development Guidelines
522
+ - Follow PEP 8 for Python code
523
+ - Use ESLint + Prettier for JavaScript/React
524
+ - Write comprehensive docstrings and comments
525
+ - Add unit tests for new features
526
+ - Update documentation accordingly
527
+
528
+ ---
529
+
530
+ ## πŸ“„ License
531
+
532
+ MIT License β€” see [LICENSE](LICENSE)
533
+
534
+ ---
535
+
536
+ ## πŸ™ Acknowledgments
537
+
538
+ ### Research Inspiration
539
+ - **Main Paper**: "Optimizing Retrieval Augmented Generation for Domain-Specific Chatbots with Reinforcement Learning" (AAAI 2024)
540
+ - **Additional References**:
541
+ - "Evaluating BERT-based Rewards for Question Generation with RL"
542
+ - "Self-Reasoning for Retrieval-Augmented Language Models"
543
+
544
+ ### Open Source Resources
545
+ - [RL-Self-Improving-RAG](https://github.com/subrata-samanta/RL-Self-Improving-RAG)
546
+ - [ARENA](https://github.com/ren258/ARENA)
547
+ - [RAGTechniques](https://github.com/NirDiamant/RAGTechniques)
548
+ - [Financial-RAG-From-Scratch](https://github.com/cse-amarjeet/Financial-RAG-From-Scratch)
549
+
550
+ ### Datasets
551
+ - [Bitext Retail Banking Dataset](https://huggingface.co/datasets/bitext/Bitext-retail-banking-llm-chatbot-training-dataset)
552
+ - [RetailBanking-Conversations](https://huggingface.co/datasets/oopere/RetailBanking-Conversations)
553
+
554
+ ### Technologies
555
+ - [FastAPI](https://fastapi.tiangolo.com/)
556
+ - [React](https://reactjs.org/)
557
+ - [HuggingFace](https://huggingface.co/)
558
+ - [Groq](https://groq.com/)
559
+ - [MongoDB Atlas](https://www.mongodb.com/cloud/atlas)
560
+
561
+ ---
562
+
563
+ ## πŸ“ž Contact
564
+
565
+ **Eeshanya Amit Joshi**
566
+ πŸ“§ [Email](mailto:[email protected])
567
+ πŸ’Ό [LinkedIn](https://www.linkedin.com/in/eeshanyajoshi/)
568
+
569
+ ---
570
+
571
+ ## πŸ“ˆ Status
572
+
573
+ ### βœ… **Backend Deployed & Live!**
574
+ - πŸš€ Backend API running on [HuggingFace Spaces](https://eeshanyaj-questrag-backend.hf.space)
575
+ - πŸ“š API Documentation available at [/docs](https://eeshanyaj-questrag-backend.hf.space/docs)
576
+ - πŸ’š Health status: [Check here](https://eeshanyaj-questrag-backend.hf.space/health)
577
+
578
+ ### 🚧 **Frontend Deployment - Coming Soon!**
579
+ - Will be deployed on Vercel/Netlify
580
+ - Stay tuned for full application link! ❀️
581
+
582
+ ---
583
+
584
+ ## πŸ”— Links
585
+
586
+ - **Live Backend API:** https://eeshanyaj-questrag-backend.hf.space
587
+ - **API Documentation:** https://eeshanyaj-questrag-backend.hf.space/docs
588
+ - **Health Check:** https://eeshanyaj-questrag-backend.hf.space/health
589
+ - **HuggingFace Space:** https://huggingface.co/spaces/eeshanyaj/questrag-backend
590
+ - **Model Repository:** https://huggingface.co/eeshanyaj/questrag_models
591
+ - **Research Paper:** [AAAI 2024 Workshop](https://arxiv.org/abs/2401.06800)
592
+
593
+ ---
594
 
595
+ <p align="center">✨ Made with ❀️ for the Banking Industry ✨</p>
596
+ <p align="center">Powered by HuggingFace πŸ€—| Groq ⚑| MongoDB πŸƒ| Docker 🐳| </p>