Spaces:
Sleeping
Sleeping
Added README with user instructions and examples
Browse filesIncludes model info, usage guide, and placeholder examples.
README.md
CHANGED
|
@@ -10,5 +10,59 @@ pinned: false
|
|
| 10 |
license: apache-2.0
|
| 11 |
short_description: Zero-shot text label predictor.
|
| 12 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 10 |
license: apache-2.0
|
| 11 |
short_description: Zero-shot text label predictor.
|
| 12 |
---
|
| 13 |
+
# π§ Zero-Shot Text Classifier (Hugging Face Version)
|
| 14 |
+
|
| 15 |
+
A smart and lightweight web app built with **Gradio** and **Transformers** that classifies your input text into the most likely label β using **Zero-Shot Learning**.
|
| 16 |
+
|
| 17 |
+
## π§ About the Model
|
| 18 |
+
- **Pipeline**: `zero-shot-classification`
|
| 19 |
+
- **Model**: `facebook/bart-large-mnli`
|
| 20 |
+
- **Framework**: Hugging Face Transformers
|
| 21 |
+
- **Task**: Predict a relevant label even if the model wasn't trained on it
|
| 22 |
+
|
| 23 |
+
## π‘ Features
|
| 24 |
+
- Accepts custom comma-separated labels
|
| 25 |
+
- Returns top predictions with confidence scores
|
| 26 |
+
- Works in real-time β hosted via Hugging Face Spaces
|
| 27 |
+
|
| 28 |
+
## βοΈ Instructions for Users
|
| 29 |
+
This app uses **zero-shot classification** to find the most relevant label based on your input and label list.
|
| 30 |
+
|
| 31 |
+
π **How to use:**
|
| 32 |
+
1. Enter a sentence or paragraph
|
| 33 |
+
2. Enter comma-separated labels like: `Technology, Sports, Food`
|
| 34 |
+
3. The app will return top labels with confidence scores
|
| 35 |
+
|
| 36 |
+
β οΈ **Note:**
|
| 37 |
+
- Avoid overlapping or vague labels. It may reduce prediction accuracy.
|
| 38 |
+
- For example, a sentence about economy and healthcare might score both **Finance** and **Health**.
|
| 39 |
+
- The answer may reflect multiple topics if the sentence spans more than one area β this is expected behavior in such cases.
|
| 40 |
+
|
| 41 |
+
β
**Example 1:**
|
| 42 |
+
- **Text:** `Roger Federer won another grand slam title, cementing his legacy in tennis.`
|
| 43 |
+
- **Labels:** `['Politics', 'Fashion', 'Sports']`
|
| 44 |
+
- **Prediction:** `Sports β 99.2%`
|
| 45 |
+
|
| 46 |
+
β
**Example 2:**
|
| 47 |
+
- **Text:** `The chef used fresh ingredients and spices to prepare a delicious Indian curry.`
|
| 48 |
+
- **Labels:** `['Food', 'Health', 'Travel']`
|
| 49 |
+
- **Prediction:** `Food β 88.9%`
|
| 50 |
+
|
| 51 |
+
β
**Example 3:**
|
| 52 |
+
- **Text:** `Climate change is leading to rising sea levels and more frequent extreme weather events.`
|
| 53 |
+
- **Labels:** `['Environment', 'Fashion', 'Technology']`
|
| 54 |
+
- **Prediction:** `Environment β 88.5%`
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## π How to Run Locally
|
| 59 |
+
Install the required packages:
|
| 60 |
+
```bash
|
| 61 |
+
pip install -r requirements.txt
|
| 62 |
+
```
|
| 63 |
+
Then run the app:
|
| 64 |
+
```bash
|
| 65 |
+
python app.py
|
| 66 |
+
```
|
| 67 |
|
| 68 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|