Downloads · 30 days
0
A5hbr1ng3r/COLD-LoL
COLD-LoL is a machine learning model from A5hbr1ng3r. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated Mar 25, 2024
Repo size
409 MB
Likes
0
Public
Click a slice to open those files.
.pth409 MB · 100%
From the Hugging Face model README
import torch
from transformers.models.bert import BertTokenizer, BertForSequenceClassification
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load model architecture from COLD and load fine-tuned params.
model_name = "thu-coai/roberta-base-cold"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=2)
model_path = "finetuned_cold_LoL.pth" # Could be downloaded in this repo.
model.load_state_dict(torch.load(model_path))
# Demo for toxicity detection
texts = ['狠狠地导', '卡了哟', 'gala有卡莎皮肤,你们这些小黑子有吗?', '早改了,改成回血了']
model_input = tokenizer(texts, return_tensors="pt", padding=True)
model_output = model(**model_input, return_dict=False)
prediction = torch.argmax(model_output[0].cpu(), dim=-1)
prediction = [p.item() for p in prediction]
# prediction = [1, 0, 1, 0] # 1 for toxic, 0 for non-toxic