Views
No views yet
1from transformers import BertTokenizer, BertForSequenceClassification
2import torch
3
4# Load model and tokenizer
5tokenizer = BertTokenizer.from_pretrained("MrPanuwit/thai-youtube-sentiment-subtask1")
6model = BertForSequenceClassification.from_pretrained("MrPanuwit/thai-youtube-sentiment-subtask1")
7
8# Example usage
9text = "วิดีโอนี้สนุกมาก"
10inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
11
12with torch.no_grad():
13 outputs = model(**inputs)
14 predictions = torch.argmax(outputs.logits, dim=-1)
15
16print(f"Prediction: {predictions.item()}")@misc{thai-youtube-sentiment,
author = {Your Name},
title = {Thai YouTube Comment Sentiment Analysis},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/MrPanuwit/thai-youtube-sentiment-subtask1}
}