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

# Run directly with uv
uvx findllm document.md

# With document conversion support (PDF, DOCX, PPTX, etc.)
uvx --from 'findllm[markitdown]' findllm 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

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.1.tar.gz (10.2 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.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for findllm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7f3ace5818173b4a6c224566fcd5590b946cb9e6be23f0b22c68b005c47b1960
MD5 3b26909ad14a4e72d1e47d124fcafaf8
BLAKE2b-256 b1c0af47dd25547ca94dcda775463d9317322ec4c1b36bb50f90a0fb7551725a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for findllm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 547fee367516c267754650d7caa5858df42cb6296cdb18079e80ec1fdee49cf0
MD5 18635b469dd3486ed65dcd2d779233ce
BLAKE2b-256 4c8a3142ab360daf4e6a9fd04992010abd17bc61b56766efce8e1cc55b6580c6

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