Views
No views yet
0.70 (determined on the validation set).| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Normal (0) | 0.9997 | 0.9998 | 0.9998 | 101,786 |
| Toxic (1) | 0.9647 | 0.9425 | 0.9535 | 522 |
| Accuracy | 0.9995 | 102,308 | ||
| Macro Avg | 0.9822 | 0.9712 | 0.9766 | 102,308 |
| Weighted Avg | 0.9995 | 0.9995 | 0.9995 | 102,308 |
1import torch
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
4MODEL_NAME = "KvaytG/rubert-tiny2-toxic-detector"
5THRESHOLD = 0.70
6
7tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
8model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
9model.eval()
10
11texts = [
12 "Привет! Как твои дела?"
13]
14
15inputs = tokenizer(texts, padding=True, truncation=True, max_length=128, return_tensors="pt")
16
17with torch.no_grad():
18 outputs = model(**inputs)
19 probs = torch.sigmoid(outputs.logits.squeeze(-1)).cpu().numpy()
20
21for text, prob in zip(texts, probs):
22 is_toxic = bool(prob > THRESHOLD)
23 print(f"Text: '{text}'")
24 print(f" Toxicity probability: {prob:.4f} | Is toxic: {is_toxic}\n")alpha=0.75, gamma=2.0)learning_rate=3e-5, weight_decay=0.01)1@misc{kvaytg_rubert_tiny2_toxic_detector,
2 author = {KvaytG},
3 title = {RuBERT-tiny2 Toxic Text Detector},
4 year = {2026},
5 publisher = {Hugging Face},
6 journal = {Hugging Face Models},
7 url = {https://huggingface.co/KvaytG/rubert-tiny2-toxic-detector},
8 note = {High-performance lightweight toxic text detector for Russian language}
9}