You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rewrite README with results, HuggingFace link, and development log
Surface v1.0-v1.3 training results, link to DataFog/pii-small-en
checkpoint, add dated development log, documentation index, key
technical findings, and open problems. Gitignore output-*/ dirs
and Windows nul artifact.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Research and development for DataFog's PII detection models.
3
+
Open research and development for lightweight PII detection models. This repo contains the full training code, experiment history, and research behind [DataFog](https://datafog.ai)'s PII-NER model family.
4
4
5
-
## Projects
5
+
**Latest checkpoint:**[DataFog/pii-small-en](https://huggingface.co/DataFog/pii-small-en) on HuggingFace (v1.3, Apache 2.0)
6
6
7
-
### [PII-NER v1](pii-ner-v1/)
7
+
##PII-NER v1
8
8
9
-
A 22.7M parameter PII detection model combining DeBERTa-v3-xsmall with a character CNN encoder, sigmoid gating fusion, and CRF output layer. Trained on 360K+ open-licensed PII examples.
9
+
A 22.7M parameter model for detecting 44 types of personally identifiable information in English text. Combines a pretrained DeBERTa-v3-xsmall backbone with a character CNN encoder, adaptive gating fusion, and CRF output layer.
The gating fusion dynamically weights character-level features (for structured PII like SSNs and credit cards) against contextual features (for soft PII like names and addresses) on a per-token basis.
28
+
29
+
### Results
30
+
31
+
Best results from v1.3 training on H100 (20 hours, 10 epochs):
12
32
13
-
**Key features:**
14
-
- 163 BIO tags covering ~81 PII entity types across 4 sensitivity tiers
15
-
- Adaptive gating between character-level patterns (for structured PII like SSNs) and contextual features (for soft PII like names)
16
-
- CRF output layer enforcing valid BIO sequences
17
-
- Differential learning rates for pretrained backbone vs randomly initialized head
Architecture survey, training data catalog, evaluation framework, and gap analysis for PII-NER model design. Includes a 29-slide interactive architecture guide.
89
+
```bash
90
+
python scripts/eval_benchmark.py \
91
+
--model datafog \
92
+
--model-path DataFog/pii-small-en \
93
+
--dataset combined \
94
+
--split test
95
+
```
96
+
97
+
See [eval_benchmark.md](pii-ner-v1/docs/eval_benchmark.md) for flags and options.
Combined: ~169K English examples after filtering and dedup. 44 canonical entity types across 4 sensitivity tiers, unified into 89 BIO labels. The dataset has a 323x frequency imbalance (DATE: 170K occurrences vs PASSPORT: 526), which drives many of the training innovations below.
108
+
109
+
## Documentation
110
+
111
+
| Document | Description |
112
+
|----------|-------------|
113
+
|[Training Chronicle](pii-ner-v1/docs/training_chronicle.md)| Full narrative of the ML journey: 4 NaN sources, backbone instability, tier-weighted loss, freezing experiments |
114
+
|[Smoke Test Walkthrough](pii-ner-v1/docs/smoke_test_walkthrough.md)| Why differential learning rates are essential for pretrained+CRF architectures |
115
+
|[Evaluation Harness](pii-ner-v1/docs/eval_benchmark.md)| Head-to-head model comparison on the same test split |
116
+
|[Design Document](docs/plans/2026-02-01-pii-ner-v1-design.md)| Original architecture decisions and project structure |
117
+
118
+
### Research
119
+
120
+
The [RESEARCH/](RESEARCH/pii-model-architecture/) directory contains the pre-implementation research: 8 reports surveying 26 architectures, 9 PII datasets, and the competitive landscape. Includes a [29-slide interactive architecture guide](RESEARCH/pii-model-architecture/architecture-guide.html).
121
+
122
+
Key finding: no published work combines differentiable character-level pattern recognition with contextual transformers specifically for PII detection.
123
+
124
+
## Development log
125
+
126
+
| Date | Version | What changed |
127
+
|------|---------|-------------|
128
+
| 2026-02-07 |**v1.3**| Best F1 (0.907). Early backbone freeze (epoch 3) + progressive tier weight reduction. Discovered training spikes originate in head components, not backbone. |
129
+
| 2026-02-05 | v1.2 | Best Tier 1 recall (0.841). Backbone freezing after epoch 4. Epoch 3 identified as consistent sweet spot. |
| 2026-02-04 | — | Training chronicle, entity frequency audit (323x imbalance discovered). |
132
+
| 2026-02-03 | v1.0 | First full training on A100. F1=0.904 on 360K examples. Model uploaded to HuggingFace. |
133
+
| 2026-02-03 | — | NaN gauntlet: 4 distinct NaN sources identified and fixed (CRF overflow, AdamW bias-correction, BF16 mantissa, FP16 gradient scaler). |
134
+
| 2026-02-02 | — | Smoke test passed (F1=0.947 on 100 examples). Differential learning rates proven essential. |
135
+
| 2026-02-01 | — | Architecture design. Research phase complete (2,800+ lines across 8 reports). |
136
+
137
+
## Key technical findings
138
+
139
+
1.**Differential learning rates are non-negotiable.** A flat LR across pretrained backbone + random CRF head produces F1=0.000. A 50x ratio (backbone 2e-5, head 1e-3) is needed.
140
+
141
+
2.**AdamW eps=1.0 for pretrained backbones.** Standard eps=1e-8 makes effective updates ~±lr regardless of gradient magnitude, causing NaN on DeBERTa with PyTorch 2.9+. Setting eps=1.0 restores gradient-proportional updates.
142
+
143
+
3.**The training spike is a head problem, not backbone.** V1.3 proved this definitively: the spike occurred at epoch 5 with the backbone already frozen since epoch 3. The CharCNN/GatingFusion/CRF destabilize under continued training.
144
+
145
+
4.**Epoch 3 is consistently the best checkpoint.** Across v1.2 and v1.3, the model peaks at epoch 3 then destabilizes. Earlier representations generalize better.
146
+
147
+
5.**Tier-weighted loss works but amplifies instability.** 3x weight + 3x oversampling = ~9x gradient signal for Tier 1, which accelerates learning but accumulates damage.
148
+
149
+
## Open problems
150
+
151
+
-**Tier 1 recall gap**: 0.823 vs 0.98 target. Passport number (0.426 F1) has only 526 training examples.
152
+
-**16 zero-occurrence entity types**: NATIONALITY, ETHNICITY, RELIGION, etc. exist in the taxonomy but no training data covers them.
153
+
-**Head instability**: Root cause of the epoch 3+ training spike is unknown. Gradient clipping, per-component LR decay, or early stopping are candidate fixes.
0 commit comments