Views
No views yet
1import torch
2from transformers import AutoModelForSequenceClassification, AutoTokenizer
3# Specify the model and tokenizer name
4model_name = "Exqrch/IndoBERTweet-IdentityAttack"
5tokenizer_name = "indolem/indobertweet-base-uncased"
6# Load the pre-trained model
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8# Load the tokenizer
9tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)
10text = "selamat pagi semua!"
11output = model(**tokenizer(text, return_tensors="pt"))
12logits = output.logits
13# Get the predicted class label
14predicted_class = torch.argmax(logits, dim=-1).item()
15print(predicted_class)
16--- Output ---
17> 0
18--- End of Output ---Model name: Exqrch/IndoBERTweet-IdentityAttack
Text 1: ayolah, jaga kebersihan bersama
Prediction: 0
Text 2: dia itu loh, udah hitam, dengkil lagi
Prediction: 1@article{susanto2024indotoxic2024,
title={IndoToxic2024: A Demographically-Enriched Dataset of Hate Speech and Toxicity Types for Indonesian Language},
author={Lucky Susanto and Musa Izzanardi Wijanarko and Prasetia Anugrah Pratama and Traci Hong and Ika Idris and Alham Fikri Aji and Derry Wijaya},
year={2024},
eprint={2406.19349},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2406.19349},
}