Still WIP

This commit is contained in:
spushk 2026-05-13 14:08:53 +05:00 • committed by spushk
commit 6d28a2f53a
Signed by: spushk
GPG key ID: 7797B761E105E8AA

117
README.md
View file

@ -1,5 +1,28 @@
# firaid-moz
> I don't know why I named it this way
> [!NOTE]
> This software is provided under terms of BUSL 1.1 license in most permissive mode,
> with exceptions for some automation.
> Please, consult the [LICENSE](LICENSE.md) if you're about to perform AI-assisted analysis
---
**Disclaimer:**
The software provided as-is, without warranty of any kind, express or implied.
This project is an educational proof-of-concept experiment.
To clarify:
- I am not responsible for your judgement on content origin (AI/human/assisted)
- I am not responsible for your attitude towards AI/human/assisted content
- I am not responsible for any consequences of such a judgement
Classifications performed by this extension are not based on private or social opinions. This extension does not rely on reputations, lists, filters, etc.
The only method used by this extension to determine origin of content is a bunch of linear algebra in a black-box, aka "ML model", which decisions may or may not be biased - depending on training dataset, which is out of scope of this project.
---
A simple local webextension, which can run a bunch of small ML models to infer some properties of DOM content, such as:
@ -8,61 +31,93 @@ A simple local webextension, which can run a bunch of small ML models to infer s
## AI/Human classification
> **NONE** of ML/AI/whatever models is 100% accurate by the very fundamental design. Any ML model *pretends* to do some job with certain degree of accuracy. So this extension *pretends* to know which content is AI-generated and which is not - with a certain degree of accuracy.
> **NONE** of ML/AI/whatever models is 100% accurate by the very fundamental design. Every "AI" simply *pretends* to posess some information. So this extension *pretends* to know which content is AI-generated and which is not - with a certain degree of accuracy.
>
>If you don't completely trust the "AI slop" - you should not completely trust this extension also!
> If you don't trust the "AI slop" - you should not completely trust this extension also!
>
> False-positives? - Possible
> False-positives - Possible
>
> False-negatives? - Probably
> False-negatives - Probably
>
> This extension - like **every other AI** - is a **tool** which aims to help you and **not** replace your own discretion.
> User discretion - Highly advised
No, I do not hate the AI. It's cool. I hate the *slop* - when the entire "technical guide" article is nothing more then a bunch of AI ejacuation. But how do I know that slop is a slop?
I hate the *slop* - when the entire "technical guide" article is nothing more then a bunch of AI ejacuation. But how do I know that slop is a slop?
Yeah.. I have to read it. And I had _enough_ of reading. So I want to see a warning badge like "its AI" - to help me navigate through text/image content.
AI/Human classification can be done in four different modes (sorted in order of preference for the potato hardware):
AI/Human classification can be done in three modes:
0. _(potato)_: No classification
1. _(normal)_: Lightweight model, which can have "no decision at all" in some cases
2. _(high)_: Lightweight model still does its job, but when its decision is weak - heavy model takes the task
3. _(ultra)_: Heavy and more accurate model performs always, lightweight model is disabled
1. _(lite)_: Lightweight model
2. _(mixed)_: Lightweight model runs first, but when its decision is weak - heavier model takes the task. This is usually faster, but requires both lite and heavy models to be loaded thus eating lots of RAM
3. _(hard)_: Heavier and more accurate model takes all tasks, lightweight model is disabled
The _normal_ mode requires ~150Mb of RAM for text classification and ~200Mb of RAM for image classification.
The _lite_ mode requires ~80Mb of RAM for text classification
The _ultra_ mode requires ~700Mb of RAM for text classification and ~500Mb of RAM for image classification.
The _mixed_ mode requires ~380Mb of RAM for text classification
## `Microslop` mode
The _hard_ mode requires ~300Mb of RAM for text classification
> Slop-sloppity slop, micro slop slop slop, microslop microslop microslop
## Installation
That's easy. Turn is on and every time the page contains word "microsoft" (except for the URLs) - this extention will replace it with "microslop"
### Building from source
## `Githief` mode
This webextension can be built from source. The following instrumentation is required:
You know what they do with your "licensed" and "private repository" code.
- `cargo` + `cargo-make` + `wasm-pack` (cargo-make will install it automatically)
- `pnpm`
Turn this on - and all "github" (except for urls) shall turn into "githief"
To build both firefox and chrome release versions, run the `release` task:
## `Хуяндекс` mode
```bash
cargo make -p production release
```
At 2025 the "yandex" corporation was caught in bypassing the data permissions on Android smartphones to collect and possibly provide all kinds of your personal information to the third-parties; to track you; to deanon you; thus violating your consent and privacy.
If you do not have `wasm-pack` (cargo) installed, cargo-make will install it for you.
You can read more about it [here](https://localmess.github.io/)
#### Models
They stopped that practice after disclosure, yes, but they did it nontheless.
To only build models, clone the repo, and run `models` task within `production` environment:
So you can turn on this feature and every occurence of word "яндекс" shall be replaced for "хуяндекс" (russian wordplay, something like "fuck-yandex") and every occurence of word "yandex" (except for urls) shall be replaced with your custom word (I did not figure out proper wordplay for it yet).
```bash
cargo make -p production models
```
---
This will compile all implemented models into WASM packages, which are later used by webextension.
## A bit of technical details
NPM-ready packages for both ai-text models will be located under `<repo>/wasm/pkg` directory
## Contributing
##### Using different models for inference
Wooow, I am so very glad thay you're reading this section! Thank you in advance for interest to contributing.
You can build the [text classification](./wasm/model-ai-text) with any ONNX model from huggingface.
As you can see - this is not a github, but there is a [mirror](https://github.com/yiffyrusdev/spushks-firaid-moz), which my friend was so kind to provide. You can open issues and make PRs there - we'll merge them, preserving your identity.
Following env variables are required:
Also, if you sumbit any code, it is considered Apache-2.0
- `_MK_MODEL_AI_TEXT`: name of the huggingface repository (e.g. "onnx-community/text-ai-detection")
- `_MK_MODEL_AI_TEXT_ONNX`: name of the onnx model file under the repository (e.g. "onnx/model.onnx")
Following env variables are optional:
- `_MK_MODEL_AI_TEXT_ATTENTION`: set to `yes` or `1` if your model uses attention mask
- `_MK_MODEL_AI_TEXT_TYPES`: set to `yes` or `1` if your model uses token types tensor
Not every model will work, and not every model which works will compute valid results.
Major constraints are:
- FP32 or FP16 weights (quantizations, int8, etc will be available when implemented by burn/burn-onnx)
- Sane size, 500Mb is your soft ceiling (browsers would likely refuse to load enormous WASM)
- Two label classification, where label `[0]` is Human and `[1]` is AI
- Output is `[0, 2]` sized tensor of *logits*
If you encounter compilation error, and compiler complains about invalid `forward` function arguments,
most likely you set the wrong `_MK_MODEL_AI_TEXT_ATTENTION` and `_MK_MODEL_AI_TEXT_TYPES` values.
#### Extension
> You must build models before running this
To only build the extension, clone the repo, build models, then you can run following tasks:
- `extension`: build and zip firefox and chrome extensions
- `extension_moz`: only build firefox extension
- `extension_chro`: only build chrome extension
- `dev`: run wxt dev server (chrome variant)