Downloads · 30 days
32
1% of all-time downloads
nimaafshar/parsbert-fa-sentiment-twitter
parsbert-fa-sentiment-twitter is a text classification model from nimaafshar. Use it when you need a label for a piece of text. It is set up for transformers.
ParsBERT digikala sentiment analysis model fine-tuned on around 600,000 Persian tweets. at least you need 650 megabytes of ram and disk in order to load the model. tensorflow, transformers and numpy library
Downloads · 30 days
32
1% of all-time downloads
All-time downloads
6.2K
Public
Repo size
1.3 GB
Likes
1
Public
Click a slice to open those files.
.h5652 MB · 100%
From the Hugging Face model README
ParsBERT digikala sentiment analysis model fine-tuned on around 600,000 Persian tweets.
at least you need 650 megabytes of ram and disk in order to load the model. tensorflow, transformers and numpy library
import numpy as np
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
#loading model
tokenizer = AutoTokenizer.from_pretrained("nimaafshar/parsbert-fa-sentiment-twitter")
model = TFAutoModelForSequenceClassification.from_pretrained("nimaafshar/parsbert-fa-sentiment-twitter")
classes = ["negative","neutral","positive"]
#using model
sequences = [".غذا خیلی افتضاح بود متاسفم برای مدیریت رستورن خیلی بد بود.",
"خیلی خوشمزده و عالی بود عالی",
"میتونم اسمتونو بپرسم؟"
]
for sequence in sequences:
inputs = tokenizer(sequence, return_tensors="tf")
classification_logits = model(inputs)[0]
results = tf.nn.softmax(classification_logits, axis=1).numpy()[0]
print(classes[np.argmax(results)])
percentages = np.around(results*100)
print(percentages)
note that this model is trained on persian corpus and is meant to be used on persian texts too.