How rasbt/ai-detector-from-scratch works
This repository builds and evaluates an AI-text detector, then exposes trained classifiers for local scoring. The documented workflow runs from licensed human-text collection and AI/AI-assisted generation through dataset construction, model training, evaluation, and inference. The inference library selects and loads model artifacts, computes probabilities, and formats scores; CLI, browser, and Substack workflows use that capability. Additional branches cover resource/latency benchmarking and reinforcement-learning verifier experiments. Several training and analysis stages are documented but absent from the supplied tree, so those nodes use null paths; relationships are limited to README statements or shown calls.
Main entry points: classifiers.py Classifier loaders · 01_collect_licensed_human_text.py Human collection · _generate_ai_texts.py AI generation · _generate_assisted_texts.py Assisted edits
Components 18
Data construction
- Human collection
scripts/01_human-data/01_collect_licensed_human_text.py - AI generation
scripts/02_ai-data/_generate_ai_texts.py - Assisted edits
scripts/03_ai-assisted-data/_generate_assisted_texts.py - Pangram checks
scripts/02_ai-data/pangram-check/run_check.py - Dataset assembly
scripts/04_hf-dataset/04_build_hf_dataset.py
Model development
- Classifier training
- Resource benchmarks
scripts/14_resource-latency/_benchmark_model.py
Inference runtime
- Model registry
src/ai_detector/registry.py - Classifier loaders
src/ai_detector/classifiers.py - Score validation
src/ai_detector/scoring.py - Artifact download
scripts/15_classifier-api/download-models.py
Scoring applications
- Scoring CLI
scripts/15_classifier-api/classify.py - Browser API
scripts/17_browser-ui/app.py - Browser interface
scripts/17_browser-ui/frontend/src/App.jsx
Research workflows
- Substack evaluation
scripts/16_case-study-substack/predict_substack_notes.py - Verifier RL
scripts/18_reinforcement-learning/05_train_grpo_human_writing.py
Other components
- Licensed text sources
- Model providers
Connections 24
- Licensed text sources → Human collection: collects text
scripts/01_human-data/01_collect_licensed_human_text.py - Human collection → AI generation: seeds generation
README.md - Model providers → AI generation: generate samples
README.md - Model providers → Assisted edits: edit samples
README.md - Human collection → Assisted edits: source texts
README.md - AI generation → Pangram checks: check samples
README.md - Assisted edits → Pangram checks: check edits
README.md - Human collection → Dataset assembly: assemble data
README.md - AI generation → Dataset assembly: assemble data
README.md - Assisted edits → Dataset assembly: assemble data
README.md - Dataset assembly → Classifier training: provides dataset
README.md - Classifier training → Model registry: exports classifiers
README.md - Model registry → Classifier loaders: supplies model specs
src/ai_detector/classifiers.py - Classifier loaders → Score validation: validates text
src/ai_detector/classifiers.py - Artifact download → Model registry: uses model registry
- Scoring CLI → Classifier loaders: loads classifier
README.md - Scoring CLI → Score validation: formats score
README.md - Browser interface → Browser API: requests scores
scripts/17_browser-ui/frontend/src/App.jsx - Browser API → Classifier loaders: scores text
scripts/17_browser-ui/app.py - Browser API → Score validation: formats score
README.md - Substack evaluation → Classifier loaders: loads classifiers
scripts/16_case-study-substack/predict_substack_notes.py - Substack evaluation → Score validation: formats scores
scripts/16_case-study-substack/predict_substack_notes.py - Classifier training → Resource benchmarks: benchmark models
README.md - Classifier loaders → Verifier RL: verifies generations
README.md