
Bert-based classifier (finetuned from [rubert-tiny2](https://huggingface.co/cointegrated/rubert-tiny2)) 

Merged datasets:

- [Russian Language Toxic Comments from 2ch.hk and pikabu.ru](https://www.kaggle.com/datasets/blackmoon/russian-language-toxic-comments)
- [Toxic Russian Comments from ok.ru](https://www.kaggle.com/datasets/alexandersemiletov/toxic-russian-comments)

The datasets split into train, val, test splits in 80-10-10 proportion
The metrics obtained from test dataset is as follows:
|        |precision|recall|f1-score|support|
|--------|---------|------|--------|-------|
|0       |0.9827   |0.9827|0.9827  |21216  |
|1       |0.9272   |0.9274|0.9273  |5054   |
|        |         |      |        |       |
|accuracy|         |      |0.9720  |26270  |
|macro avg|0.9550   |0.9550|0.9550  |26270  |
|weighted avg|0.9720   |0.9720|0.9720  |26270  |

### Usage

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

PATH = 'khvatov/ru_toxicity_detector'
tokenizer = AutoTokenizer.from_pretrained(PATH)
model = AutoModelForSequenceClassification.from_pretrained(PATH)

# if torch.cuda.is_available():
#     model.cuda()

model.to(torch.device("cpu"))


def get_toxicity_probs(text):
    with torch.no_grad():
        inputs = tokenizer(text, return_tensors='pt', truncation=True, padding=True).to(model.device)
        proba = torch.nn.functional.softmax(model(**inputs).logits, dim=1).cpu().numpy()
    return proba[0]


TEXT = "Марк был хороший"
print(f'text = {TEXT}, probs={get_toxicity_probs(TEXT)}')
# text = Марк был хороший, probs=[0.9940585  0.00594147]
```

### Train
The model has been trained with Adam optimizer, the learning rate of 2e-5, and batch size of 32 for 3 epochs

{"language": ["ru"], "license": "mit", "tags": ["russian", "classification", "toxicity"], "widget": [{"text": "\u041d\u0435\u043b\u0435\u043f\u044b\u0435 \u043b\u043e\u0445\u0438 \u043d\u0435\u0434\u043e\u0432\u043e\u043b\u044c\u043d\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0438 \u0432\u0441\u0435\u043c"}]}
transformers pytorch safetensors bert text-classification russian classification toxicity ru license:mit autotrain_compatible endpoints_compatible region:us
TAGS
#transformers #pytorch #safetensors #bert #text-classification #russian #classification #toxicity #ru #license-mit #autotrain_compatible #endpoints_compatible #region-us 

Bert-based classifier (finetuned from rubert-tiny2)


Merged datasets:


* Russian Language Toxic Comments from URL and URL
* Toxic Russian Comments from URL


The datasets split into train, val, test splits in 80-10-10 proportion
The metrics obtained from test dataset is as follows:



### Usage


### Train


The model has been trained with Adam optimizer, the learning rate of 2e-5, and batch size of 32 for 3 epochs



### Usage ### Train


The model has been trained with Adam optimizer, the learning rate of 2e-5, and batch size of 32 for 3 epochs
TAGS
#transformers #pytorch #safetensors #bert #text-classification #russian #classification #toxicity #ru #license-mit #autotrain_compatible #endpoints_compatible #region-us 
 ### Usage ### Train


The model has been trained with Adam optimizer, the learning rate of 2e-5, and batch size of 32 for 3 epochs