kea-cyberbully
Production-grade Cyberbullying Text Detection powered by transformer neural networks and nuance-aware multi-task learning. Developed by KEA MINDZ.
Designed for social media moderation, chat moderation, comment screening, and trust & safety workflows.
Key Features
- Multi-Task Neural Architecture: Joint binary classifier (cyberbullying vs. safe) with a 20-way auxiliary intent head (threats, targeted insults, implicit mockery, backhanded compliments, sarcasm among friends, venting, etc.).
- Context & Nuance Aware: Distinguishes harmful bullying from benign sarcasm among friends, self-venting, or constructive criticism.
- Adversarial Robustness: Handles leetspeak (e.g.
@$$h0le,sna7ch), typo variations, and emoji sentiment without breaking casing or punctuation. - Lightweight Package (<15 KB): Compliant with PyPI upload limits by decoupling heavy 260MB model checkpoints and providing automatic background caching to
~/.cache/cyberbully/models/. - Flexible Interface: Simple Python API and a rich interactive CLI.
Installation
From PyPI
pip install kea-cyberbully
From Source / Development
git clone https://github.com/KEA-Mindz/Cyberbully.git
cd Cyberbully
pip install -e .
Optional Dependencies
For running model evaluations and plotting metrics:
pip install -e ".[eval]"
For testing:
pip install -e ".[dev]"
Quickstart (Python API)
1. Simple Boolean Check
import cyberbully
# True
print(cyberbully.is_cyberbullying("Go jump off a cliff you loser"))
# False
print(cyberbully.is_cyberbullying("You are a wonderful person!"))
2. Detailed Prediction
import cyberbully
result = cyberbully.predict("Nobody likes you, you are ugly and pathetic")
print(result.label) # 'cyberbullying'
print(result.score) # 0.9996
print(result.confidence) # 0.9996
print(result.category) # 'targeted_insult_general'
print(result.category_scores)
# {
# 'targeted_insult_general': 0.8227,
# 'threat': 0.1511,
# ...
# }
3. Explainability Diagnostics
import cyberbully
explanation = cyberbully.explain("You are so annoying")
print(explanation)
# {
# 'text': 'You are so annoying',
# 'prediction': 'cyberbullying',
# 'cyberbullying_score': '0.9412',
# 'threshold': '0.2300',
# 'primary_intent_category': 'targeted_insult_general',
# 'assessment': 'Flagged as cyberbullying (94.1% probability exceeds threshold 23.0%)'
# }
4. Custom Model Instance & Batch Processing
from cyberbully import CyberbullyingDetector
# Automatically detects local models/ or downloads to cache on first use
detector = CyberbullyingDetector()
texts = [
"Have a fantastic day!",
"You are an idiot.",
"Can you please help review this PR?"
]
results = detector.predict(texts, batch_size=32)
for res in results:
print(f"[{res.label.upper():17s}] ({res.score:.3f}) {res.text}")
Command-Line Interface (CLI)
The package provides two alias commands: kea-cyberbully and cyberbully:
Classify Single or Multiple Texts
kea-cyberbully "You are a wonderful person"
kea-cyberbully "Nobody likes you" --threshold 0.30
Interactive Mode
Launch an interactive evaluation console:
kea-cyberbully -i
Batch Processing from CSV or Text Files
kea-cyberbully --file comments.csv --output flagged_results.csv
Check Model Info & Cache
kea-cyberbully --info
Pre-download Model Checkpoint
kea-cyberbully --download
Model Weights & Distribution
The trained checkpoint (best_model.pt, ~265MB) is decoupled from the PyPI wheel for fast installation:
- Local Search: The detector first inspects:
models/cyberbully_v0.1_run- Explicit path specified via
--model-dirorCYBERBULLY_MODEL_DIR
- Cache Fallback: If not found in local directories, it checks
~/.cache/cyberbully/models/cyberbully_v0.1_run. - Auto-Download: If missing, it downloads the checkpoint and tokenizer directly from Google Drive upon first execution.
Repository Structure
Cyberbully/
├── .github/
│ └── workflows/
│ └── release.yaml # Automated release & PyPI publishing workflow
├── src/
│ └── cyberbully/ # Core Python package
│ ├── __init__.py # Package exports & convenience API
│ ├── __main__.py # python -m cyberbully entrypoint
│ ├── cli.py # Command-line interface
│ ├── detector.py # CyberbullyingDetector engine
│ ├── downloader.py # Model downloader & cache management
│ ├── model.py # PyTorch MultiTaskClassifier architecture
│ └── preprocessing.py # Adversarial & social media text cleaner
├── models/
│ └── cyberbully_v0.1_run/ # Trained PyTorch model, tokenizer, and config
├── tests/
│ ├── test_detector.py # Pytest suite for model inference
│ └── test_preprocessing.py # Unit tests for text normalization
├── LICENSE # MIT License
├── MANIFEST.in # Packaging exclusions
├── pyproject.toml # Modern PEP 621 / setuptools packaging
├── requirements.txt # Environment dependencies
└── README.md # Documentation
License
This project is licensed under the MIT License.
Release files for kea-cyberbully 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kea_cyberbully-0.1.0.tar.gz | 15.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kea_cyberbully-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.8 kB
Release files / kea_cyberbully-0.1.0.tar.gz
| Download URL | kea_cyberbully-0.1.0.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b988355c544e91bf4c52ebc8dd0287d310930c8b02195587e8cb215cd5c5aab
|
|
BLAKE2b-256 checksum How to use checksums |
efa9169efc1c778212f3fe295cd53fd50a658d4e5b8852df374a6bf521097e2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / kea_cyberbully-0.1.0-py3-none-any.whl
| Download URL | kea_cyberbully-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3529c91e0f345ec51ca132c593aeadb3823a3e1e25b388914c60f29862213036
|
|
BLAKE2b-256 checksum How to use checksums |
e2aff60e67490683c3e604f79c9122666e71717e3e6c2dd8e85f614d8d61d43b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency log