Spaces:
Sleeping
Sleeping
Download services/zero_shot.py from saurav384/Meta_ADS_SAAS: direct link, hf CLI and curl.
- Browser
- Download file 581 Bytes
-
https://huggingface.co/spaces/saurav384/Meta_ADS_SAAS/resolve/main/services/zero_shot.py
- Command line
-
hf download hf://spaces/saurav384/Meta_ADS_SAAS/services/zero_shot.py
-
curl -L -o zero_shot.py https://huggingface.co/spaces/saurav384/Meta_ADS_SAAS/resolve/main/services/zero_shot.py
581 Bytes
| # services/zero_shot.py | |
| from transformers import pipeline | |
| import streamlit as st | |
| def load_zero_shot_model(): | |
| return pipeline( | |
| "zero-shot-classification", | |
| model="facebook/bart-large-mnli" | |
| ) | |
| def classify_intent(text: str): | |
| classifier = load_zero_shot_model() | |
| labels = [ | |
| "sales", | |
| "lead generation", | |
| "brand awareness", | |
| "engagement", | |
| "traffic" | |
| ] | |
| result = classifier(text, labels) | |
| return { | |
| "label": result["labels"][0], | |
| "score": float(result["scores"][0]) | |
| } | |