ModernBERT-base-fa-taghche

Fine-tuned Persian sentiment analysis model based on myrkur/Persian-ModernBert-base for binary sentiment classification on the Taaghche Persian review dataset.

Dataset

The model was trained on the Taaghche Persian reviews dataset available on Kaggle:

Model Details

  • Base model: myrkur/Persian-ModernBert-base
  • Task: Sentiment Classification
  • Language: Persian (Farsi)
  • Framework: Transformers + PyTorch

Usage

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_name = "aysangh/ModernBERT-base-fa-taghche"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

def predict_sentiment(text):
    inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256, padding=True)
    with torch.no_grad():
        outputs = model(**inputs)
    probs = torch.softmax(outputs.logits, dim=-1)
    pred = torch.argmax(probs, dim=-1).item()
    confidence = probs[0][pred].item()
    return {
    "label": "positive" if pred == 0 else "negative",
    "confidence": confidence
}

text = "خیلی بد بود، اصلاً پیشنهاد نمی‌کنم."

result = predict_sentiment(text)
print(result)

# Output:
# {'label': 'negative', 'confidence': 0.9999935626983643}

Repository

Training and inference scripts are available on GitHub.

Downloads last month
8
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for aysangh/ModernBERT-base-fa-taghche

Finetuned
(2)
this model