Spaces:
Sleeping
Sleeping
File size: 544 Bytes
42b5a1a 45a4908 86c1607 42b5a1a 45a4908 42b5a1a 45a4908 42b5a1a 45a4908 42b5a1a 45a4908 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from transformers import pipeline
# Load once at startup
classifier = pipeline(
"zero-shot-classification",
model="valhalla/distilbart-mnli-12-3"
)
def analyze_article(text, title, link):
result = classifier(
text,
candidate_labels=["analytics", "data science", "business insight"],
multi_label=True
)
summary = result['labels'][0]
return {
"title": title,
"link": link,
"summary": summary,
"labels": result['labels'],
"scores": result['scores']
}
|