Replace toxicity model with multi-label classifier

This commit is contained in:
Jordan Wages 2026-08-26 17:00:49 -05:00
commit 1568c787f8
24 changed files with 2581129 additions and 119717 deletions

View file

@ -35,18 +35,18 @@ python3 -m pip install -r tools/requirements-model.txt
# Inspect architecture, labels, tokenizer, and resolved source revision.
python3 tools/convert_model.py inspect \
--model wagesj45/toxic-comment-classifier
--model wagesj45/multilabel-toxic-comment-classifier
# Use the immutable commit printed by inspection for a release artifact.
python3 tools/convert_model.py prepare \
--model wagesj45/toxic-comment-classifier \
--model wagesj45/multilabel-toxic-comment-classifier \
--revision <resolved-huggingface-commit>
python3 tools/convert_model.py validate
```
Preparation writes the Transformers.js-compatible files and `model-manifest.json` under `public/models/toxicity/`. The manifest records the source revision, Apache 2.0 license, toxic/non-toxic label indices, maximum sequence length, and int8 quantization format. Source PyTorch/safetensors weights are never copied into the extension.
Preparation writes the Transformers.js-compatible files and `model-manifest.json` under `public/models/toxicity/`. The manifest records the source revision, Apache 2.0 license, ordered multi-label category mapping, 512-token maximum sequence length, and int8 quantization format. Source PyTorch/safetensors weights are never copied into the extension.
If the model uses generic labels such as `LABEL_0` and `LABEL_1`, pass `--toxic-index` and `--non-toxic-index` to `prepare`; the command refuses to guess an ambiguous mapping.
The bundled [multi-label ModernBERT model](https://huggingface.co/wagesj45/multilabel-toxic-comment-classifier) produces independent scores for toxicity, severe toxicity, obscene, threat, insult, identity attack, and sexual explicit content. Preparation refuses models that do not expose exactly this label set.
VibeGuard injects a lightweight content script on ordinary web pages, but reads and processes content only when a validated site definition matches the page. The extension includes a bundled definition collection for the official Mastodon web interface, Threads, old Reddit, and X. The Threads definition covers both `threads.com` and legacy `threads.net` URLs using semantic and data-attribute selectors; the Reddit definition targets `old.reddit.com`, while the X definition covers both `x.com` and legacy `twitter.com` URLs. The default subscription follows the repository's raw JSON collection and refreshes weekly, while the bundled copy remains available offline. Additional JSON subscriptions, local overrides, and disabled definitions are managed in the options page. Definitions are declarative selectors and URL patterns, never executable code.
@ -71,7 +71,7 @@ Inference runs locally through ONNX Runtime's WASM backend using the bundled qua
## Options page
Open the extensions options page to change the threshold, filtering mode, and score display. The Site definitions section manages JSON subscriptions, which refresh automatically once per week and can also be refreshed manually. Local overrides can be imported from or exported to JSON and are validated before they are saved. A failed or invalid subscription update leaves the last-known-good definitions active.
Open the extensions options page to change the shared category threshold, enabled categories, filtering mode, and score display. A post is filtered when any enabled category reaches the threshold, and a collapsed placeholder identifies the highest-scoring matching category. The Site definitions section manages JSON subscriptions, which refresh automatically once per week and can also be refreshed manually. Local overrides can be imported from or exported to JSON and are validated before they are saved. A failed or invalid subscription update leaves the last-known-good definitions active.
The options page uses the locally bundled [Bulma CSS](https://bulma.io/) v1.0.3 stylesheet. No options-page styling or runtime dependency is loaded from a CDN.
@ -88,7 +88,7 @@ VibeGuard requests the following permissions:
## Model and third-party licenses
The packaged toxicity model is distributed under the Apache License 2.0. Its source revision, label mapping, sequence length, and quantization details are recorded in `public/models/toxicity/model-manifest.json`.
The packaged toxicity model is distributed under the Apache License 2.0. Its source revision, multi-label mapping, sequence length, and quantization details are recorded in `public/models/toxicity/model-manifest.json`.
VibeGuard also bundles [Bulma CSS v1.0.3](https://github.com/jgthms/bulma), which is distributed under the MIT License. The projects own code is licensed under the terms in [LICENSE](LICENSE).