Downloads · 30 days
2.3K
16% of all-time downloads
Ahsamkk/urdu-sentiment-model
urdu-sentiment-model is a machine learning model from Ahsamkk. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Compared to murilbasecasedurdusentiment, the base model of the present model went through an additional pre-training procedure of "masked LM" (MLM) on a dataset of over 1 Million Urdu news. Murilbasecasedurdusentiment…
Downloads · 30 days
2.3K
16% of all-time downloads
All-time downloads
14.8K
Public
Repo size
3.8 GB
Likes
0
Public
Click a slice to open those files.
.pt1.9 GB · 67%
From the Hugging Face model README
Compared to muril_base_cased_urdu_sentiment, the base model of the present model went through an additional pre-training procedure of "masked LM" (MLM) on a dataset of over 1 Million Urdu news. Muril_base_cased_urdu_sentiment_2.0 outperformed muril_base_cased_urdu_sentiment by about 0.2 accuracy rate on news data. Base model is google/muril-base-cased, a BERT model pre-trained on 17 Indian languages and their transliterated counterparts. Urdu sentiment analysis dataset is from mirfan899.
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load the model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("google/muril-base-cased")
model = AutoModelForSequenceClassification.from_pretrained("MichaelHuang/muril_base_cased_urdu_sentiment_2.0")
# Define the input text
text = '''
لیکن مسٹر پوتن نے یہ بھی کہا کہ یہ منصوبہ اسی وقت پیش کیا جا سکتا ہے جب لوگ 'مغرب اور کیئو میں' اس کے لیے تیار ہوں۔
روسی رہنما نے منگل کو ماسکو میں چینی صدر شی جن پنگ سے ملاقات کی جس میں روس یوکرین جنگ اور دونوں ممالک کے درمیان تعلقات پر تبادلہ خیال کیا گیا۔
گذشتہ ماہ شائع ہونے والے چین کے منصوبے میں واضح طور پر روس سے یوکرین چھوڑنے کا مطالبہ نہیں کیا گیا ہے۔
'''
# Tokenize the input text
inputs = tokenizer(text, return_tensors='pt')
# Make a prediction
outputs = model(**inputs)
predicted_class = torch.argmax(outputs.logits).item()
# Print the predicted class
if predicted_class == 1:
print('Positive')
else:
print('Negative')
| eval_loss | epoch | step | eval_accuracy |
|---|---|---|---|
| 0.31 | 1.0 | 3000 | 0.89 |
| 0.28 | 2.0 | 6000 | 0.90 |
| 0.33 | 3.0 | 9000 | 0.91 |