Spaces:
Sleeping
Sleeping
|
Download README.md from maddiman/text-classifier-api: direct link, hf CLI and curl.
- Browser
- Download file 3.49 kB
-
https://huggingface.co/spaces/maddiman/text-classifier-api/resolve/main/README.md
- Command line
-
hf download hf://spaces/maddiman/text-classifier-api/README.md
-
curl -L -o README.md https://huggingface.co/spaces/maddiman/text-classifier-api/resolve/main/README.md
3.49 kB
| 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 | |