File size: 1,356 Bytes
1c4e775
36f39dc
 
 
 
 
 
 
 
 
 
1c4e775
 
36f39dc
1c4e775
36f39dc
1c4e775
36f39dc
 
1c4e775
36f39dc
 
 
1c4e775
36f39dc
 
 
1c4e775
36f39dc
1c4e775
36f39dc
 
 
1c4e775
36f39dc
 
1c4e775
36f39dc
 
1c4e775
36f39dc
 
 
1c4e775
36f39dc
 
 
 
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
---
language:
- ru
license: mit
tags:
- text-classification
- toxicity-detection
- pytorch
metrics:
- f1
- accuracy
---

# RuBERT Toxicity Classifier

Модель для классификации токсичности текста на русском языке.

## Описание модели
Обучена на базе `ru-en-RoBERTa` с помощью PyTorch Lightning.

## Классы
* **0**: Безопасный текст (Non-toxic)
* **1**: Токсичный текст (Toxic)

## Метрики
* **Validation F1-Score**: ~0.982
* **Validation Accuracy**: ~0.982

## Пример использования

```python
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("fdlvaaa/rubert-toxicity-classifier")
model = AutoModelForSequenceClassification.from_pretrained("fdlvaaa/rubert-toxicity-classifier")

text = "Здравствуйте, чем могу помочь?"
inputs = tokenizer(text, return_tensors='pt', truncation=True, max_length=512)

with torch.no_grad():
    outputs = model(**inputs)
    probs = torch.softmax(outputs.logits, dim=-1)

toxicity_prob = probs[0][1].item()
label = 'Токсично' if toxicity_prob >= 0.5 else 'Безопасно'
print(f"Результат: {label} | Вероятность: {toxicity_prob:.4f}")
```