PaulSouvik's picture
Added README with user instructions and examples
d6b9484 verified

A newer version of the Gradio SDK is available: 6.5.1

Upgrade
metadata
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:

pip install -r requirements.txt

Then run the app:

python app.py

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference