An ultra-lightweight AI content blocker browser extension powered by regex-based pattern matching and linguistic analysis. It has an average precision of about 80-90% in correctly classifying human text, and an average precision of around 80% in detecting an AI-generated corpus.
In the current era, the Internet is becoming increasingly plagued with AI-written or inauthentic content. It may not be much of a problem for some, but many people wish to not see this type of content on the Web. Extinction is a proof-of-concept browser extension that blocks AI-generated text across many websites, with built-in whitelisting support.
Traditional AI content detectors rely on either heavy machine learning (ML) and/or intensive pretraining for a basic classifier model, which are far from ideal for a mere browser extension. They usually measure values such as perplexity, burstiness, and token probability patterns to determine whether or not a text is generated by AI. Although, admittedly, regex-based detection cannot be as precise as ML-based detection, it can reach satisfactory levels when certain exceptions/limitations are implemented.
This section explains Extinction's algorithm and how it classifies text as either human-written or AI-written.
Extinction uses a precompiled list of regular expressions, with each regex pattern assigned a certain "point" value depending on how common it appears in AI-generated content.
- Some regexes have a negative score. A negative score indicates that the pattern is more common in human text than in AI text.
- This helps increase accuracy by limiting the impact of outliers in the content.
The TextClassifier.analyze function is used to analyze a given article using a chunkSize-length sliding window as well as using several functions to analyze the linguistic characteristics of the corpus.
-
The match map is an object with keys as scores and values as the number of matches for a score.
-
The alpha is a parameter that is used to later scale the score for normalization.
-
The step, or stride, of the window is defined by
chunkSize / 1.25, meaning that the windows/chunks overlap by about 20%.- This overlap is used to account for patterns that span across chunk boundaries.
- In each step, the following operations occur:
-
Loop through the scores in the
patterns.yamlfile.- The patterns are grouped by score. For example, a score of
7.5contains seven regex patterns.
- The patterns are grouped by score. For example, a score of
-
Under each score, loop through the regex patterns and match it with the chunk with the flags
/gimu. -
Count the number of matches for each regex.
-
If the number of matches is greater than 0, do the following:
- Add
Math.log1p(numberOfMatches) * regexScoreto the alpha. - Add the number of matches to the score in the match map.
- Add
-
-
The windows continue to slide until the end of the corpus is reached.
-
The lexical diversity is then calculated by finding the ratio of the number of unique words (tokens) to the number of total tokens.
-
Next, the burstiness is calculated by analyzing the sentence length variance throughout the corpus.
-
The overall linguistic score is finally calculated by applying weights to the lexical diversity and burstiness to produce a combined value.
-
At the end, a three-item array containing the match map, the resulting alpha, and the linguistic score is returned.
The TextClassifier.calculatePatternScore function calculates the pattern score by iterating through the entries in the match map and summing the products of the keys and values. In pseudocode:
patternScore = Σ (score * matches) for each (score, matches) in matchMap
The TextClassifier.normalizeScore function adjusts the scores to account for both the size of the corpus (in characters) and the pattern intensity (alpha). The function follows the steps:
-
Scale the alpha exponentially:
scaledAlpha = |alpha| ^ scaleThe equation takes the absolute value of
alpha(to avoid negative scaling) and raises it to thescalepower. -
Combine with the raw score and corpus length:
exponent = (-scaledAlpha * patternScore ^ linguisticScore) / corpusLengthIn this step, we multiply the score by the scaled alpha to weight the score by the detected pattern intensity. We then divide by the length of the corpus so longer texts do not automatically get higher scores.
-
Run an exponential transform:
normalizedScore = 1 - exp(exponent)The weighted score into a number between 0 and 1 (ideally, if the score is not negative). This reduces the impact of outliers and makes the score more comparable.
The following guide explains how to install Extinction as a browser extension on Chromium-based and Firefox-based browsers.
You must have the following components installed on your system:
- A modern browser that is either Chromium-based (e.g., Chrome, Edge, Brave, Opera) or Firefox-based (e.g., Firefox, LibreWolf, Zen, Floorp).
- Node.js, in order to build the extension from source.
These steps assume you are operating on a Bash shell. Make sure you have already properly installed the requirements listed above.
- Clone the repository
git clone https://github.com/extinctionteam/extinction.git
cd extinction- Install the dependencies
npm install- Build the extension
TARGET=firefox npm run build # for Firefox browsers
TARGET=chrome npm run build # for Chromium browsersThis will create a dist_{TARGET} folder containing the packaged extension.
To install Extinction on a Chromium-based browser, make sure you have successfully built the project. Then, follow the steps:
- Open
chrome://extensionsin your browser. - Enable Developer Mode using the toggle.
- Click Load unpacked and select the
dist_chromefolder generated by the build operation.
After loading the extension, Extinction should appear in your extension list. If you want, you can pin it to your toolbar for easier access to the menu.
To install Extinction on a Firefox-based browser, you should follow the guide:
- Open
about:debugging#/runtime/this-firefoxin your browser. - Click Load Temporary Add-on… and select any file from the
dist_firefoxfolder generated by the build operation.
Important
Temporary add-ons in Firefox disappear after the session ends or after the browser restarts.
To report an issue or bug, visit Extinction's issue tracker on GitHub.
To push your features or fixes into this official repository:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/my-feature) or a fix branch (git checkout -b fix/my-fix). - Commit your changes (
git commit -m "feat: add new feature"). Please follow the Conventional Commits guideline when doing so! - Push the branch (
git push origin feature/my-feature). - Open a pull request with
contribas the base branch. Make sure to create a detailed title and description of your change.
Please follow the GitHub flow and Observatory's Code of Conduct when submitting a pull request.
Extinction is free software distributed under the GNU General Public License, version 3.0 or later (GPL-3.0+).
You are free to use, modify, and share the software under the terms of the GPL. For full details, see the GNU General Public License v3.0.