Instructions to use MichaelHuang/muril_base_cased_urdu_sentiment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MichaelHuang/muril_base_cased_urdu_sentiment with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="MichaelHuang/muril_base_cased_urdu_sentiment")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("MichaelHuang/muril_base_cased_urdu_sentiment") model = AutoModelForSequenceClassification.from_pretrained("MichaelHuang/muril_base_cased_urdu_sentiment") - Notebooks
- Google Colab
- Kaggle
Sentiment Binary Classifier for Urdu
muril_base_cased_urdu_sentiment
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")
# 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.29 | 1.0 | 3000 | 0.89 |
| 0.32 | 2.0 | 6000 | 0.91 |
| 0.33 | 3.0 | 9000 | 0.91 |
- Downloads last month
- 4