Downloads · 30 days
171
9% of all-time downloads
Pongsathorn/wangchanberta-base-sentiment
wangchanberta-base-sentiment is a machine learning model from Pongsathorn. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This is a fine-tuned version of the WangchanBERTa model, trained for sentiment analysis in Thai language using simpletransformers.
Downloads · 30 days
171
9% of all-time downloads
All-time downloads
1.8K
Public
Parameters
105M
16.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt10.9 GB · 65%
From the Hugging Face model README
This is a fine-tuned version of the WangchanBERTa model, trained for sentiment analysis in Thai language using simpletransformers.
airesearch/wangchanberta-base-att-spm-uncasedsimpletransformersProvide any performance metrics here, such as accuracy, F1-score, etc., depending on your dataset.
To use this model, you can load it as follows:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import torch.nn.functional as F
import numpy as np
from pythainlp.tokenize import word_tokenize
tokenizer = AutoTokenizer.from_pretrained("Pongsathorn/wangchanberta-base-sentiment")
model = AutoModelForSequenceClassification.from_pretrained("Pongsathorn/wangchanberta-base-sentiment")
id2label = {
0: "pos",
1: "neu",
2: "neg",
}
input_text = "พนักงานบริการดีมาก สัญญาณก็ดี แต่ร้านอยู่ที่ไหน อยากได้ข้อมูลเพิ่มเติม จะได้ประกาศบนเว็บถูก"
segmented_text = word_tokenize(input_text, engine="longest")
preprocessed_text = " ".join(segmented_text)
inputs = tokenizer(preprocessed_text, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = F.softmax(logits, dim=-1)
predicted_class = torch.argmax(probs, dim=-1).item()
predicted_label = id2label[predicted_class]
print("Predicted Label (ID):", predicted_class)
print("Predicted Label (Description):", predicted_label)
max_prob = np.max(probs.numpy())
print(f"Maximum Probability: {max_prob:.4f}")