YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
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.
Profanity β Toxicity
π§ 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:
git clone https://github.com/floxoris/harmony-v2
cd harmony-v2
Install dependencies:
pip install -r requirements.txt
π¦ Load the Model
from transformers import (
AutoTokenizer,
AutoModelForSequenceClassification
)
model_path = "./Harmony-v2"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSequenceClassification.from_pretrained(model_path)
π Prediction Example
import torch
def predict(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)
toxic_score = probs[0][1].item()
return toxic_score
text = "Π±Π»ΡΠ½ ΡΠ΅ΡΠ²Π΅Ρ Π²ΠΏΠ°Π², ΡΡΠ΅ΡΡΠΉ ΡΠ°Π· ΡΡΠΎΠ³ΠΎΠ΄Π½Ρ"
score = predict(text)
label = "π¨ Toxic" if score > 0.5 else "β
Safe"
print(f"""
Text: {text}
Score: {score:.3f}
Prediction: {label}
""")
Example output:
Text: Π±Π»ΡΠ½ ΡΠ΅ΡΠ²Π΅Ρ Π²ΠΏΠ°Π², ΡΡΠ΅ΡΡΠΉ ΡΠ°Π· ΡΡΠΎΠ³ΠΎΠ΄Π½Ρ
Score: 0.021
Prediction: β
Safe
π Training
Train locally:
python train.py
Or inside Google Colab:
!python train.py
π 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.
- Downloads last month
- 44