pythainlp/wisesight_sentiment
Viewer • Updated • 26.7k • 1.03k • 16
WangchanBERTa fine-tuned for 4-class sentiment classification (pos / neu / neg / q) on
Wisesight Sentiment, trained on
text passed through a custom Thai normalizer (normalize_thai()) that collapses elongation,
maps emoji to sentiment tags, and corrects slang via a dictionary mined from MultiLexNorm++.
airesearch/wangchanberta-base-att-spm-uncasedFull project, code, and the normalization pipeline this model is paired with: https://github.com/thitiwutsuk/Thai-Slang-NLP-Normalize
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
tokenizer = AutoTokenizer.from_pretrained("thitiwutsuk/thai-sentiment-wangchanberta")
model = AutoModelForSequenceClassification.from_pretrained("thitiwutsuk/thai-sentiment-wangchanberta")
inputs = tokenizer("อาหารอร่อยมาก", return_tensors="pt", truncation=True, max_length=64, padding="max_length")
with torch.no_grad():
probs = torch.softmax(model(**inputs).logits, dim=-1)
print(probs) # [pos, neu, neg, q]
Note: for best results, run input text through normalize_thai() from the project repo above
before tokenizing — this model was trained on normalized text, not raw text.