| 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}") | |
| ``` | |