Skip to main content

Detect AI writing patterns. Make text human again.

Project description

ai-text-audit ๐Ÿฆž

PyPI version License: MIT Python 3.8+

Detect AI writing patterns. Make text human again.

A fast, offline CLI tool and Python library that detects AI-generated text patterns based on linguistic analysis โ€” no API keys, no cloud, no privacy concerns.

Built from analysis of 10,000+ AI-generated texts, based on Wikipedia's comprehensive guide to AI writing patterns.

โœจ Features

  • ๐Ÿ” 22+ AI pattern detectors โ€” em-dashes, rule of three, AI vocabulary, promotional language, vague attribution, and more
  • ๐Ÿ“Š Weighted scoring โ€” patterns ranked by severity, not just frequency
  • ๐ŸŽฏ Smart suggestions โ€” actionable rewrite tips for each detected pattern
  • ๐Ÿ”„ Pipeline mode โ€” --json output for CI/CD integration
  • โšก Fast โ€” analyzes 1000 words in <50ms, no network calls
  • ๐ŸŒ Offline โ€” zero external dependencies for core detection
  • ๐Ÿ› ๏ธ Extensible โ€” add your own patterns with simple YAML config
  • ๐Ÿ“ Batch mode โ€” process entire directories or stdin

๐Ÿš€ Quick Start

pip install ai-text-audit

# Analyze a file
ai-audit README.md

# Analyze from stdin
echo "This groundbreaking tool represents a pivotal advancement..." | ai-audit -

# JSON output for pipelines
ai-audit --json document.md

๐Ÿ“– Usage

CLI

# Basic analysis
ai-audit document.txt

# With detailed pattern breakdown
ai-audit --verbose document.txt

# JSON output
ai-audit --json document.txt > report.json

# Set threshold (0-100, default: 30)
ai-audit --threshold 50 document.txt

# Show only score (for scripting)
ai-audit --score-only document.txt

# Batch directory
ai-audit --batch ./docs/

# Pipeline: check then humanize
cat draft.md | ai-audit - --humanize

Python API

from ai_text_audit import Auditor

auditor = Auditor()
result = auditor.analyze("This groundbreaking innovation represents a pivotal moment...")

print(result.score)          # 72.3 (0-100, higher = more AI-like)
print(result.verdict)        # "likely_ai" | "possibly_ai" | "likely_human"
print(result.patterns)       # List of detected patterns with counts
print(result.suggestions)    # Rewrite suggestions per pattern

# Custom patterns
auditor = Auditor(patterns_file="my_patterns.yaml")

# Batch
results = auditor.analyze_dir("./docs/")

Output Examples

Terminal (default):

๐Ÿฆž AI Text Audit โ€” document.md
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
Score: 72.3 / 100  โ†’  ๐Ÿค– Likely AI

Patterns detected:
  โš ๏ธ  em_dash (ร—8)              "โ€”" appears frequently, uncommon in casual writing
  โš ๏ธ  ai_vocab (ร—12)            Words like "crucial", "pivotal", "tapestry"
  โšก rule_of_three (ร—5)          "X, Y, and Z" structure overused
  โšก boast_language (ร—3)         "stands as a testament", "boasts"
  ๐Ÿ’ก promotional (ร—2)           "groundbreaking", "cutting-edge"

Suggestions:
  โ†’ Replace "โ€”" with ", " or "."
  โ†’ Swap "crucial" โ†’ "important", "pivotal" โ†’ "key"
  โ†’ Vary list structures beyond "A, B, and C"

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

JSON (--json):

{
  "file": "document.md",
  "score": 72.3,
  "verdict": "likely_ai",
  "word_count": 847,
  "patterns": [
    {"name": "em_dash", "count": 8, "weight": 1, "severity": "low", "description": "..."},
    {"name": "ai_vocab", "count": 12, "weight": 1, "severity": "medium"}
  ],
  "suggestions": ["Replace em-dashes with commas..."]
}

๐Ÿ”ง Detection Patterns

Pattern Weight Example Why It's AI
em_dash 1 โ€” Overused in AI, rare in casual writing
ai_vocab 1 "crucial", "tapestry", "delve" Hallmark AI vocabulary
rule_of_three 0.5 "A, B, and C" AI loves triplets
negative_parallelism 2 "It's not just X, it's Y" Classic AI structure
boast_language 2 "stands as a testament" Promotional framing
promotional 2 "groundbreaking", "revolutionary" Buzzword density
vague_attribution 2 "experts say", "many believe" Fake authority
collaborative_artifact 3 "I hope this helps!" Chatbot leftovers
filler 1 "It is important to note" Academic filler phrases
ing_superficial 2 "...ing, reflecting" Superficial analysis pattern

See docs/patterns.md for the full list of 22+ patterns.

๐Ÿ› ๏ธ Configuration

Create ~/.ai-audit.yaml or pass --config:

# Custom patterns
patterns:
  my_custom:
    regex: "\\b(synergy|leverage|optimize)\\b"
    weight: 1
    description: "Corporate buzzwords"

# Thresholds
thresholds:
  likely_ai: 60
  possibly_ai: 30

# Ignore files
ignore:
  - "*.min.js"
  - "vendor/**"

๐Ÿ—๏ธ CI/CD Integration

GitHub Actions

- name: Check for AI writing
  run: |
    pip install ai-text-audit
    ai-audit --threshold 50 --json . > audit.json
    SCORE=$(jq '.score' audit.json)
    if (( $(echo "$SCORE > 50" | bc -l) )); then
      echo "::warning::Content score is $SCORE โ€” likely AI-generated"
    fi

Pre-commit Hook

repos:
  - repo: https://github.com/sudabg/ai-text-audit
    rev: v1.0.0
    hooks:
      - id: ai-audit
        args: ['--threshold', '40']

๐Ÿ“ฆ Installation

# PyPI (recommended)
pip install ai-text-audit

# From source
git clone https://github.com/sudabg/ai-text-audit.git
cd ai-text-audit
pip install -e .

# With optional dependencies
pip install ai-text-audit[full]  # includes rich, pyyaml

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md.

Good first issues:

  • Add new detection patterns
  • Improve existing pattern accuracy
  • Add support for more languages (currently optimized for English + Chinese)
  • Write tests for edge cases

๐Ÿ“„ License

MIT License โ€” see LICENSE.

๐Ÿ™ Acknowledgments

๐Ÿ“ˆ Roadmap

  • v1.0.0 โ€” Core detection + CLI (this release)
  • v1.1.0 โ€” Stylometric analysis (sentence length variance, vocabulary richness)
  • v1.2.0 โ€” Perplexity-based detection (lightweight, local)
  • v1.3.0 โ€” Multilingual support (Japanese, Korean, etc.)
  • v2.0.0 โ€” Self-hosted API server mode

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

ai_text_audit-1.0.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

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

ai_text_audit-1.0.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file ai_text_audit-1.0.0.tar.gz.

File metadata

  • Download URL: ai_text_audit-1.0.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ai_text_audit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1490e88ba60104317c783416044215f06d0087502dcc9e9ec0fea6733acceeb7
MD5 2abc3a5a306889ec5c792177fb55f6c2
BLAKE2b-256 306da6ab5f2cb29640587c718caf91c7c1c2fe80c6d7a2471a571d8cece9d912

See more details on using hashes here.

File details

Details for the file ai_text_audit-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ai_text_audit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ai_text_audit-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7b1008440216e8e1174c17e1bff506a93d4806e19cc7fed0882224cef73aef1
MD5 7bc6998334a43ef57372ef5da8316945
BLAKE2b-256 551127f578a52209e6f0aa18c36d5e622409a39b327539434757e6c46905872c

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