ZipPy: Fast method to classify text as AI or human-generated
 
 
 
 
Go to file
Jacob Torrey e77aeb8e58 Add preset as optional argument
Signed-off-by: Jacob Torrey <jacob@thinkst.com>
2023-10-15 04:43:32 -06:00
.github/workflows Update pytest.yml 2023-09-27 16:54:43 -06:00
inch Update browser extension repo to v0.3.1 2023-09-21 13:33:36 -06:00
nlzmadetect Fix Nim testsuite 2023-09-27 16:47:03 -06:00
samples Added GPTZero's public eval dataset and added it to the test bench 2023-09-14 12:13:25 -06:00
.gitignore
.gitmodules Added code to make Nim compile to CLI and web 2023-06-09 03:46:28 -06:00
LICENSE
README.md Update README to reflect zlib and contentatscale.ai 2023-09-26 08:01:17 -06:00
ai-generated.txt Completed a 500/set test with CHEAT 2023-06-09 03:46:30 -06:00
ai_detect_roc.png Completed evaluation of contentatscale.ai and added zlib support to both the Python and Nim/JS implementations 2023-09-26 07:51:41 -06:00
burstiness.py Initial commit of burstiness analysis 2023-06-09 03:46:29 -06:00
contentatscale-report.xml Completed evaluation of contentatscale.ai and added zlib support to both the Python and Nim/JS implementations 2023-09-26 07:51:41 -06:00
contentatscale_detect.py Initial results from contentatscale.ai added, and removed the OpenAI detector from the ROC chart plotter 2023-09-21 16:37:28 -06:00
crossplag-report.xml Added crossplag results 2023-06-20 21:08:51 -06:00
crossplag_detect.py Remove copy-paste artifact 2023-09-20 16:23:55 -06:00
gptzero-report.xml Completed a 500/set test with CHEAT 2023-06-09 03:46:30 -06:00
gptzero_detect.py Added GPTZero API for testing and comparison 2023-06-09 03:46:29 -06:00
openai-report.xml Completed a 500/set test with CHEAT 2023-06-09 03:46:30 -06:00
openai_detect.py Added OpenAI's detector and all the test run reports along with a ROC diagram 2023-06-09 03:46:29 -06:00
plot_rocs.py Completed evaluation of contentatscale.ai and added zlib support to both the Python and Nim/JS implementations 2023-09-26 07:51:41 -06:00
preset_plot_rocs.py Added preset analysis 2023-10-15 04:42:53 -06:00
roberta-report.xml Rerun with fixed Roberta script 2023-06-09 03:46:31 -06:00
roberta_detect.py Add CUDA support for Roberta (local) and fix an alignment issue 2023-06-15 10:47:50 -06:00
roberta_local.py Add CUDA support for Roberta (local) and fix an alignment issue 2023-06-15 10:47:50 -06:00
test_contentatscale_detect.py Completed evaluation of contentatscale.ai and added zlib support to both the Python and Nim/JS implementations 2023-09-26 07:51:41 -06:00
test_crossplag_detect.py Added crossplag results 2023-06-20 21:08:51 -06:00
test_gptzero_detect.py Completed a 500/set test with CHEAT 2023-06-09 03:46:30 -06:00
test_openai_detect.py Completed a 500/set test with CHEAT 2023-06-09 03:46:30 -06:00
test_roberta_detect.py Fix typo in CHEAT tests 2023-06-09 03:46:30 -06:00
test_zippy_detect.py Added the ability to ensemble different compression models 2023-09-27 13:39:45 -06:00
zippy-lzma-0.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-1.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-2.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-3.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-4.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-5.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-6.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-7.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-8.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-9.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-lzma-report.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-0.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-1.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-2.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-3.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-4.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-5.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-6.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-7.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-8.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-9.xml Added preset analysis 2023-10-15 04:42:53 -06:00
zippy-zlib-report.xml Update test reports 2023-09-27 09:41:44 -06:00
zippy.py Add preset as optional argument 2023-10-15 04:43:32 -06:00

README.md

ZipPy: Fast method to classify text as AI or human-generated

This is a research repo for fast AI detection using compression. While there are a number of existing LLM detection systems, they all use a large model trained on either an LLM or its training data to calculate the probability of each word given the preceeding, then calculating a score where the more high-probability tokens are more likely to be AI-originated. Techniques and tools in this repo are looking for faster approximation to be embeddable and more scalable.

Compression-based detector (zippy.py and nlzmadetect)

ZipPy uses either the LZMA or zlib compression ratios as a way to indirectly measure the perplexity of a text. Compression ratios have been used in the past to detect anomalies in network data for intrusion detection, so if perplexity is roughly a measure of anomalous tokens, it may be possible to use compression to detect low-perplexity text. LZMA and zlib creates a dictionary of seen tokens, and then uses though in place of future tokens. The dictionary size, token length, etc. are all dynamic (though influenced by the 'preset' of 0-9--with 0 being the fastest but worse compression than 9). The basic idea is to 'seed' a compression stream with a corpus of AI-generated text (ai-generated.txt) and then measure the compression ratio of just the seed data with that of the sample appended. Samples that follow more closely in word choice, structure, etc. will acheive a higher compression ratio due to the prevalence of similar tokens in the dictionary, novel words, structures, etc. will appear anomalous to the seeded dictionary, resulting in a worse compression ratio.

Current evaluation

Some of the leading LLM detection tools are: OpenAI's model detector (v2), Content at Scale, GPTZero, CrossPlag's AI detector, and Roberta. Here are each of them compared with both the LZMA and zlib detector across the test datasets:

ROC curve of detection tools

Usage

ZipPy will read files passed as command-line arguments, or will read from stdin to allow for piping of text to it.

$ python3 zippy.py -h
usage: zippy.py [-h] [-e {zlib,lzma}] [-s | sample_files ...]

positional arguments:
  sample_files    Text file(s) containing the sample to classify

options:
  -h, --help      show this help message and exit
  -e {zlib,lzma}  Which compression engine to use: lzma or zlib
  -s              Read from stdin until EOF is reached instead of from a file
$ python3 zippy.py samples/human-generated/about_me.txt 
samples/human-generated/about_me.txt
('Human', 0.06013429262166636)

If you want to use the ZipPy technology in your browser, check out the Chrome extension that runs ZipPy in-browser to flag potentially AI-generated content.