Edit model card

Sentiment Binary Classifier for Urdu

muril_base_cased_urdu_sentiment_2.0

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.

Usage

example:

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')

Training results

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
Downloads last month
19