A simple and effective tool utilizing AI to detect bad words and toxic language.
As an admin on Venity Network, I’ve had a problem dealing with toxic players. Sometimes they keep arguing and causing drama even after being muted, and it can go on endlessly (many of them even evade mutes using alternate accounts).
Eventually, I got an idea from the players who constantly yapping about how many toxic words appear in chat, and the solution I found was the good old simple AI-based toxicity detector called Detoxify. Detoxify was created by Unitary and comes with 3 detection models. It can also detect many different types of toxic language, which makes it highly accurate. Kinda...
Its multilingual support also helps detect offensive or toxic words in many languages other than English, and the best thing, it can understand context too. So this project example should make it easier to implement something like this into a server.
There are two main components: a Python API (for toxicity detection using Detoxify) and the Go server integration.
Requirements:
- Python 3.10+
- pip (package manager)
detoxifylibrary- Important: Make sure your
numpyversion is less than 2 (e.g., 1.26.x).
Install dependencies:
pip install -r API/requirements.txtStart the API server:
cd API
uvicorn run:app --host 0.0.0.0 --port 8000 --workers 1The API will now be running on http://localhost:8000.
Requirements:
- Go 1.24+
- Project dependencies (see
go.modfor details)
Build and run the server:
go build -o df-detoxify
./df-detoxifyOr simply run go run .
The Go server will interact with the Detoxify API to moderate chat messages for toxicity.
Note: You can configure toxicity thresholds in config.toml.
Windows PowerShell:
./scripts/autorun.ps1If dependencies are already installed:
./scripts/autorun.ps1 -SkipInstallWhat this script does:
- Optionally installs Python dependencies from
API/requirements.txt - Starts Detoxify API at
127.0.0.1:8000 - Starts Dragonfly server using
go run . - Stops API automatically when Go server exits
- Adjust toxicity category thresholds in
config.tomlto tune moderation sensitivity. - Ensure the API is running before starting the Go server.
- To test if the API is working, try running
test.pyand see if the toxic detector is working properly.