Downloads · 30 days
0
amytran589-aus/Categories
Categories is a zero-shot classification model from amytran589-aus. Use it when you need labels you did not train the model on.
Downloads · 30 days
0
Access
Public
Updated Jun 14, 2024
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other1.5 KB · 60%
From the Hugging Face model README
!pip install transformers
import pandas as pd from transformers import pipeline from google.colab import files
uploaded = files.upload()
file_name = 'publications.csv' # Use the file name as uploaded df = pd.read_csv(file_name)
df.head()
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
candidate_labels = ["World", "Sports", "Business", "Science and Technology", "Entertainment", "Lifestyle"]
results = []
for article in df['headline']: result = classifier(article, candidate_labels) category = result['labels'][0] results.append(category)
df['category'] = results
df.head(10)