Spaces:
Sleeping
Sleeping
| # Desklib Pre-trained Model Integration | |
| ## β What Was Added | |
| Instead of training your own model (which hits PyTorch MPS bugs on M2 Mac), the project now uses **Desklib's pre-trained AI text detector** - a state-of-the-art model that leads the RAID Benchmark. | |
| ## π― Model Details | |
| - **Model**: `desklib/ai-text-detector-v1.01` | |
| - **Base**: microsoft/deberta-v3-large | |
| - **Architecture**: DeBERTa with mean pooling + classifier head | |
| - **Performance**: Top performer on RAID benchmark | |
| - **No Training Needed**: Pre-trained and ready to use! | |
| ## π Changes Made | |
| ### 1. `ai_text_detector/models.py` | |
| - β Added `DesklibAIDetectionModel` class (custom architecture) | |
| - β Updated `DetectorModel` to support Desklib model | |
| - β Added `predict()` method for easy inference | |
| - β Automatic CPU placement for macOS compatibility | |
| ### 2. `gradio_app.py` | |
| - β Now uses Desklib model by default (instead of RoBERTa-base) | |
| - β Updated detection logic to use new `predict()` method | |
| - β Better error handling | |
| ## π Usage | |
| ### In Gradio App | |
| ```bash | |
| python gradio_app.py | |
| ``` | |
| The app will automatically use the Desklib model! | |
| ### In Your Code | |
| ```python | |
| from ai_text_detector.models import DetectorModel | |
| # Load Desklib model | |
| model = DetectorModel("desklib/ai-text-detector-v1.01", use_desklib=True) | |
| # Predict | |
| ai_prob, label = model.predict("Your text here") | |
| print(f"AI Probability: {ai_prob:.2%}") | |
| print(f"Label: {'AI-generated' if label == 1 else 'Human-written'}") | |
| ``` | |
| ### Test It | |
| ```bash | |
| python test_desklib.py | |
| ``` | |
| ## π Benefits | |
| - β **No Training Needed** - Pre-trained model ready to use | |
| - β **Better Accuracy** - State-of-the-art performance | |
| - β **Works on M2 Mac** - Avoids PyTorch MPS training bugs | |
| - β **Easy to Use** - Same interface as before | |
| - β **Production Ready** - Already fine-tuned and optimized | |
| ## π Model Performance | |
| - **RAID Benchmark**: Top performer | |
| - **Robust**: Handles adversarial attacks well | |
| - **Domain Generalization**: Works across different text types | |
| - **Fast Inference**: Optimized for production use | |
| ## π Fallback | |
| If Desklib model fails to load, the code falls back to: | |
| - Your trained model (if exists in `models/ai_detector`) | |
| - RoBERTa-base (standard classification model) | |
| ## π References | |
| - **Model Card**: https://huggingface.co/desklib/ai-text-detector-v1.01 | |
| - **GitHub**: https://github.com/desklib/ai-text-detector | |
| - **Try Online**: https://desklib.com/ai-detector | |
| --- | |
| **You now have a production-ready AI text detector without needing to train!** π | |