ai-content-detector / README.md
Deepesh Rathore
Deploy AI Content Detector suite and custom model weights
ff76684 verified
|
Raw History Blame Contribute Delete
6.69 kB
---
language:
- en
license: mit
tags:
- ai-content-detector
- text-classification
- nlp
- forensics
pipeline_tag: text-classification
widget:
- text: "Artificial intelligence has undeniably revolutionized modern natural language processing systems across global academia."
---
# AI Content Detector: Explainable Multi-Vector Forensic Intelligence Suite
> **Multi-Tier Forensic System**
> *Designed for academic and professional evaluators to detect, quantify, localize, and explain generative AI text across 7 document formats while rigorously preventing false accusations.*
---
## 🌟 Core Architecture & Solution Mapping
| Problem Requirement | Evaluator Scenario & Need | VeritasDoc Architectural Solution |
|---|---|---|
| **1. Ingest Documents** | Diverse file formats (`.pdf`, `.docx`, `.doc`, `.pptx`, `.ppt`, `.rtf`, `.txt`) | Unified parsing pipeline preserving document structural hierarchy and computing **SHA-256** checksum. |
| **2. Detect AI Content** | Separate machine-generated text from authentic human prose | **Tri-Layer Neural Consensus** combining Syntactic Discourse (Core Alpha), Generative Cadence (Core Beta), and Adversarial Evasion (Core Gamma). |
| **3. Quantify AI Usage** | Mixed/hybrid documents with both human and AI sections | **Character-weighted token attribution** with **3-sentence Gaussian boundary smoothing** ($\tilde{S}_i = 0.70 S_i + 0.15 S_{i-1} + 0.15 S_{i+1}$). |
| **4. Localize & Explain** | Point directly to flagged sentences with transparent reasoning | **3-Color Visual Heatmap** (Red $\ge 70\%$, Yellow $45-69\%$, Green $< 45\%$) paired with a **Diagnostic Explainability Card** for every sentence. |
| **5. Minimize False Positives** | Avoid wrongful accusations against innocent authors | **Platt-scaled calibration**, **3-Zone Academic Decision Matrix** (Green $<25\%$, Yellow $25-65\%$, Red $>65\%$), **ESL Safeguard**, and sensitivity modes (Conservative, Balanced, Aggressive). |
| **6. Evaluator UI & Export** | Intuitive inspection and tamper-evident audit export | Modern split-screen dashboard with live heatmaps and 1-click **SHA-256 hashed PDF audit certificate**. |
---
## πŸš€ All 4 Bonus Innovators Implemented
1. **AI Platform Origin Attribution:**
- Detects generating platform (**ChatGPT-4o**, **Claude 3.5**, **Google Gemini**, **Microsoft Copilot**) with empirical confidence scores and stylistic token markers (`delve`, `tapestry`, `furthermore`, etc.).
2. **Humanizer / QuillBot Evasion Detector:**
- Detects bypass tools (**Undetectable.ai**, **HideMyAI**) via **Semantic Dissonance Detection** and **Perturbation Anomaly** analysis.
3. **LMS Plugin Hook & Chrome Extension (Manifest V3):**
- **Canvas / Moodle Webhook** endpoint (`POST /api/lms/webhook`).
- Ready-to-load **Manifest V3 Chrome Extension** in `extension/` directory for zero-friction browser overlay inspection.
4. **Multilingual & Regional Support:**
- Cross-lingual support for Hindi, Spanish, French, and German.
---
## πŸ—οΈ Project Structure
```
ai-detector/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ main.py # FastAPI application, routes (/analyze, /recalculate, /health, /history, /pdf, LMS webhook)
β”‚ β”œβ”€β”€ config.py # Zero-configuration defaults from environment (.env)
β”‚ β”œβ”€β”€ database.py # Native SQLite (WAL mode) with automatic migrations
β”‚ β”œβ”€β”€ extractor.py # Multi-format parser (.pdf, .docx, .doc, .pptx, .ppt, .rtf, .txt) & Hierarchical Tree
β”‚ β”œβ”€β”€ sanitizer.py # Zero-width stripping, NFKC normalization, homoglyphs, ligatures & SHA-256
β”‚ β”œβ”€β”€ detector.py # Tri-Layer Neural Consensus Engine (Alpha, Beta, Gamma cores)
β”‚ β”œβ”€β”€ forensics.py # Perplexity (PPL), Burstiness (B), Zipfian, Stylometrics, ESL Safeguard
β”‚ β”œβ”€β”€ analyzer.py # Gaussian smoothing, character weighting, 3-zone matrix, explainability
β”‚ β”œβ”€β”€ reporter.py # Tamper-evident ReportLab PDF audit certificates with SHA-256
β”‚ └── utils.py # Sentence tokenizers & confidence calculation
β”œβ”€β”€ extension/ # Chrome Extension Manifest V3 (Bonus 3)
β”‚ β”œβ”€β”€ manifest.json # Manifest V3 configuration
β”‚ β”œβ”€β”€ content.js # Floating inspector overlay on any webpage / LMS
β”‚ β”œβ”€β”€ popup.html # Evaluator popup inspection UI
β”‚ └── popup.js # Local consensus inspection client
β”œβ”€β”€ static/
β”‚ β”œβ”€β”€ index.html # Evaluator split-screen dashboard with Tailwind CDN
β”‚ └── app.js # Vanilla JavaScript client (dropzone, heatmaps, diagnostic cards, PDF export)
β”œβ”€β”€ data/ # Auto-created on startup (persists across reboots)
β”‚ β”œβ”€β”€ analyses.db # SQLite database file (WAL mode)
β”‚ └── uploads/ # Saved uploaded documents
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ run.bat # Windows 1-click launcher
β”œβ”€β”€ start.bat # Alternative Windows launcher
β”œβ”€β”€ main.py # Root Python launcher
└── README.md
```
---
## ⚑ Quickstart Guide
### 1. Launch the Server (Single Command)
**On Windows:**
```cmd
run.bat
```
or
```cmd
python main.py
```
- Web UI: **[http://localhost:8000](http://localhost:8000)**
- Health endpoint: **[http://localhost:8000/health](http://localhost:8000/health)**
---
## πŸ§ͺ 5-Minute Evaluator Demo Script
1. **Step 1: Inspect System Health**
- Open `http://localhost:8000/health`.
- Confirm active multi-vector neural cores:
```json
{
"status": "ok",
"model": "Multi-Vector Neural Consensus (3/3 Cores Active)",
"model_loaded": true,
"device": "cpu",
"model_type": "neural_consensus"
}
```
2. **Step 2: 1-Click Instant Evaluation**
- Click `πŸ€– Pure AI Essay` on the dashboard.
- In 1 second, the radial gauge renders with **Red Zone (>65%)**, highlighting monotonous sentence cadence, low Perplexity ($PPL < 20$), and attributing to **ChatGPT-4o (89% confidence)**.
3. **Step 3: Test Interactive Split-Screen & Diagnostic Drawer**
- Click any sentence in the left document text.
- The **Diagnostic Explainability Card** on the right instantly inspects that specific sentence, showing its **smoothed score**, **sentence perplexity**, **clichΓ©s found**, and linguistic reasoning.
4. **Step 4: Export Official Tamper-Evident PDF Certificate**
- Click **"Export PDF Certificate"** to download the institutional audit certificate containing the cryptographic **SHA-256 checksum**, **3-Zone Academic Verdict**, **Neural Consensus Matrix**, and **Evaluator Disclaimers**.