ibagur's picture
Complete history cleanup and model removal
cb2ce22
---
title: Cfm Topic Classifier
emoji: 😻
colorFrom: green
colorTo: green
sdk: gradio
sdk_version: 6.2.0
app_file: app.py
pinned: false
short_description: ModernBERT encoder model fine-tuned on CFM topics
---
# πŸ’§ WASH CFM Topic Classifier
A Gradio web application for classifying WASH (Water, Sanitation, and Hygiene) feedback into relevant topic categories using a fine-tuned ModernBERT model.
## Features
- **Topic Classification**: Automatically classifies WASH feedback into relevant topic categories
- **ModernBERT Integration**: Uses a fine-tuned ModernBERT-large model for accurate classification
- **Multi-Device Support**: Automatically detects and utilizes the best available device:
- Apple Silicon (MPS)
- NVIDIA GPU (CUDA)
- CPU fallback
- **Top-K Predictions**: Shows the top 2 most probable topics with confidence scores
- **Interactive Interface**: User-friendly Gradio interface with real-time classification
- **Input Validation**: Validates input and provides helpful error messages
## Installation
1. Clone or download this repository
2. Install the required dependencies:
```bash
pip install -r requirements.txt
```
3. Ensure the model files are available in the `./wash_cfm_classifier/` directory
## Usage
1. Run the application:
```bash
python app.py
```
2. Open your web browser and navigate to `http://localhost:7860`
3. Enter WASH feedback text in the input box (e.g., "The water pump in our area has been broken for 3 days...")
4. Click "Submit" to get topic predictions with confidence scores
5. Use the "Clear" button to reset the interface
## Requirements
- Python 3.7+
- torch>=2.0.0
- transformers>=4.30.0
- gradio>=4.0.0
## Technical Details
- **Model**: Fine-tuned ModernBERT-large for sequence classification
- **Framework**: Gradio for web interface
- **Device Support**: Automatic device detection (MPS/CUDA/CPU)
- **Caching**: LRU cache for model loading to improve performance
- **Output Format**: HTML-formatted results with confidence percentages
## Example Input/Output
**Input**: "The water pump in our area has been broken for 3 days and we need access to clean water"
**Output**:
1. **Water Supply** - Confidence: 95.2%
2. **Infrastructure** - Confidence: 87.1%
## Error Handling
- Validates empty or whitespace-only input
- Handles missing model files gracefully
- Provides detailed error messages for troubleshooting
## Configuration
- **Server Address**: `0.0.0.0` (all interfaces)
- **Port**: `7860`
- **Model Path**: `./wash_cfm_classifier/`
- **Top-K Predictions**: `2`
## License
UNICEF WASH Cluster CFM System
---
*Powered by ModernBERT-large | UNICEF WASH Cluster CFM System*