Skip to main content

Detect AI-generated text using GPT-2 token prediction analysis

Project description

findllm - Detect AI-generated text by analyzing token prediction patterns using GPT-2.

https://github.com/user-attachments/assets/89d03001-7cef-4b9e-878d-c991bd520f18

Installation

[!IMPORTANT] This project was 99% vibe coded using gemini 3 Pro, sonnet 4.5 and opus 4.5. The model tends to identify AI text as human text more often than the reverse. The metrics can't be fully trusted though, so use everything with caution!

# Run directly with uv
uvx findllm document.md

# With document conversion support (PDF, DOCX, PPTX, etc.)
uvx 'findllm[markitdown]' document.pdf

# Or install into your environment
pip install findllm

# With document conversion support
pip install 'findllm[markitdown]'

Usage

# Analyze a text file (sentence mode by default)
findllm document.md

# Analyze documents (PDF, DOCX, PPTX, XLSX, etc.) - requires markitdown extra
findllm paper.pdf
findllm presentation.pptx
findllm report.docx

# Use token-level analysis
findllm document.md --mode token

# Chunk sentences into smaller batches (e.g., 10 tokens per chunk)
findllm document.md --max-sentence-tokens 10

# Skip short sentences (e.g., less than 5 tokens, default is 3)
findllm document.md --min-sentence-tokens 5

# Use different aggregation methods (mean, max, l2, rmse, median, default is l2)
findllm document.md --aggregation max

# JSON output for programmatic use
findllm document.md --json

Document Support

With the markitdown extra installed, findllm can analyze various document formats:

  • PDF (.pdf)
  • Microsoft Office (.docx, .pptx, .xlsx)
  • HTML (.html, .htm)
  • Rich Text (.rtf)
  • And more - see markitdown for full format support

Documents are automatically converted to markdown in-memory before analysis.

How It Works

The tool analyzes how predictable each token in the text is according to GPT-2:

  • Green = Low probability (unpredictable, human-like)
  • Yellow = Moderate probability
  • Orange = Higher probability
  • Red = High probability (predictable, AI-like)

AI-generated text tends to follow predictable patterns that language models can easily anticipate. Human writing is more variable and surprising.

Metrics

  • Perplexity: How "surprised" the model is overall (lower = more predictable)
  • Burstiness: Variation in complexity (humans tend to write with more variation)
  • Color Distribution: Percentage of green/yellow/orange/red tokens

Evaluation

Evaluation on 150 samples from https://www.kaggle.com/datasets/shanegerami/ai-vs-human-text

Image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

findllm-0.1.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

findllm-0.1.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file findllm-0.1.2.tar.gz.

File metadata

  • Download URL: findllm-0.1.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for findllm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9e5ca9a2ae5d850758fa0ff549a1d9679c8082020c4c63252199bc9d3537eebb
MD5 8c27efc61b47688fbd3847e9e298c790
BLAKE2b-256 eb09f0aee982ada7586cce6f2c1cb3a63817c3a0bb7c938cce09e5ecf9606aa7

See more details on using hashes here.

File details

Details for the file findllm-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: findllm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for findllm-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a67d68512ec714a1ce24b7e27331050a89c5d8c472a056b510759eb2a2630dea
MD5 d51bec1d7b59c56df656ec85f77a639d
BLAKE2b-256 7293554fcc3ac8fd32081807f5d217b639968fac6b8c672db721b8fc423226a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page