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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: SupportMind
|
| 3 |
+
emoji: π§
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# AetherFlow AI | SupportMind Engine π§
|
| 11 |
+
|
| 12 |
+
**Confidence-Gated Support Intelligence for B2B SaaS Customer Operations**
|
| 13 |
+
|
| 14 |
+
[](https://python.org)
|
| 15 |
+
[](https://fastapi.tiangolo.com)
|
| 16 |
+
[](https://huggingface.co/)
|
| 17 |
+
[](LICENSE)
|
| 18 |
+
[](https://github.com/asmitha2025/supportfloww/actions)
|
| 19 |
+
|
| 20 |
+
> *"B2B SaaS support teams don't lose customers because agents are slow. They lose them because AI acts with false confidence on ambiguous tickets β and nobody in the stack knows it happened."*
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## π― What is SupportMind?
|
| 25 |
+
|
| 26 |
+
SupportMind is a **confidence-gated, uncertainty-aware** ticket routing system that solves the most expensive unsolved problem in B2B SaaS support: **AI routing ambiguous tickets with false certainty**.
|
| 27 |
+
|
| 28 |
+
Unlike traditional AI solutions (Zoho Zia, Freshworks Freddy, Zendesk, and Salesforce Einstein) which use standard Softmax classifiers with no uncertainty output, SupportMind implements **Monte Carlo Dropout on DistilBERT**. This produces calibrated confidence scores and Shannon entropy, enabling a robust **three-tier decision gate**:
|
| 29 |
+
|
| 30 |
+
| Action | Confidence | Entropy | What Happens |
|
| 31 |
+
|--------|-----------|---------|--------------|
|
| 32 |
+
| **ROUTE** | β₯ 0.80 | β€ 0.35 | Auto-assign to the correct agent queue immediately. |
|
| 33 |
+
| **CLARIFY** | 0.55 β 0.80 | N/A | Ask 1 targeted, high-information-gain question to disambiguate. |
|
| 34 |
+
| **ESCALATE** | < 0.55 | N/A | Flag as complex; send to human triage immediately. |
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## ποΈ Detailed System Architecture
|
| 39 |
+
|
| 40 |
+
The SupportMind engine operates as a multi-stage pipeline designed to mimic human cognitive processes in support triage:
|
| 41 |
+
|
| 42 |
+
### Stage 1: Feature Extraction & Signal Detection
|
| 43 |
+
When a ticket arrives, it passes through an NLP feature extraction layer:
|
| 44 |
+
* **DistilBERT Embeddings**: Extracts deep semantic meaning (768-dimensional space).
|
| 45 |
+
* **VADER Sentiment Analysis**: Measures emotional tone (frustration, anger).
|
| 46 |
+
* **Regex & Heuristics**: Detects urgency flags ("ASAP", "System Down") and text complexity (Flesch-Kincaid).
|
| 47 |
+
|
| 48 |
+
### Stage 2: Confidence-Gated Router (MC Dropout)
|
| 49 |
+
Instead of a single forward pass, the DistilBERT classifier performs **20 stochastic forward passes**. By randomly deactivating neurons, it generates a distribution of predictions.
|
| 50 |
+
* **Low variance** across passes = High Confidence (Safe to Route)
|
| 51 |
+
* **High variance** across passes = High Epistemic Uncertainty (Needs Clarification or Escalation)
|
| 52 |
+
|
| 53 |
+
### Stage 3: The Intelligence Layer
|
| 54 |
+
* **SLA Breach Predictor (XGBoost)**: Evaluates the extracted features against current queue depth and historical SLA data to predict the probability of missing SLA targets (AUC 0.83).
|
| 55 |
+
* **Clarification Engine (Hybrid Architecture)**: When the router enters the CLARIFY tier, the engine uses a two-layer approach:
|
| 56 |
+
1. **LLM Layer (Groq LLaMA3-8B)**: Generates a ticket-specific question referencing the customer's exact words. Runs in ~100ms via Groq's optimized inference.
|
| 57 |
+
2. **Template Layer (fallback)**: If LLM is unavailable, selects from 47 pre-built templates scored by expected Shannon entropy reduction (information gain).
|
| 58 |
+
|
| 59 |
+
This design ensures the system never stops routing β LLM enhances quality when available, templates guarantee reliability always.
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## π Benchmark Results (Honest Dual-Evaluation)
|
| 64 |
+
|
| 65 |
+
> β οΈ **Benchmark Validity**: To ensure complete transparency, this project reports two sets of accuracy numbers:
|
| 66 |
+
> 1. **In-Distribution (Synthetic)**: The test set is generated from the same templates as the training data. The 100% accuracy here merely confirms the model successfully learned the training distribution without catastrophic forgetting.
|
| 67 |
+
> 2. **Out-of-Distribution (OOD)**: Evaluated against a separate, hand-crafted dataset of 96 real-world-style tickets (informal language, typos, missing context, and ambiguous edge-cases). **This is the honest estimate of the model's true generalization ability before fine-tuning on real production data.**
|
| 68 |
+
|
| 69 |
+
| Metric | In-Distribution *(synthetic)* | Out-of-Distribution *(hand-crafted)* |
|
| 70 |
+
|--------|------------------------------|--------------------------------------|
|
| 71 |
+
| Overall Routing Accuracy | **100.0%** | **57.3%** |
|
| 72 |
+
| Precision on Auto-Routed | **100.0%** | **100.0%** |
|
| 73 |
+
| Accuracy on Ambiguous Tickets | β | **30.0%** |
|
| 74 |
+
|
| 75 |
+
### Why the OOD Accuracy is "Low" (And Why That's Good)
|
| 76 |
+
On the OOD dataset, the model correctly routed the familiar tickets but struggled with the novel/ambiguous ones. **However, it only auto-routed 2.1% of the OOD tickets (achieving 100% precision on those).** It correctly flagged the remaining 97.9% as requiring clarification (51%) or escalation (47%).
|
| 77 |
+
|
| 78 |
+
Traditional Softmax classifiers would have blindly auto-routed these unfamiliar tickets, leading to costly misroutes. **SupportMind's confidence gate correctly prevented these misroutes.** This proves the architecture works as intendedβeven when the model weights are untrained for the specific domain, the system fails *safely*.
|
| 79 |
+
|
| 80 |
+
### Why This Matters for Zoho Desk + Zia
|
| 81 |
+
|
| 82 |
+
Zia's current field prediction uses standard Softmax β it returns a
|
| 83 |
+
category with no uncertainty signal. When Zia is wrong on an ambiguous
|
| 84 |
+
ticket, the agent only discovers the misroute after picking it up.
|
| 85 |
+
SupportMind's clarification gate catches this *before* routing,
|
| 86 |
+
reducing misroute cost from agent-time to one extra customer message.
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
+
|
| 90 |
+
## π Installation & Setup Guide
|
| 91 |
+
|
| 92 |
+
Follow these steps to set up the engine locally for development or demonstration.
|
| 93 |
+
|
| 94 |
+
### 1. Prerequisites
|
| 95 |
+
* Python 3.10+
|
| 96 |
+
* Git
|
| 97 |
+
* Virtual Environment tool (`venv`, `conda`, etc.)
|
| 98 |
+
|
| 99 |
+
### 2. Clone and Install
|
| 100 |
+
```bash
|
| 101 |
+
# Clone the repository
|
| 102 |
+
git clone https://github.com/asmitha2025/supportfloww.git
|
| 103 |
+
cd supportfloww
|
| 104 |
+
|
| 105 |
+
# Create and activate a virtual environment
|
| 106 |
+
python -m venv venv
|
| 107 |
+
source venv/bin/activate # On Windows use: venv\Scripts\activate
|
| 108 |
+
|
| 109 |
+
# Install dependencies
|
| 110 |
+
pip install -r requirements.txt
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
### 3. Running the System Locally
|
| 114 |
+
The core system is powered by FastAPI, serving both the REST API and the interactive dashboard.
|
| 115 |
+
|
| 116 |
+
```bash
|
| 117 |
+
# Start the FastAPI server
|
| 118 |
+
cd src
|
| 119 |
+
uvicorn api:app --host 0.0.0.0 --port 7860 --reload
|
| 120 |
+
```
|
| 121 |
+
Once the server is running, navigate to `http://localhost:7860/` in your web browser to access the **Live SupportMind Dashboard**.
|
| 122 |
+
|
| 123 |
+
---
|
| 124 |
+
|
| 125 |
+
## π§ Training the Models
|
| 126 |
+
|
| 127 |
+
If you wish to retrain the models from scratch using your own datasets:
|
| 128 |
+
|
| 129 |
+
1. **Prepare Data**: Place your raw ticket data in `data/raw/`.
|
| 130 |
+
2. **Train Router**:
|
| 131 |
+
```bash
|
| 132 |
+
python src/train_baseline.py # Trains the fallback TF-IDF + Logistic Regression model
|
| 133 |
+
python src/train_router.py # Trains the DistilBERT sequence classifier
|
| 134 |
+
```
|
| 135 |
+
*These scripts train the routing models and save them to `models/ticket_classifier/`.*
|
| 136 |
+
3. **Train SLA Predictor**:
|
| 137 |
+
```bash
|
| 138 |
+
python src/train_sla.py
|
| 139 |
+
```
|
| 140 |
+
*This trains the XGBoost model based on synthetic feature data and saves to `models/sla_predictor/`.*
|
| 141 |
+
4. **Evaluate System**:
|
| 142 |
+
```bash
|
| 143 |
+
python src/evaluate.py
|
| 144 |
+
```
|
| 145 |
+
*Generates benchmark metrics comparing MC Dropout against a standard Softmax baseline.*
|
| 146 |
+
|
| 147 |
+
---
|
| 148 |
+
|
| 149 |
+
## π‘ Comprehensive API Reference
|
| 150 |
+
|
| 151 |
+
SupportMind exposes a fully documented RESTful API. When the server is running, visit `http://localhost:7860/docs` for the interactive Swagger UI.
|
| 152 |
+
|
| 153 |
+
### `POST /route`
|
| 154 |
+
**Description**: Main routing endpoint. Processes a ticket and returns a 3-tier confidence-gated decision.
|
| 155 |
+
**Request Body**:
|
| 156 |
+
```json
|
| 157 |
+
{
|
| 158 |
+
"text": "The API endpoint /v2/export returns a 500 error when batch size exceeds 1000.",
|
| 159 |
+
"customer_id": "cust_8910"
|
| 160 |
+
}
|
| 161 |
+
```
|
| 162 |
+
**Response**:
|
| 163 |
+
```json
|
| 164 |
+
{
|
| 165 |
+
"action": "route",
|
| 166 |
+
"confidence": 0.942,
|
| 167 |
+
"entropy": 0.12,
|
| 168 |
+
"top_category": "technical_support",
|
| 169 |
+
"features": {
|
| 170 |
+
"sentiment_score": -0.25,
|
| 171 |
+
"urgency_flags": []
|
| 172 |
+
},
|
| 173 |
+
"sla_breach_probability": 0.15,
|
| 174 |
+
"latency_ms": 45.2
|
| 175 |
+
}
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
### `POST /clarify`
|
| 179 |
+
**Description**: Fetch the best clarification question based on model uncertainty.
|
| 180 |
+
### `POST /sla/predict`
|
| 181 |
+
**Description**: Predict SLA breach risk independently based on features.
|
| 182 |
+
### `POST /churn/signal`
|
| 183 |
+
**Description**: Extract churn signals from an array of historical thread texts.
|
| 184 |
+
### `GET /metrics`
|
| 185 |
+
**Description**: Live system health and routing distribution statistics.
|
| 186 |
+
|
| 187 |
+
---
|
| 188 |
+
|
| 189 |
+
## π³ Docker Deployment
|
| 190 |
+
|
| 191 |
+
For production deployments, package the application using Docker.
|
| 192 |
+
|
| 193 |
+
```bash
|
| 194 |
+
# Build the image
|
| 195 |
+
docker build -t supportmind .
|
| 196 |
+
|
| 197 |
+
# Run the container
|
| 198 |
+
docker run -d -p 7860:7860 --name supportmind-api supportmind
|
| 199 |
+
```
|
| 200 |
+
|
| 201 |
+
For advanced orchestration, we recommend extending the deployment with `docker-compose` to include Redis or RabbitMQ for asynchronous webhook processing.
|
| 202 |
+
|
| 203 |
+
---
|
| 204 |
+
|
| 205 |
+
## π Repository Structure
|
| 206 |
+
|
| 207 |
+
```text
|
| 208 |
+
supportmind/
|
| 209 |
+
βββ src/
|
| 210 |
+
β βββ api.py # FastAPI server & endpoints
|
| 211 |
+
β βββ confidence_router.py # DistilBERT MC Dropout logic
|
| 212 |
+
β βββ clarification_engine.py # Shannon entropy info-gain logic
|
| 213 |
+
β βββ sla_predictor.py # XGBoost SLA modeling
|
| 214 |
+
β βββ feature_extraction.py # NLP Feature engineering
|
| 215 |
+
β βββ churn_extractor.py # Sentiment & Churn analysis
|
| 216 |
+
β βββ train_router.py # DistilBERT training script
|
| 217 |
+
β βββ train_sla.py # XGBoost training script
|
| 218 |
+
β βββ evaluate.py # Evaluation & benchmark suite
|
| 219 |
+
βββ dashboard/
|
| 220 |
+
β βββ web/ # Interactive Frontend HTML/CSS/JS
|
| 221 |
+
β ββοΏ½οΏ½ index.html # Main UI
|
| 222 |
+
β βββ app.js # Frontend logic & API calls
|
| 223 |
+
β βββ style.css # Glassmorphism styling
|
| 224 |
+
βββ data/
|
| 225 |
+
β βββ clarification_bank.json # 47 Question templates
|
| 226 |
+
βββ models/ # Stored model weights (ignored in git)
|
| 227 |
+
βββ tests/ # Pytest suite
|
| 228 |
+
βββ Dockerfile # Containerization instructions
|
| 229 |
+
βββ requirements.txt # Python dependencies
|
| 230 |
+
βββ README.md # You are here
|
| 231 |
+
```
|
| 232 |
+
|
| 233 |
+
---
|
| 234 |
+
|
| 235 |
+
## π€ Author
|
| 236 |
+
|
| 237 |
+
**Asmitha** Β· BSc Data Science Β· 2026
|
| 238 |
+
|
| 239 |
+
Part of the three-project portfolio arc:
|
| 240 |
+
1. **OPTI-FAB** β Manufacturing edge AI with confidence gating
|
| 241 |
+
2. **IncidentMind** β RL-based incident response with ambiguity awareness
|
| 242 |
+
3. **SupportMind** β NLP ticket routing with MC Dropout uncertainty
|
| 243 |
+
|
| 244 |
+
> *"I spent the last year building systems that know what they don't know."*
|
| 245 |
+
|