pythainlp/wisesight_sentiment
Viewer • Updated • 26.7k • 377 • 15
Fine-tuned PhayaThaiBERT for Thai sentiment classification.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained("yourusername/thai-sentiment-phayabert")
tokenizer = AutoTokenizer.from_pretrained("yourusername/thai-sentiment-phayabert")
text = "อาหารอร่อยมาก"
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
prediction = torch.argmax(outputs.logits, dim=-1).item()
labels = {0: "positive", 1: "neutral", 2: "negative"}
print(labels[prediction]) # positive