Status: Architecture audit + concrete upgrade path
Date: 2025-05-05
Issues: Closes #61, Closes #55
| Layer | Implementation | Type |
|---|---|---|
| Humanization core | lib/humanizer.ts β multi-pass LLM rewriting with sentence-level rehumanization |
Prompt engineering |
| Prompt engine | lib/prompts.ts β tone/style/domain-aware system prompts with anti-detection instructions |
Prompt engineering |
| Post-processing | lib/postprocess.ts β regex-based phrase replacement + synonym injection |
Rule-based |
| Style modeling | lib/style-model.ts + public/corpus-style-model.json β statistical corpus features injected into prompts |
Hybrid (stats β prompts) |
| Scoring | lib/detector.ts, lib/readability.ts β burstiness, lexical diversity, readability |
Heuristic |
| Training scripts | scripts/model/train-framework.mjs β logistic regression on extracted features |
Lightweight ML |
| Python training | training/train_model.py β basic T5 fine-tuning (prototype) |
Prototype ML |
The core humanization loop is 100% prompt-dependent. Every text transformation goes through an LLM call shaped by prompts. The system's quality ceiling is bounded by:
- LLM provider quality β GPT-4, Claude, etc.
- Prompt effectiveness β anti-detection instructions in
prompts.ts - Post-processing coverage β finite regex/synonym rules
There is no learned model performing the actual rewriting. The "style model" (corpus-style-model.json) provides statistical parameters that get injected into prompts, not a neural model that transforms text directly.
- β Fast iteration β prompt changes deploy instantly
- β Multi-provider support (13 providers)
- β Rich tone/style/domain configuration
- β
Existing data pipeline infrastructure (
data/,scripts/papers/)
- β No local inference capability β always requires an LLM API
- β Quality varies by provider and model
- β Latency proportional to LLM response time
- β Cost scales with usage (API calls)
- β T5 training script is a minimal prototype, not production-ready
- β No evaluation benchmarking against real AI detectors
- β No experiment tracking or model versioning
Goal: Build a robust data pipeline that produces high-quality training pairs from 10k+ Q1 open-access papers.
Components:
| Component | File | Purpose |
|---|---|---|
| Paper ingestion | data/collector.py |
Fetch from arXiv, PubMed, Semantic Scholar |
| Text cleaning | data/cleaner.py |
Remove citations, normalize whitespace |
| Pair generation | data/pair_generator.py |
Create (AI-like β human) rewrite pairs |
| Dataset builder | data/dataset_builder.py |
Assemble final training corpus |
| Full pipeline | data/full_pipeline.py |
Orchestrate all stages |
| Configs | data/models/train.q1-oa-10k.json |
10k paper training configuration |
Data sources: arXiv, PubMed Central, Semantic Scholar, CrossRef (all open-access).
Goal: Production-ready training pipeline with experiment tracking and quality gates.
Components:
| Component | File | Purpose |
|---|---|---|
| Training config | data/models/train.config.example.json |
Hyperparameters, thresholds |
| Training script | training/train_model.py |
T5/BART fine-tuning with proper setup |
| Inference | inference/local_model.py |
Local model inference |
| Evaluation | scripts/model/evaluate-framework.mjs |
Metrics + quality gates |
| Experiment tracking | data/models/lineage/experiments.jsonl |
Reproducibility |
βββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Input Text βββββΆβ ML Rewrite βββββΆβ Scoring β
β β β (T5/BART) β β + Fallback β
βββββββββββββββ ββββββββββββββββ ββββββββ¬ββββββββ
β
βββββββββββββΌβββββββββββ
β Score < threshold? β
ββββ¬ββββββββββββββββ¬ββββ
Yes β β No
βΌ βΌ
ββββββββββββββββ ββββββββββββ
β LLM Fallbackβ β Output β
β (current) β β β
ββββββββββββββββ ββββββββββββ
Key design decisions:
- ML-first with LLM fallback β local model handles 80%+ of cases, LLM only for edge cases
- Unified scoring β same metrics for ML and LLM outputs
- Gradual rollout β A/B test ML vs LLM before switching default
- Fine-tune larger models (BART-large, T5-3B) on accumulated training data
- Add domain-specific model heads (academic, creative, technical)
- Deploy as ONNX/TensorRT for fast local inference
- Remove LLM dependency entirely for core humanization
- Enhanced ML training pipeline (
training/train_model.py) - Data pipeline for 10k Q1 papers (
data/) - Evaluation metrics and quality gates
- Configuration files for reproducible training
- Technical review documentation (this file)
- Integrate local model inference into API routes
- Add A/B testing between ML and LLM paths
- Benchmark against GPTZero, Originality.ai, Turnitin
- Add ONNX export for deployment
- Domain-specific fine-tuning (academic, creative, technical)
- Continuous learning pipeline (user feedback β retraining)
- Model serving infrastructure (Docker, GPU support)
| Risk | Likelihood | Mitigation |
|---|---|---|
| Training data quality issues | Medium | Multi-source validation, deduplication, quality scoring |
| Model doesn't beat LLM quality | Medium | Hybrid fallback ensures no regression |
| GPU requirements too high | Low | Start with T5-small/base, quantize for inference |
| Data pipeline scaling to 10k papers | Low | Batch processing, incremental updates |
| Metric | Current (Prompt-only) | Target (ML + Hybrid) |
|---|---|---|
| GPTZero bypass rate | ~70% (depends on provider) | >85% |
| Latency (p/500 words) | 2-5s (LLM API) | <1s (local ML) |
| Cost per 1000 humanizations | $0.50-2.00 (API) | ~$0 (local) |
| Offline capability | β | β |