--- title: Zero Shot Classifier emoji: 🏃 colorFrom: purple colorTo: yellow sdk: gradio sdk_version: 5.35.0 app_file: app.py pinned: false license: apache-2.0 short_description: Zero-shot text label predictor. --- # 🧠 Zero-Shot Text Classifier (Hugging Face Version) 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**. ## 🧠 About the Model - **Pipeline**: `zero-shot-classification` - **Model**: `facebook/bart-large-mnli` - **Framework**: Hugging Face Transformers - **Task**: Predict a relevant label even if the model wasn't trained on it ## 💡 Features - Accepts custom comma-separated labels - Returns top predictions with confidence scores - Works in real-time — hosted via Hugging Face Spaces ## ⚙️ Instructions for Users This app uses **zero-shot classification** to find the most relevant label based on your input and label list. 👉 **How to use:** 1. Enter a sentence or paragraph 2. Enter comma-separated labels like: `Technology, Sports, Food` 3. The app will return top labels with confidence scores ⚠️ **Note:** - Avoid overlapping or vague labels. It may reduce prediction accuracy. - For example, a sentence about economy and healthcare might score both **Finance** and **Health**. - The answer may reflect multiple topics if the sentence spans more than one area — this is expected behavior in such cases. ✅ **Example 1:** - **Text:** `Roger Federer won another grand slam title, cementing his legacy in tennis.` - **Labels:** `['Politics', 'Fashion', 'Sports']` - **Prediction:** `Sports — 99.2%` ✅ **Example 2:** - **Text:** `The chef used fresh ingredients and spices to prepare a delicious Indian curry.` - **Labels:** `['Food', 'Health', 'Travel']` - **Prediction:** `Food — 88.9%` ✅ **Example 3:** - **Text:** `Climate change is leading to rising sea levels and more frequent extreme weather events.` - **Labels:** `['Environment', 'Fashion', 'Technology']` - **Prediction:** `Environment — 88.5%` --- ## 🚀 How to Run Locally Install the required packages: ```bash pip install -r requirements.txt ``` Then run the app: ```bash python app.py ``` Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference