Text Classification
Transformers
Safetensors
Russian
roberta
toxicity
pytorch_lightning
text-embeddings-inference
Instructions to use Nelera/ru-toxicity-detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nelera/ru-toxicity-detection with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Nelera/ru-toxicity-detection", device_map="auto")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Nelera/ru-toxicity-detection") model = AutoModelForSequenceClassification.from_pretrained("Nelera/ru-toxicity-detection", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Краткое описание
Модель предназначена для классификации токсичности текста на русском языке.
Обучена на основе архитектуры ai-forever/ru-en-RoSBERTa с использованием PyTorch Lightning.
Задача
Модель решает задачу бинарной классификации текста:
0– нейтральный, безопасный текст.1– токсичный текст, содержащий грубость, мат, явные или скрытые оскорбления.
Метрики на тестовой выборке
- Accuracy: 0.9967
- F1 Score: 0.9967
- ROC AUC: 0.9997
- MCC: 0.9934
Пример использования (Inference)
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("Nelera/ru-en-toxicity-rosberta")
model = AutoModelForSequenceClassification.from_pretrained("Nelera/ru-en-toxicity-rosberta")
text = "Ваш текст для проверки"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
with torch.no_grad():
logits = model(**inputs).logits
prob = torch.softmax(logits, dim=-1)[0][1].item()
pred = torch.argmax(logits, dim=1).item()
print(f"Класс: {pred} (Вероятность токсичности: {prob:.4f})")
- Downloads last month
- 29