This repository is split into two independent products:
model/: reusable NLP model pipeline and inference contract for detecting hate directed at Indians, Hindus, and related target groups.extension/: Chrome/Firefox WebExtension that consumes exported browser-compatible model artifacts and performs local inference by default.
The extension must not import training code. It consumes versioned artifacts and the shared prediction contract only.
This is a production-oriented scaffold with:
- deterministic preprocessing and rule baseline;
- stable prediction schema;
- model/export/benchmark commands;
- optional FastAPI backend;
- WebExtension source architecture for Twitter/X;
- local-first privacy and security documentation;
Python model package:
cd model
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,backend]"
pytest
python -m hate_guard.cli predict "All [GROUP] are disgusting."Browser extension:
cd extension
npm install
npm run typecheck
npm run test
npm run buildOptional backend:
cd backend
uvicorn app.main:app --reload- No telemetry by default.
- No cloud inference unless explicitly enabled by the user.
- Raw restricted examples and slur-heavy datasets belong under
model/datasets/restricted/, which is ignored by Git. - Public tests and docs use redacted or synthetic examples.
Production extension archives are generated by CI from a validated trained ONNX bundle and
are not committed to Git. Run python scripts/package_release.py --model-artifact-dir PATH
with a bundle containing both ONNX graphs, tokenizer.json, tokenizer configuration,
thresholds, and a checksum manifest. Packaging fails for placeholder, stub, corrupt, or
tokenizer-incomplete bundles. Use --dry-run to validate inputs and display commands without
writing release files.