--- title: Zero-Shot Text Classification emoji: 🎯 colorFrom: blue colorTo: purple sdk: gradio sdk_version: 4.44.0 app_file: app.py pinned: false --- # 🎯 Zero-Shot Text Classification API A powerful text classification API using **microsoft/deberta-v3-large-mnli** model. Classify any text into custom categories without training! ## Features - 🚀 **Zero-shot classification** - No training data needed - 🎨 **Interactive Gradio UI** - Easy-to-use web interface - 🔌 **RESTful API** - Programmatic access - 📊 **DeBERTa-v3-large** - State-of-the-art NLI model - 🔒 **Private Space Support** - Can be deployed as private ## Usage ### Web Interface Simply enter your text and comma-separated labels, then click "Classify"! ### API Usage #### Python ```python import requests response = requests.post( "https://YOUR-USERNAME-YOUR-SPACE-NAME.hf.space/api/predict", json={ "data": [ "I absolutely love this product!", "positive, negative, neutral", true ] } ) result = response.json() print(result) ``` #### cURL ```bash curl -X POST "https://YOUR-USERNAME-YOUR-SPACE-NAME.hf.space/api/predict" \ -H "Content-Type: application/json" \ -d '{"data": ["I love this product!", "positive, negative, neutral", true]}' ``` #### JavaScript/Node.js ```javascript const response = await fetch("https://YOUR-USERNAME-YOUR-SPACE-NAME.hf.space/api/predict", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ data: [ "I love this product!", "positive, negative, neutral", true ] }) }); const result = await response.json(); console.log(result); ``` ## Response Format ```json { "text": "I absolutely love this product!", "prediction": "positive", "confidence": "0.9876", "all_scores": { "positive": "0.9876", "neutral": "0.0098", "negative": "0.0026" }, "model": "microsoft/deberta-v3-large-mnli" } ``` ## Model Information - **Model:** microsoft/deberta-v3-large-mnli - **Architecture:** DeBERTa (Decoding-enhanced BERT with disentangled attention) - **Task:** Zero-Shot Classification / Natural Language Inference - **Training Data:** MultiNLI dataset - **License:** MIT ## Use Cases - **Sentiment Analysis** - Classify text as positive, negative, or neutral - **Topic Classification** - Categorize content into custom topics - **Intent Detection** - Determine user intent in chatbots - **Content Moderation** - Flag inappropriate content - **Custom Categories** - Any classification task with your own labels! ## Examples ### Sentiment Analysis ``` Text: "This movie was amazing! I loved every minute." Labels: positive, negative, neutral Result: positive (0.9821) ``` ### Topic Classification ``` Text: "The new AI model achieves state-of-the-art results." Labels: technology, politics, sports, entertainment Result: technology (0.9654) ``` ### Intent Detection ``` Text: "I want to cancel my subscription" Labels: inquiry, complaint, cancellation, purchase Result: cancellation (0.9432) ``` ## Local Development 1. Install dependencies: ```bash pip install -r requirements.txt ``` 2. Run the app: ```bash python app.py ``` 3. Open http://localhost:7860 in your browser ## Deployment on Hugging Face Spaces See DEPLOYMENT.md for detailed instructions. ## License MIT License - Feel free to use this in your projects! --- Built with ❤️ using Hugging Face Transformers and Gradio