Harmony v2 — Toxicity Classifier
Lightweight, context-aware toxicity detection that understands intent, not just keywords.
Harmony v2 is a lightweight toxicity classifier fine-tuned from gravitee-io/bert-tiny-toxicity on HarmonyDataset v2 , a custom dataset of 7,000 human-like chat messages .
Unlike traditional keyword-based filters, Harmony v2 focuses on who is being targeted, the intent behind the message, and conversational context .
🧠 Overview
Harmony v2 is designed for modern chat moderation, especially for Telegram communities, forums, games, and social platforms.
It distinguishes between:
🚨 Toxic
Personal attacks
Harassment
Threats
Humiliation
Dehumanization
Hate directed at another person
✅ Safe
Emotional expression
Frustration
Profanity without a target
Friendly banter
Sarcasm
Jokes
Self-directed insults
Instead of blocking words, Harmony v2 evaluates intent .
✨ Features
Feature Value Base model gravitee-io/bert-tiny-toxicity Dataset HarmonyDataset v2 Samples 7,000 Languages Ukrainian, Russian, mixed UA/RU Max sequence length 512 tokens Framework Hugging Face Transformers Model format PyTorch Quantized size ~9 MB (INT8) License Apache-2.0
⚡ Performance
Metric Result Evaluation Loss 0.4255 F1 Score 98.4% CPU Inference ~11 ms Precision High Recall High
📊 Dataset
HarmonyDataset v2 contains 7,000 balanced synthetic chat messages .
Category Share Safe 15% Friendly profanity 10% Frustration 10% Self-insult 5% Joke 10% Sarcasm 10% Criticism 5% Insult 10% Harassment 15% Threat 10%
Dataset philosophy:
realistic conversations
Telegram-like writing
slang
spelling mistakes
emojis
mixed Ukrainian/Russian
contextual toxicity
🚀 Installation
Clone the repository:
1 git clone https://github.com/floxoris/harmony-v2
2 cd harmony-v2
Install dependencies:
pip install -r requirements.txt
📦 Load the Model
1 from transformers import (
2 AutoTokenizer ,
3 AutoModelForSequenceClassification
4 )
5
6 model_path = "./Harmony-v2"
7
8 tokenizer = AutoTokenizer . from_pretrained ( model_path )
9 model = AutoModelForSequenceClassification . from_pretrained ( model_path )
🔍 Prediction Example
1 import torch
2
3 def predict ( text ) :
4 inputs = tokenizer (
5 text ,
6 return_tensors = "pt" ,
7 truncation = True ,
8 max_length = 512
9 )
10
11 with torch . no_grad ( ) :
12 outputs = model ( ** inputs )
13
14 probs = torch . softmax ( outputs . logits , dim = 1 )
15 toxic_score = probs [ 0 ] [ 1 ] . item ( )
16
17 return toxic_score
18
19 text = "блін сервер впав, третій раз сьогодні"
20
21 score = predict ( text )
22
23 label = "🚨 Toxic" if score > 0.5 else "✅ Safe"
24
25 print ( f"""
26 Text: { text }
27
28 Score: { score : .3f }
29
30 Prediction: { label }
31 """ )
Example output:
1 Text: блін сервер впав, третій раз сьогодні
2
3 Score: 0.021
4
5 Prediction: ✅ Safe
🏗 Training
Train locally:
Or inside Google Colab:
📁 Repository Structure
Harmony-v2/
│
├── config.json
├── tokenizer.json
├── tokenizer_config.json
├── special_tokens_map.json
├── model.safetensors
├── train.py
├── requirements.txt
└── README.md
💡 Intended Use
Harmony v2 is suitable for:
Telegram bots
Discord moderation
Forum moderation
Live chat filtering
AI assistants
Comment moderation
Social platforms
Community management
❌ Not Intended For
Harmony v2 should not be used as the sole decision-maker for:
legal decisions
law enforcement
employment screening
medical applications
Human review is recommended for critical moderation.
📚 References
Base model
gravitee-io/bert-tiny-toxicity
Frameworks
Hugging Face Transformers
Hugging Face Datasets
PyTorch
📄 License
Licensed under the Apache License 2.0 .
You are free to:
✅ use commercially
✅ modify
✅ redistribute
✅ include in proprietary software
Subject to the Apache-2.0 license terms.
🤝 Contributing
Pull requests, bug reports, and suggestions are welcome.
If you find a false positive or false negative, please open an issue.
🌸 Floxoris Labs
Harmony v2 is developed by Floxoris Labs .
Lightweight AI. Maximum Intelligence.