| --- |
| 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 |
|
|