Spaces:
Sleeping
Sleeping
metadata
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
- Clone or download this repository
- Install the required dependencies:
pip install -r requirements.txt
- Ensure the model files are available in the
./wash_cfm_classifier/directory
Usage
- Run the application:
python app.py
Open your web browser and navigate to
http://localhost:7860Enter WASH feedback text in the input box (e.g., "The water pump in our area has been broken for 3 days...")
Click "Submit" to get topic predictions with confidence scores
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:
- Water Supply - Confidence: 95.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