File size: 1,678 Bytes
3e4b233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
language: ru
license: mit
tags:
- toxicity-classification
- multi-label-classification
- russian
- rubert
pipeline_tag: text-classification
---

# Multi-Task Toxicity Classifier for Russian

## Описание

Модель для мульти-лейбл классификации токсичных комментариев на русском языке.
Основана на `cointegrated/rubert-tiny2` с тремя головами для классов:
- Ненормативная лексика (Profanity)
- Угрозы (Threats)
- Незаконные запросы (Illegal)

## Использование

```python
from transformers import AutoTokenizer, AutoModel
import torch
import json

# Загрузка модели
model = AutoModel.from_pretrained("Doji070/rubert-tiny2-toxic-multilabel")
tokenizer = AutoTokenizer.from_pretrained("Doji070/rubert-tiny2-toxic-multilabel")

# Загрузка порогов
with open("thresholds.json", "r") as f:
    thresholds = json.load(f)

def predict(text):
    inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
    with torch.no_grad():
        outputs = model(**inputs)
        probs = torch.sigmoid(outputs.logits).squeeze().numpy()

    preds = {
        'profanity': int(probs[0] >= thresholds['profanity']),
        'threat': int(probs[1] >= thresholds['threat']),
        'illegal': int(probs[2] >= thresholds['illegal'])
    }
    return preds, probs

# Пример
text = "Ты идиот! Я тебя убью!"
preds, probs = predict(text)
print(f"Текст: {text}")
print(f"Предсказания: {preds}")
```

## Автор

Doji070

## Дата

2026-07-18