File size: 3,962 Bytes
6f1b6f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
---
license: mit
language:
- en
tags:
- mental-health
- intent-classification
- fallback-model
pipeline_tag: text-classification
base_model: bert-base-uncased
---
# Intent Fallback Classifier (MindPadi)
This model serves as a **lightweight fallback intent classifier** for the MindPadi mental health assistant. It is designed to handle ambiguous or unrecognized user inputs when the primary intent classifier fails or yields low confidence. It helps maintain robustness in routing user messages to the appropriate modules in the chatbot backend.
## π§ Model Summary
- **Model Type:** Transformer-based classifier (BERT or DistilBERT variant)
- **Task:** Text classification (intent prediction)
- **Primary Purpose:** Backup routing in case of low-confidence from main classifier
- **Size:** Lightweight (optimized for low-latency inference)
- **Files:**
- `config.json`
- `pytorch_model.bin` or `model.safetensors`
- `tokenizer.json`, `vocab.txt`
## π§Ύ Intended Use
### βοΈ Use Cases
- Predicting fallback intents like `"unknown"`, `"help"`, `"clarify"`, etc.
- Activating clarification routines or default flows when the main intent classifier is uncertain
- Used in `app/chatbot/intent_classifier.py` as `fallback_model.predict(...)`
### π« Not Recommended For
- Serving as the primary intent classifier for all inputs
- Handling highly nuanced or multi-intent queries
- Clinical or domain-specific intent disambiguation
## ποΈββοΈ Training Details
- **Dataset:** Internal fallback samples and "unknown intent" examples
- Location: `training/datasets/fallback_intents.json`
- Includes mislabeled, ambiguous, or noisy utterances
- **Script:** `training/train_intent_classifier.py` (with fallback mode enabled)
- **Classes:**
- `"unknown"`
- `"clarify"`
- `"greeting"`
- `"exit"`
- `"irrelevant"`
- `"default"`
### Hyperparameters
- Model: `bert-base-uncased` or similar
- Batch Size: 16
- Learning Rate: 3e-5
- Epochs: 3β4
- Max Sequence Length: 128
## π Evaluation
- **Accuracy:** ~91% on test set of ambiguous intent queries
- **F1-Score (unknown intent):** 0.94
- **Confusion Matrix:** Available in `logs/fallback_intent_eval.png`
- **Performance Benchmark:** Inference latency < 50ms on CPU
## π¬ Example Usage
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "mindpadi/intent_fallback"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
inputs = tokenizer("I'm not sure what I need", return_tensors="pt")
outputs = model(**inputs)
predicted_class = torch.argmax(outputs.logits, dim=1)
print(predicted_class.item()) # e.g., 0 => "unknown"
````
## π§ Integration in MindPadi
This model is used as:
* A safety net in `app/chatbot/intent_classifier.py`
* Part of the router fallback in `app/chatbot/intent_router.py`
* Optional validation in LangGraph workflows for ambiguous queries
## β οΈ Limitations
* May overgeneralize rare intents as `"unknown"`
* Trained on a relatively small fallback dataset
* May require manual thresholds for activation in hybrid systems
* English-only
## π§ͺ Deployment (Optional)
For real-time inference via Hugging Face Inference Endpoints:
```python
import requests
api_url = "https://<your-endpoint>.hf.space"
headers = {"Authorization": f"Bearer <your-token>", "Content-Type": "application/json"}
payload = {"inputs": "I'm not sure what I need"}
response = requests.post(api_url, headers=headers, json=payload)
print(response.json())
```
## π License
MIT License β Open for personal and commercial use with attribution.
## π¬ Contact
* **Project:** [MindPadi AI](https://huggingface.co/mindpadi)
* **Team:** MindPadi Developers
* **Email:** \[[[email protected]](mailto:[email protected])]
* **GitHub:** \[[https://github.com/mindpadi](https://github.com/mindpadi)]
*Last updated: May 2025* |