A lightweight binary toxicity classifier for
Russian-language text, fine-tuned from
cointegrated/rubert-tiny on the
AlexSham/Toxic_Russian_Comments dataset.
Inputs are truncated to a maximum of 128 tokens.
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "akanemind/BazarFiltr-0.1"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8text = "Ты вообще нормальный человек или нет?"
9inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
10
11with torch.no_grad():
12 logits = model(**inputs).logits
13 probs = torch.softmax(logits, dim=-1)
14 pred = torch.argmax(probs, dim=-1).item()
15
16label = "toxic" if pred == 1 else "non-toxic"
17print(f"{label} (p_toxic={probs[0][1]:.3f})")
AlexSham/Toxic_Russian_Comments — Russian comments labeled toxic/non-toxic, with a natural class imbalance of roughly 82% non-toxic to 18% toxic.