Spaces:
Sleeping
Sleeping
| 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'] | |
| } | |