Instructions to use aysangh/bert-fa-sentiment-taghche with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aysangh/bert-fa-sentiment-taghche with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="aysangh/bert-fa-sentiment-taghche")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("aysangh/bert-fa-sentiment-taghche") model = AutoModelForSequenceClassification.from_pretrained("aysangh/bert-fa-sentiment-taghche") - Notebooks
- Google Colab
- Kaggle
bert-fa-sentiment-taghche
Fine-tuned Persian sentiment analysis model based on HooshvareLab/bert-fa-base-uncased 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:
HooshvareLab/bert-fa-base-uncased - Task: Sentiment Classification
- Language: Persian (Farsi)
- Framework: Transformers + PyTorch
Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "aysangh/bert-fa-sentiment-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 = "ﺦﯿﻠﯾ ﺏﺩ ﺏﻭﺩ، ﺎﺻﻻ ﭗﯿﺸﻨﻫﺍﺩ ﻦﻤﯾ<200c>ﮑﻨﻣ."
result = predict_sentiment(text)
print(result)
# Output:
# {'label': 'negative', 'confidence': 0.9619705080986023}
Repository
Training and inference scripts are available on GitHub.
- Downloads last month
- -
Model tree for aysangh/bert-fa-sentiment-taghche
Base model
HooshvareLab/bert-fa-base-uncased