diff --git a/.github/workflows/publish-source-classify-hf.yml b/.github/workflows/publish-source-classify-hf.yml index b6905b7..1f8ca8b 100644 --- a/.github/workflows/publish-source-classify-hf.yml +++ b/.github/workflows/publish-source-classify-hf.yml @@ -12,7 +12,7 @@ on: weights_tag: description: "GitHub Release tag holding multi-provider-source-v3.npz" required: true - default: source-classify-freeze-2026-10-30 + default: source-classify-freeze-2026-11-01 jobs: publish: diff --git a/docs/source-classify-hf/README.md b/docs/source-classify-hf/README.md index d2d27a6..4b25bf9 100644 --- a/docs/source-classify-hf/README.md +++ b/docs/source-classify-hf/README.md @@ -20,43 +20,43 @@ This model is **not a SynthID detector** and does not decode or verify any crypt - `124-d` spatial opponent-residual and gradient forensic features (`extract_124d`). - `768-d` phase-free `16x16` log-power and radial spectral features (`source_spectral`). - `64-d` directional / block-boundary (`8x8` and `16x16`) / chroma-aliasing / azimuthal-anisotropy features (`augment_892d_to_956d`). -- **Stage 1 (`54` specialist units across `10` canonical providers):** - - `10` global provider specialists + `44` subfamily and codec/export-regime specialists (`37` active), each combining a block-diagonal MLP Soup, a vectorized fixed-depth `HistGradientBoosting` tree ensemble, and a distilled `ExtraTrees -> MLP` student with calibration-reoptimized distilled blend weights (`w_e <= 0.25`), pooled via drift-bounded zero-inflation subfamily blending across 16 real-image varieties, refined by an unknown-domain debiased Stage-1.5 zero-inflated hinge meta-router (`router_meta_tau`, `router_meta_w`), and routed by a unified damped competitive margin (`gamma = 0.60`). -- **Stage 2 (`9` stacked version heads, `1010-d`):** - - Feature-subsampled vectorized `HistGradientBoosting` tree ensembles (including a multi-depth forest soup on `flux`) taking the `956-d` features (and `54` Stage-1 unit log-odds scores) to predict the canonical model/export subfamily (`version_subfamily`). +- **Stage 1 (`54` primary specialist units + `366` auxiliary hard-margin subfamily, codec-recompression, cross-AI disambiguator, and domain-veto hinge descriptors across `10` canonical providers):** + - `10` global provider specialists + `44` subfamily and codec/export-regime specialists (`37` active), each combining a block-diagonal MLP Soup (including 3-seed joint multi-task `54`-unit shared-trunk MLP blocks), a vectorized fixed-depth `HistGradientBoosting` tree ensemble, and a distilled `ExtraTrees -> MLP` student with calibration-reoptimized distilled blend weights (`w_e <= 0.25`), pooled via drift-bounded zero-inflation subfamily blending across 16 real-image varieties, refined by a Wave-11 Stage-1.5 2-knot zero-inflated hinge meta-router (`router_meta_tau`, `router_meta_w`) incorporating expanded-corpus 3-component hybrid (`MLP Soup + HGB + Distilled ExtraTrees-MLP`), pure-channel (`onlyhgb`, `onlymlp`, `onlyet`), cross-AI disambiguator, and real-domain veto specialists, and routed by a unified damped competitive margin (`gamma = 0.60`). +- **Stage 2 (`9` stacked version heads, `1376-d`):** + - Feature-subsampled vectorized `HistGradientBoosting` tree ensembles (including multi-seed/multi-depth forest soups on `openai`, `google`, `flux`, `midjourney`, `ideogram`, `bytedance`, and `stable_diffusion`) taking the `956-d` features (and Stage-1 unit log-odds scores) to predict the canonical model/export subfamily (`version_subfamily`). - **Artifact:** `multi-provider-source-v3.npz` (`allow_pickle=False`) -- **SHA-256:** `b23ef046da3cb85b65e5985a276cbf2912022d79a1837f5d0967631f7c04598e` +- **SHA-256:** `9cc657037074e79e964ba446e169591e3dda781e927674df55daf9c227d2bc6b` The artifact contains only learned parameters, normalization constants, tree arrays, labels, and calibrated thresholds. It does not contain training images, paths, image hashes, embeddings, or a training catalog. -## Evaluation (`56,611` clean audited samples; `10,586` locked test) +## Evaluation (`90,079` clean audited samples; `10,586` locked test) The operating point was selected on a disjoint `8,365`-image calibration split across 16 fine-grained real-image varieties and group-locked (`parent_sha256`) native, light-JPEG, and heavy-JPEG/resize views. On the `10,586`-image locked test split (`4,539` multi-variety `unknown` negatives + `6,047` AI provider images including preprocessed social/JPEG derivatives): -- **Unified 10-provider router:** `99.41%` `unknown` specificity (`0.59%` test `unknown` FPR; `0.87%` photographic FPR and `0.34%` non-photographic structured FPR across all 15 non-photo varieties), `49.43%` aggregate target recall across native and recompressed test views (`96.67%` provider accuracy when firing), and `0.9419` binary ROC-AUC / `0.9579` PR-AUC on the monotonic `confidence` score (`_sigmoid_scalar(excess[best_cls])`). +- **Unified 10-provider router:** `99.52%` `unknown` specificity (`0.48%` test `unknown` FPR; `0.69%` photographic FPR and `0.30%` non-photographic structured FPR across all 15 non-photo varieties), `56.67%` aggregate target recall across native (`63.43%`) and recompressed (`22.39%`) test views (`97.22%` provider accuracy among classified AI; `96.62%` overall precision when firing), and `0.9514` binary ROC-AUC / `0.9640` PR-AUC on the monotonic `confidence` score (`_sigmoid_scalar(excess[best_cls])`). | Provider | Test count | Standalone ROC AUC | Router recall | Router precision | Stage-2 version accuracy | |---|---:|---:|---:|---:|---:| -| `openai` | 1,478 | 0.9657 | 60.8% | 96.6% | 85.0% | -| `google` | 1,382 | 0.9661 | 64.1% | 96.9% | 92.6% | -| `bytedance` | 389 | 0.9445 | 53.2% | 97.6% | 90.0% | -| `flux` | 1,357 | 0.9234 | 34.2% | 94.9% | 85.8% | -| `stable_diffusion` | 955 | 0.9582 | 37.6% | 97.0% | 85.9% | -| `meta` | 94 | 0.9767 | 78.7% | 91.4% | — (`meta:imagine`) | -| `midjourney` | 123 | 0.9215 | 36.6% | 81.8% | 87.8% | -| `ideogram` | 118 | 0.8868 | 10.2% | 70.6% | 64.4% | -| `firefly` | 103 | 0.9170 | 33.0% | 87.2% | 100.0% | -| `xai` | 48 | 0.9283 | 20.8% | 83.3% | 72.9% | +| `openai` | 1,478 | 0.9693 | 67.8% | 97.0% | 86.5% | +| `google` | 1,382 | 0.9713 | 68.5% | 96.4% | 93.2% | +| `bytedance` | 389 | 0.9565 | 59.1% | 99.6% | 90.0% | +| `flux` | 1,357 | 0.9309 | 40.6% | 96.3% | 87.0% | +| `stable_diffusion` | 955 | 0.9640 | 49.4% | 96.7% | 86.8% | +| `meta` | 94 | 0.9797 | 78.7% | 96.1% | — (`meta:imagine`) | +| `midjourney` | 123 | 0.9565 | 45.5% | 94.9% | 90.2% | +| `ideogram` | 118 | 0.9307 | 30.5% | 94.7% | 65.3% | +| `firefly` | 103 | 0.9193 | 46.6% | 87.3% | 100.0% | +| `xai` | 48 | 0.9416 | 25.0% | 92.3% | 72.9% | ### Held-out real-image specificity by variety (`4,539` test negatives across 16 real classes + foreign AI) | Real-image variety | Test count | False positives | False-positive rate | Specificity | |---|---:|---:|---:|---:| -| `photo` | 2,183 | 19 | 0.87% | 99.13% | +| `photo` | 2,183 | 15 | 0.69% | 99.31% | | `photo_retouched` | 339 | 1 | 0.29% | 99.71% | | `classical_inpaint` | 17 | 0 | 0.00% | 100.00% | | `digital_art` | 441 | 1 | 0.23% | 99.77% | -| `game_art` | 174 | 1 | 0.57% | 99.43% | +| `game_art` | 174 | 0 | 0.00% | 100.00% | | `vector` | 135 | 1 | 0.74% | 99.26% | | `interface` | 180 | 0 | 0.00% | 100.00% | | `diagram` | 98 | 1 | 1.02% | 98.98% | @@ -65,20 +65,20 @@ The operating point was selected on a disjoint `8,365`-image calibration split a | `procedural_graphic` | 13 | 0 | 0.00% | 100.00% | | `document` | 165 | 0 | 0.00% | 100.00% | | `gov_scientific_doc` | 32 | 0 | 0.00% | 100.00% | -| `receipt_invoice` | 181 | 1 | 0.55% | 99.45% | +| `receipt_invoice` | 181 | 0 | 0.00% | 100.00% | | `print_publishing` | 229 | 1 | 0.44% | 99.56% | -| `stress_recompressed` | 103 | 1 | 0.97% | 99.03% | +| `stress_recompressed` | 103 | 2 | 1.94% | 98.06% | | `foreign_ai` | 6 | 0 | 0.00% | 100.00% | ### External blind multi-variety real-image verification (`selective-v8`, `2,267` untouched images) -Evaluated on the hash-disjoint external `selective-v8` blind real-image cohorts (`2,267` images never seen in train, calibration, or test): **10 / 2,267 false positives (`0.44%` overall FPR, `99.56%` specificity)**. +Evaluated on the hash-disjoint external `selective-v8` blind real-image cohorts (`2,267` images never seen in train, calibration, or test): **3 / 2,267 false positives (`0.13%` overall FPR, `99.87%` specificity)**. | Blind `selective-v8` cell | Evaluated | False positives | False-positive rate | Specificity | |---|---:|---:|---:|---:| -| `photo` | 450 | 5 | 1.11% | 98.89% | +| `photo` | 450 | 2 | 0.44% | 99.56% | | `vector` | 332 | 0 | 0.00% | 100.00% | -| `game_art` | 230 | 5 | 2.17% | 97.83% | +| `game_art` | 230 | 1 | 0.43% | 99.57% | | `interface` | 342 | 0 | 0.00% | 100.00% | | `diagram` | 305 | 0 | 0.00% | 100.00% | | `document` | 308 | 0 | 0.00% | 100.00% | diff --git a/docs/source-classify-hf/metrics.json b/docs/source-classify-hf/metrics.json index e7cc288..a720482 100644 --- a/docs/source-classify-hf/metrics.json +++ b/docs/source-classify-hf/metrics.json @@ -2,9 +2,9 @@ "claim": "abstaining 10-provider source-pipeline classification with version subfamily attribution; not SynthID detection", "schema": "multi-provider-source-v3", "artifact_file": "multi-provider-source-v3.npz", - "artifact_sha256": "b23ef046da3cb85b65e5985a276cbf2912022d79a1837f5d0967631f7c04598e", + "artifact_sha256": "9cc657037074e79e964ba446e169591e3dda781e927674df55daf9c227d2bc6b", "feature_dimension": 956, - "stacked_stage2_dimension": 1010, + "stacked_stage2_dimension": 1376, "classes": [ "openai", "google", @@ -19,50 +19,50 @@ "unknown" ], "corpus_counts": { - "total": 56611, - "train": 37660, + "total": 90079, + "train": 71128, "calibration": 8365, "test": 10586 }, "locked_internal_test": { "n": 10586, - "binary_roc_auc": 0.9419, - "binary_pr_auc": 0.9579, - "unknown_specificity": 0.9940515532055518, - "unknown_fpr": 0.005948446794448116, - "photo_fpr": 0.008703618873110398, - "structured_fpr": 0.003404255319148936, - "aggregate_target_recall": 0.4942946915826029, + "binary_roc_auc": 0.9514, + "binary_pr_auc": 0.964, + "unknown_specificity": 0.995153117426746, + "unknown_fpr": 0.004846882573254021, + "photo_fpr": 0.006871278057718736, + "structured_fpr": 0.0029711375212224107, + "aggregate_target_recall": 0.5667273027947742, "recall": { - "openai": 0.6075778078484438, - "google": 0.6410998552821997, - "bytedance": 0.532133676092545, - "flux": 0.341930729550479, - "stable_diffusion": 0.37591623036649213, + "openai": 0.6779431664411367, + "google": 0.6845151953690304, + "bytedance": 0.5912596401028277, + "flux": 0.40604274134119384, + "stable_diffusion": 0.4942408376963351, "meta": 0.7872340425531915, - "midjourney": 0.36585365853658536, - "ideogram": 0.1016949152542373, - "firefly": 0.3300970873786408, - "xai": 0.20833333333333334 + "midjourney": 0.45528455284552843, + "ideogram": 0.3050847457627119, + "firefly": 0.46601941747572817, + "xai": 0.25 }, "precision": { - "openai": 0.9655913978494624, - "google": 0.9693654266958425, - "bytedance": 0.9764150943396226, - "flux": 0.9488752556237219, - "stable_diffusion": 0.9702702702702702, - "meta": 0.9135802469135802, - "midjourney": 0.8181818181818182, - "ideogram": 0.7058823529411765, - "firefly": 0.8717948717948718, - "xai": 0.8333333333333334 + "openai": 0.9699903194578896, + "google": 0.9643221202854231, + "bytedance": 0.9956709956709957, + "flux": 0.9632867132867133, + "stable_diffusion": 0.9672131147540983, + "meta": 0.961038961038961, + "midjourney": 0.9491525423728814, + "ideogram": 0.9473684210526315, + "firefly": 0.8727272727272727, + "xai": 0.9230769230769231 }, "real_variety_specificity": { - "photo": 0.9912963811268896, + "photo": 0.9931287219422813, "photo_retouched": 0.9970501474926253, "classical_inpaint": 1.0, "digital_art": 0.9977324263038548, - "game_art": 0.9942528735632183, + "game_art": 1.0, "vector": 0.9925925925925926, "interface": 1.0, "diagram": 0.9897959183673469, @@ -71,23 +71,23 @@ "procedural_graphic": 1.0, "document": 1.0, "gov_scientific_doc": 1.0, - "receipt_invoice": 0.994475138121547, + "receipt_invoice": 1.0, "print_publishing": 0.9956331877729258, - "stress_recompressed": 0.9902912621359223, + "stress_recompressed": 0.9805825242718447, "foreign_ai": 1.0 } }, "external_blind_selective_v8_real_varieties": { "total_evaluated": 2267, - "total_false_positives": 10, - "overall_fpr": 0.004411116012351125, - "overall_specificity": 0.9955888839876489, + "total_false_positives": 3, + "overall_fpr": 0.0013233348037053375, + "overall_specificity": 0.9986766651962947, "per_variety": { "photo": { "evaluated": 450, - "false_positives": 5, - "fpr": 0.011111111111111112, - "specificity": 0.9888888888888889 + "false_positives": 2, + "fpr": 0.0044444444444444444, + "specificity": 0.9955555555555555 }, "vector": { "evaluated": 332, @@ -97,9 +97,9 @@ }, "game_art": { "evaluated": 230, - "false_positives": 5, - "fpr": 0.021739130434782608, - "specificity": 0.9782608695652174 + "false_positives": 1, + "fpr": 0.004347826086956522, + "specificity": 0.9956521739130435 }, "interface": { "evaluated": 342, @@ -128,13 +128,13 @@ } }, "stage2_version_accuracy": { - "openai": 0.8504736129905277, - "google": 0.9261939218523878, + "openai": 0.86468200270636, + "google": 0.9319826338639653, "bytedance": 0.8997429305912596, - "flux": 0.8577745025792188, - "stable_diffusion": 0.8586387434554974, - "midjourney": 0.8780487804878049, - "ideogram": 0.6440677966101694, + "flux": 0.8703021370670597, + "stable_diffusion": 0.8680628272251308, + "midjourney": 0.9024390243902439, + "ideogram": 0.652542372881356, "firefly": 1.0, "xai": 0.7291666666666666 } diff --git a/src/remove_ai_watermarks/source_classify.py b/src/remove_ai_watermarks/source_classify.py index cd73f97..c2caf40 100644 --- a/src/remove_ai_watermarks/source_classify.py +++ b/src/remove_ai_watermarks/source_classify.py @@ -77,7 +77,7 @@ WEIGHTS_ENV = "RAIW_SOURCE_CLASSIFY_WEIGHTS" WEIGHTS_REPO = "wiltodelta/raiw-source-classify" WEIGHTS_REVISION = "9d5adc9371bc2e3ea3b455cebc97ad92a0c94a1a" MODEL_FILE = "multi-provider-source-v3.npz" -MODEL_SHA256 = "b23ef046da3cb85b65e5985a276cbf2912022d79a1837f5d0967631f7c04598e" +MODEL_SHA256 = "9cc657037074e79e964ba446e169591e3dda781e927674df55daf9c227d2bc6b" MODEL_SCHEMA = "multi-provider-source-v3" SOURCE_CLASSIFY_EXTRA = "'remove-ai-watermarks[source-classify]'"