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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DiffusionGemma Humanizer β Architecture & Strategy
|
| 2 |
+
|
| 3 |
+
> **Date:** 2026-06-29
|
| 4 |
+
> **Budget:** $250 Modal credits
|
| 5 |
+
> **Target:** GPTZero, GPTDetector, Pangram, Binoculars
|
| 6 |
+
> **Objective:** Fine-tune DiffusionGemma to humanize AI-generated text and evade detection
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
## 1. Why Diffusion Models Beat Detectors (Paper-Backed)
|
| 11 |
+
|
| 12 |
+
### 1.1 The Theoretical Ceiling (Sadasivan et al., 2023)
|
| 13 |
+
|
| 14 |
+
**Theorem 1** proves mathematically: AUROC β€ 1/2 + TV(M,H) β TV(M,H)Β²/2, where TV(M,H) is the total variation distance between machine and human text distributions. As models improve and TV β 0, every detector converges to random guessing (AUROC β 0.5). This is not a technological limitation β it's a mathematical certainty. [arXiv:2303.11156]
|
| 15 |
+
|
| 16 |
+
**Implication:** 0% detection (AUROC = 0.5) is achievable asymptotically. A model that perfectly mimics human text distribution is undetectable by definition. We don't need perfection today β we just need TV(M,H) to be lower than what detectors have been trained to distinguish.
|
| 17 |
+
|
| 18 |
+
### 1.2 Pangram's Blind Spot: No Diffusion Text
|
| 19 |
+
|
| 20 |
+
Pangram's DAMAGE detector (Mistral NeMo 12B + LoRA + linear head) was trained exclusively on autoregressive text: GPT-3.5/4/4o, Claude 2/3, LLaMA 2/3/3.1, Mistral, Gemini Pro/Flash. Their "synthetic mirror prompts" all target instruction-tuned autoregressive models. **Zero diffusion-generated text in their training set.** [arXiv:2501.03437]
|
| 21 |
+
|
| 22 |
+
Key finding from their adversarial attack (Β§7):
|
| 23 |
+
- When they fine-tuned GPT-4o specifically against their detector: TPR dropped from 100% β 93.2%
|
| 24 |
+
- This was with a generic fine-tune API, not a custom architecture
|
| 25 |
+
- A purpose-built diffusion humanizer would exploit a fundamentally different statistical pathway they've never seen
|
| 26 |
+
|
| 27 |
+
### 1.3 Adversarial Paraphrasing Works (Cheng et al., 2025)
|
| 28 |
+
|
| 29 |
+
The closed-loop optimization is the secret: paraphrasing WITHOUT detector guidance **increases** detection by 8-15%. With detector feedback guiding the paraphrase, TPR drops by **87.88% average**. The innovation is in the feedback loop, not the base model. [arXiv:2506.07001]
|
| 30 |
+
|
| 31 |
+
**Our advantage:** We can embed this feedback loop *inside* the diffusion denoising process, eliminating the need for an external autoregressive LLM that would leave AR-specific traces.
|
| 32 |
+
|
| 33 |
+
### 1.4 Diffusion Text Naturally Evades AR-Trained Detectors (TarΔ±m & Onan, 2025)
|
| 34 |
+
|
| 35 |
+
LLaDA-generated text "closely mimics human text in perplexity and burstiness, yielding high false-negative rates for AR-oriented detectors." Diffusion models generate through iterative denoising β left-to-right token probabilities don't exist, so perplexity-based methods break. [HF Papers:2507.10475]
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
## 2. Architecture Proposal
|
| 40 |
+
|
| 41 |
+
### 2.1 Base Model: DiffusionGemma 26B
|
| 42 |
+
|
| 43 |
+
| Property | Value |
|
| 44 |
+
|----------|-------|
|
| 45 |
+
| Total params | 25.2B |
|
| 46 |
+
| Active params | 3.8B (MoE, 8/128 experts + 1 shared) |
|
| 47 |
+
| Generation | Discrete diffusion, block-autoregressive, 256-token canvases |
|
| 48 |
+
| Attention | Bidirectional in decoder, cross-attention to AR encoder |
|
| 49 |
+
| Sampling | Entropy-Bounded Denoising, 1β48 steps, temperature 0.8β0.4 |
|
| 50 |
+
| License | Apache 2.0 |
|
| 51 |
+
| Release | June 9, 2026 |
|
| 52 |
+
|
| 53 |
+
**Why this model:**
|
| 54 |
+
1. Generation pathway is fundamentally different from AR models β OOD for all current detectors
|
| 55 |
+
2. Bidirectional canvas attention enables holistic text understanding for rewriting
|
| 56 |
+
3. Iterative denoising (1-48 steps) provides a perfect mechanism for progressive humanization
|
| 57 |
+
4. MoE (3.8B active) makes QLoRA fine-tuning feasible on A100
|
| 58 |
+
5. 4-bit quantized versions already exist (NVFP4 from NVIDIA, AutoRound from Intel)
|
| 59 |
+
|
| 60 |
+
### 2.2 Training Strategy
|
| 61 |
+
|
| 62 |
+
**Phase 1: Dataset Construction**
|
| 63 |
+
- Base: HC3 (48.6K ChatGPT-human QA pairs)
|
| 64 |
+
- Augmentation: Synthetic pairs from heuristic humanization (sentence splitting, hedging, register variation)
|
| 65 |
+
- Detector scoring: Each pair annotated with pre/post scores from Fast-DetectGPT, burstiness, heuristics
|
| 66 |
+
|
| 67 |
+
**Phase 2: QLoRA Fine-Tuning**
|
| 68 |
+
- Method: QLoRA, rank 8-16, 4-bit base (NVIDIA NVFP4)
|
| 69 |
+
- Format: Chat template (system: "Rewrite to sound human", user: AI text, assistant: human text)
|
| 70 |
+
- Initial scale: 300-500 pairs, A100 80GB, ~$40
|
| 71 |
+
|
| 72 |
+
**Phase 3: Detector-Guided Refinement**
|
| 73 |
+
- At inference, use entropy-bounded denoising (48 steps max)
|
| 74 |
+
- Apply classifier-free guidance to push logits toward human-like tokens
|
| 75 |
+
- Target inversion of known detector signals:
|
| 76 |
+
- Reduce transition markers (furthermore, however, therefore)
|
| 77 |
+
- Increase sentence length variation
|
| 78 |
+
- Reduce passive voice constructions
|
| 79 |
+
- Increase hapax legomena ratio
|
| 80 |
+
|
| 81 |
+
### 2.3 Detector Signals to Invert
|
| 82 |
+
|
| 83 |
+
From the literature, detectors (especially Pangram) target:
|
| 84 |
+
|
| 85 |
+
| Signal | AI Text | Human Text | Inversion Strategy |
|
| 86 |
+
|--------|---------|------------|-------------------|
|
| 87 |
+
| Perplexity | Low (<20) | High (>30) | Add "surprising" tokens |
|
| 88 |
+
| Burstiness | Low (<0.15) | High (>0.3) | Vary sentence structure |
|
| 89 |
+
| Transition markers | Many | Few | Replace with informal alternatives |
|
| 90 |
+
| Passive voice | Many | Few | Convert to active voice |
|
| 91 |
+
| Sentence length Ο | Low (<5) | High (>10) | Mix short/long sentences |
|
| 92 |
+
| Hapax ratio | Low (<0.40) | High (>0.45) | Use more unique words |
|
| 93 |
+
| Lexical diversity | Moderate | Variable | Match domain-specific patterns |
|
| 94 |
+
|
| 95 |
+
---
|
| 96 |
+
|
| 97 |
+
## 3. Cost Breakdown
|
| 98 |
+
|
| 99 |
+
| Step | GPU | Est. Time | Cost |
|
| 100 |
+
|------|-----|----------|------|
|
| 101 |
+
| 1. Model download + baseline gen | A100 | 30 min | $1.25 |
|
| 102 |
+
| 2. Detector tests | A100 | 20 min | $0.85 |
|
| 103 |
+
| 3. Dataset construction | CPU (within A100) | 10 min | $0 |
|
| 104 |
+
| 4. QLoRA fine-tuning (300 pairs) | A100 | 1-2h | $5-10 |
|
| 105 |
+
| 5. Evaluation (5 prompts) | A100 | 15 min | $0.60 |
|
| 106 |
+
| 6. Export to HF | CPU | 5 min | $0 |
|
| 107 |
+
| **Total per run** | | **~3h** | **~$8-13** |
|
| 108 |
+
| **Available runs ($250)** | | | **19-31 experiments** |
|
| 109 |
+
|
| 110 |
+
Each experiment can vary: dataset size, LoRA rank, learning rate, prompt template, training epochs.
|
| 111 |
+
|
| 112 |
+
---
|
| 113 |
+
|
| 114 |
+
## 4. Expected Results (Hypothesis)
|
| 115 |
+
|
| 116 |
+
Based on cross-referencing all papers:
|
| 117 |
+
|
| 118 |
+
| Detector | Baseline (DiffusionGemma raw) | Fine-tuned Humanizer |
|
| 119 |
+
|----------|------------------------------|---------------------|
|
| 120 |
+
| GPTZero | 60-80% evasion (diffusion confuses perplexity) | 95%+ evasion |
|
| 121 |
+
| Binoculars | 50-70% evasion (cross-perplexity mismatch) | 90%+ evasion |
|
| 122 |
+
| Fast-DetectGPT | 40-60% evasion (curvature is AR-specific) | 85%+ evasion |
|
| 123 |
+
| Pangram | 30-50% evasion (untrained on diffusion) | 70-85% evasion initially |
|
| 124 |
+
|
| 125 |
+
Pangram will be the hardest because their deep classifier learns nuanced style patterns. But being completely OOD (out-of-distribution) for their training set gives a significant initial advantage. The window of high evasion will close once Pangram adds diffusion text to their training pipeline β estimated 1-3 months after public release.
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## 5. Security: HF Token Setup
|
| 130 |
+
|
| 131 |
+
### Required Permissions
|
| 132 |
+
|
| 133 |
+
1. **Read token**: Download models (DiffusionGemma, GPT-2 for detectors)
|
| 134 |
+
2. **Write token**: Upload to `simonlesaumon/diffusiongemma-humanizer`
|
| 135 |
+
|
| 136 |
+
### Setup on Modal (nothing stored locally)
|
| 137 |
+
|
| 138 |
+
```powershell
|
| 139 |
+
# Create Modal secret (tokens stay encrypted on Modal, never on your PC)
|
| 140 |
+
modal secret create hf-secrets HF_TOKEN=hf_your_token_here
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
Then the app reads from `os.environ["HF_TOKEN"]` automatically.
|
| 144 |
+
Create your token at: https://huggingface.co/settings/tokens (needs "Write" permission)
|
| 145 |
+
|
| 146 |
+
---
|
| 147 |
+
|
| 148 |
+
## 6. File Structure
|
| 149 |
+
|
| 150 |
+
```
|
| 151 |
+
Deepseek_SOTA/
|
| 152 |
+
βββ modal_project/
|
| 153 |
+
β βββ app.py # Full Modal pipeline
|
| 154 |
+
βββ scripts/
|
| 155 |
+
β βββ run_pipeline.ps1 # PowerShell launcher
|
| 156 |
+
β βββ run.py # Python launcher
|
| 157 |
+
βββ research/
|
| 158 |
+
β βββ technical-diffusion-text-humanization-2026-06-29.md # Research report
|
| 159 |
+
β βββ architecture-strategy.md # This file
|
| 160 |
+
βββ .gitignore
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
**Everything runs on Modal. Nothing downloaded locally except the scripts.**
|
| 164 |
+
|
| 165 |
+
---
|
| 166 |
+
|
| 167 |
+
## 7. References
|
| 168 |
+
|
| 169 |
+
1. Sadasivan et al. (2023) β *Can AI-Generated Text be Reliably Detected?* [arXiv:2303.11156]
|
| 170 |
+
2. Masrour, Emi & Spero (2025) β *DAMAGE: Detecting Adversarially Modified AI Generated Text* [arXiv:2501.03437]
|
| 171 |
+
3. Cheng et al. (2025) β *Adversarial Paraphrasing: A Universal Attack for Humanizing AI-Generated Text* [arXiv:2506.07001]
|
| 172 |
+
4. TarΔ±m & Onan (2025) β *Can You Detect the Difference? Diffusion vs AR Text* [HF:2507.10475]
|
| 173 |
+
5. Ranganath & Ramesh (2026) β *StealthRL: RL Paraphrase Attacks for Multi-Detector Evasion* [arXiv:2602.08934]
|
| 174 |
+
6. Xu et al. (2026) β *Base Models Look Human To AI Detectors* [arXiv:2605.19516]
|
| 175 |
+
7. Schiff et al. (2024) β *Simple Guidance Mechanisms for Discrete Diffusion Models* [arXiv:2412.10193]
|
| 176 |
+
8. DiffusionGemma β [Hugging Face](https://huggingface.co/google/diffusiongemma-26B-A4B-it)
|