iamSamurai commited on
Commit
2549068
·
verified ·
1 Parent(s): 09d6e24

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +287 -30
README.md CHANGED
@@ -12,66 +12,323 @@ tags:
12
  - lora
13
  - peft
14
  - nigeria
15
- - naija
16
  - privacy-filter
17
  model-index:
18
- - name: iamSamurai/privacy-filter-nigeria
19
  results:
20
  - task:
21
  type: token-classification
22
  name: PII Span Detection
23
  dataset:
24
- name: Naija privacy-filter training release
25
  type: custom
26
  metrics:
27
  - type: f1
28
- name: Validation typed span F1
29
- value: 0.9737
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  ---
31
 
32
- # OpenAI Privacy Filter Naija LoRA
33
 
34
- This is a PEFT LoRA adapter for `openai/privacy-filter` trained for Nigerian-domain PII
35
- span detection. It is a research preview, not a production privacy or
36
- compliance control.
37
 
38
- ## Checkpoint
39
-
40
- - Adapter repo: `iamSamurai/privacy-filter-nigeria`
41
- - Base model: `openai/privacy-filter`
42
- - Best epoch: `9`
43
- - Best validation typed span F1: `0.9737`
 
44
 
45
  ## Evaluation
46
 
47
- | Split | Typed span F1 |
 
 
 
 
 
 
 
 
 
 
 
48
  | --- | ---: |
49
- | Validation | 0.9737 |
50
- | Test | 0.9640 |
51
- | Challenge | 0.0000 |
 
52
 
53
- The challenge split is diagnostic and should not be used for checkpoint
54
- selection. Review the included metric JSON files for full precision, recall,
55
- loss, and false-positive details.
 
56
 
57
- ## Usage
58
 
59
- Use the project runner so the classification head is resized from
60
- `label_map.json` before the adapter is loaded:
 
 
 
 
 
 
 
61
 
62
  ```bash
 
63
  git clone https://github.com/iamNarcisse/naija-privacy-filter
64
  cd naija-privacy-filter
65
 
 
 
 
 
 
 
 
 
 
66
  uv run python main.py \
67
  --model-name openai/privacy-filter \
68
  --adapter-name iamSamurai/privacy-filter-nigeria \
69
  "Amina Yusuf can be reached at +234 802 111 3344."
70
  ```
71
 
72
- ## Limitations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
- The adapter detects spans from its trained label taxonomy and can miss or
75
- misclassify PII outside the training distribution. Do not use it as the only
76
- control for regulatory, legal, medical, financial, or irreversible privacy
77
- decisions. Evaluate on representative in-domain data before deployment.
 
12
  - lora
13
  - peft
14
  - nigeria
 
15
  - privacy-filter
16
  model-index:
17
+ - name: privacy-filter-nigeria
18
  results:
19
  - task:
20
  type: token-classification
21
  name: PII Span Detection
22
  dataset:
23
+ name: stage2_v5 private mixed dataset (validation)
24
  type: custom
25
  metrics:
26
  - type: f1
27
+ name: Typed Span F1
28
+ value: 0.9763
29
+ - type: precision
30
+ name: Typed Span Precision
31
+ value: 0.9707
32
+ - type: recall
33
+ name: Typed Span Recall
34
+ value: 0.9820
35
+ - task:
36
+ type: token-classification
37
+ name: PII Span Detection
38
+ dataset:
39
+ name: stage2_v5 private mixed dataset (test)
40
+ type: custom
41
+ metrics:
42
+ - type: f1
43
+ name: Typed Span F1
44
+ value: 0.9640
45
+ - type: precision
46
+ name: Typed Span Precision
47
+ value: 0.9593
48
+ - type: recall
49
+ name: Typed Span Recall
50
+ value: 0.9688
51
+ - task:
52
+ type: token-classification
53
+ name: Hard-Negative False Positive Audit
54
+ dataset:
55
+ name: stage2_v5 hard-negative challenge
56
+ type: custom
57
+ metrics:
58
+ - type: false_positive_rate
59
+ name: False-positive example rate
60
+ value: 0.72
61
  ---
62
 
63
+ # Privacy Filter Nigeria LoRA
64
 
65
+ A LoRA adapter on top of [`openai/privacy-filter`](https://huggingface.co/openai/privacy-filter)
66
+ for Nigerian-domain PII span detection. This is a **v0.1 research preview**,
67
+ not a production privacy product.
68
 
69
+ - **Adapter repo:** `iamSamurai/privacy-filter-nigeria`
70
+ - **Base model:** `openai/privacy-filter`
71
+ - **Adapter type:** LoRA (PEFT) for token classification
72
+ - **Source repo:** https://github.com/iamNarcisse/naija-privacy-filter
73
+ - **Eval artifacts:** [`iamSamurai/openai-privacy-filter-naija-eval-artifacts`](https://huggingface.co/iamSamurai/openai-privacy-filter-naija-eval-artifacts)
74
+ - **License:** Apache-2.0 (this adapter). Use of the base model remains
75
+ subject to the upstream model's terms.
76
 
77
  ## Evaluation
78
 
79
+ Latest v5 eval against the internal stage2 v5 private mixed dataset, after
80
+ deterministic span postprocessing:
81
+
82
+ | Split | Typed span F1 | Precision | Recall | TP | FP | FN |
83
+ | --- | ---: | ---: | ---: | ---: | ---: | ---: |
84
+ | Validation | 0.9763 | 0.9707 | 0.9820 | 762 | 23 | 14 |
85
+ | Test | 0.9640 | 0.9593 | 0.9688 | 777 | 33 | 25 |
86
+
87
+ The v5 challenge split is hard-negative-only. Typed F1 is not meaningful
88
+ because there are no gold positive spans. Use false-positive diagnostics:
89
+
90
+ | Challenge diagnostic | Value |
91
  | --- | ---: |
92
+ | Examples | 250 |
93
+ | Examples with predictions | 180 |
94
+ | False-positive example rate | 0.72 |
95
+ | Predicted false-positive spans | 456 |
96
 
97
+ This is a recall-oriented research adapter. The hard-negative audit shows that
98
+ benign identifier-like text can be over-redacted. Precision-sensitive users
99
+ should add deterministic filters, tune thresholds where applicable, or
100
+ finetune on representative local negatives.
101
 
102
+ ## How To Use
103
 
104
+ > **Note on the classifier head.** This adapter ships a resized token-
105
+ > classification head for the Nigerian-domain label taxonomy
106
+ > (`label_map.json` / `token_label_names` in `adapter_config.json`). Loading
107
+ > the adapter on top of the unmodified base model with vanilla
108
+ > `peft.PeftModel.from_pretrained` will not resize the head automatically.
109
+ > Use the project runner (`privacy_filter.py`) or replicate its head-resize
110
+ > logic to get correct predictions.
111
+
112
+ ### Recommended: project runner
113
 
114
  ```bash
115
+ pip install "torch>=2.8" "transformers>=4.56" "peft>=0.17" "huggingface-hub>=0.34"
116
  git clone https://github.com/iamNarcisse/naija-privacy-filter
117
  cd naija-privacy-filter
118
 
119
+ python main.py \
120
+ --model-name openai/privacy-filter \
121
+ --adapter-name iamSamurai/privacy-filter-nigeria \
122
+ "Amina Yusuf can be reached at +234 802 111 3344."
123
+ ```
124
+
125
+ Or via `uv`:
126
+
127
+ ```bash
128
  uv run python main.py \
129
  --model-name openai/privacy-filter \
130
  --adapter-name iamSamurai/privacy-filter-nigeria \
131
  "Amina Yusuf can be reached at +234 802 111 3344."
132
  ```
133
 
134
+ ### REST API
135
+
136
+ ```bash
137
+ PRIVACY_FILTER_MODEL_NAME=openai/privacy-filter \
138
+ PRIVACY_FILTER_ADAPTER_NAME=iamSamurai/privacy-filter-nigeria \
139
+ uv run uvicorn api:app --reload
140
+
141
+ curl -X POST http://127.0.0.1:8000/predict \
142
+ -H "Content-Type: application/json" \
143
+ -d '{"text":"Amina Yusuf can be reached at +234 802 111 3344.","mode":"cleaned"}'
144
+ ```
145
+
146
+ ### Direct `transformers + peft` (advanced)
147
+
148
+ If you want to bypass the project runner, you must resize the base model's
149
+ classification head to match `token_label_names` from the adapter's
150
+ `adapter_config.json` before applying the LoRA weights. See
151
+ [`privacy_filter.py`](https://github.com/iamNarcisse/naija-privacy-filter/blob/main/privacy_filter.py)
152
+ for the reference implementation.
153
+
154
+ ## Intended Use
155
+
156
+ Use this adapter for:
157
+
158
+ - Research and evaluation of Nigerian-domain PII detection.
159
+ - Prototyping local inference or REST API integration for privacy-filtering
160
+ workflows.
161
+ - Studying LoRA adaptation and deterministic span postprocessing for
162
+ token-classification models.
163
+ - Producing candidate spans for downstream review, redaction, or policy
164
+ engines.
165
+
166
+ Do **not** use this adapter as the only control for regulatory, legal,
167
+ medical, financial, or irreversible privacy decisions.
168
+
169
+ ## Training Data
170
+
171
+ The source repository includes a tiny public synthetic example bundle,
172
+ `data/examples`:
173
+
174
+ | Split | Examples |
175
+ | --- | ---: |
176
+ | Train | 5 |
177
+ | Validation | 5 |
178
+ | Test | 5 |
179
+ | Challenge | 5 |
180
+
181
+ This example bundle is for schema inspection and smoke tests only. It is not a
182
+ training or evaluation release.
183
+
184
+ The current v5 adapter was trained and evaluated against a later private
185
+ stage2 v5 mixed dataset that is not distributed with this model card. That
186
+ private mix includes synthetic examples, OCR-derived Nigerian
187
+ identity-document samples used to test document-layout and OCR behavior, and
188
+ real-world domain samples. Direct identifiers and sensitive fields were
189
+ annotated and redacted from model-use fields. Source materials and derived
190
+ artifacts remain private and are not distributed.
191
+
192
+ Label space includes Nigerian-domain PII types such as `private_nin`,
193
+ `private_bvn`, `account_number`, `private_passport_number`,
194
+ `private_voters_card_number`, and `private_drivers_license_number`,
195
+ alongside generic PII labels: `private_person`, `private_email`,
196
+ `private_phone`, `private_address`, `private_date`, `private_url`, and
197
+ `secret`.
198
+
199
+ The committed public examples are **synthetic**. The private v5 mix is broader
200
+ and includes reviewed non-synthetic source material after direct identifiers
201
+ and sensitive fields were redacted from model-use fields. It is not a public
202
+ corpus of real user records.
203
+
204
+ ## Bias, Risks, And Limitations
205
+
206
+ This adapter is built on `openai/privacy-filter` and inherits the upstream
207
+ model's bias, risk, and limitation profile. The notes below summarize and
208
+ extend that profile for the Naija research preview. Consult the upstream
209
+ model card for the authoritative description of base-model behavior.
210
+
211
+ ### Over-Reliance
212
+
213
+ This adapter, like the base model, is a redaction and data-minimization aid.
214
+ It is not an anonymization, compliance, or safety guarantee. Treating its
215
+ output as a blanket anonymization claim risks missing the privacy objectives
216
+ the system is being deployed to support. Use it as one layer in a
217
+ privacy-by-design pipeline alongside policy controls, access controls,
218
+ logging discipline, and human review where mistakes have material impact.
219
+ The model detects spans; it does not by itself enforce retention, access
220
+ control, consent, or data-subject rights.
221
+
222
+ ### Static Label Policy
223
+
224
+ The model only detects spans that match its trained label taxonomy.
225
+ Real-world privacy policies vary, and label boundaries appropriate for one
226
+ organization may not be appropriate for another. Adjusting the policy
227
+ requires further finetuning, not runtime configuration. The Naija adapter
228
+ shifts boundaries for Nigerian-domain identifiers (NIN, BVN, NUBAN account
229
+ numbers, voter card, driver license, passport, addresses, phone formats),
230
+ but does not introduce a runtime policy configuration mechanism.
231
+
232
+ ### Domain And Language Coverage
233
+
234
+ Performance can drop on:
235
+
236
+ - non-English text and non-Latin scripts;
237
+ - naming patterns or identifier formats not represented in training data;
238
+ - domains outside the evaluated private mix, including unseen OCR layouts,
239
+ noisy chat logs, code-switched multilingual text, and organization-specific
240
+ record formats.
241
+
242
+ The private evaluation mix cannot fully represent every deployment
243
+ distribution. High typed-span F1 on the included splits should not be read as
244
+ evidence of production readiness on all real records.
245
+
246
+ ### Failure Modes
247
+
248
+ Like all models, this adapter can make mistakes. Common failure modes
249
+ include:
250
+
251
+ - under-detection of uncommon personal names, regional naming conventions,
252
+ initials, or honorific-heavy references;
253
+ - over-redaction of organizations, locations, or common nouns when local
254
+ context is ambiguous;
255
+ - fragmented or shifted span boundaries in mixed-format text, long
256
+ documents, or text with heavy punctuation and layout artifacts;
257
+ - structured-identifier ambiguity - a numeric string may be a NIN, BVN,
258
+ account number, invoice number, order ID, or unrelated code, and the
259
+ model cannot always disambiguate without surrounding context;
260
+ - missed secrets for novel credential formats, project-specific token
261
+ patterns, or secrets split across surrounding syntax;
262
+ - over-redaction of benign high-entropy strings, hashes, placeholders, sample
263
+ credentials, synthetic examples, dates, checksums, and routing IDs that
264
+ resemble real secrets or identity numbers.
265
+
266
+ Deterministic span postprocessing (`span_postprocess.py` in the source repo)
267
+ reduces some boundary and known-format failures, but it is tuned for the
268
+ synthetic Naija release. Applied outside that distribution it may itself
269
+ introduce false positives.
270
+
271
+ These failure modes can interact with demographic, regional, and domain
272
+ variation. Names and identifiers underrepresented in the training data, or
273
+ that follow conventions different from the dominant training distribution,
274
+ are more likely to be missed or inconsistently bounded.
275
+
276
+ ### High-Risk Deployment Caution
277
+
278
+ Additional caution is warranted in medical, legal, financial, human
279
+ resources, education, and government workflows. In these settings, both
280
+ false negatives and false positives can be costly: missed spans may expose
281
+ sensitive information, while excess masking can remove material context
282
+ needed for review, auditing, or downstream decisions. Do not use this adapter
283
+ as the only control in such workflows.
284
+
285
+ ### Recommendations
286
+
287
+ - Use the model as part of a privacy-by-design pipeline, not as a standalone
288
+ anonymization claim.
289
+ - Evaluate on representative in-domain data under local policy before
290
+ production use.
291
+ - Add deterministic filters for high-precision structured IDs where local
292
+ policy allows it.
293
+ - Finetune further when your policy boundaries differ from the trained
294
+ taxonomy or when hard-negative precision matters.
295
+ - Preserve human review paths for high-sensitivity workflows.
296
+
297
+ ## Privacy And Safety
298
+
299
+ The public example bundle is synthetic and should not intentionally contain
300
+ real personal data. Before publishing any new dataset, predictions, logs, or
301
+ eval artifacts derived from this adapter, inspect them for accidental real PII
302
+ or secrets.
303
+
304
+ Do not publish:
305
+
306
+ - raw real records;
307
+ - production prompts, logs, tickets, emails, or support transcripts
308
+ containing personal data;
309
+ - API keys, access tokens, cookies, or credentials;
310
+ - model outputs that include unredacted real PII from private systems;
311
+ - raw private/internal prediction JSONL or configs containing absolute paths,
312
+ private dataset IDs, or temporary directory names.
313
+
314
+ ## Citation And Attribution
315
+
316
+ If you use this adapter, please cite both the base model and this repository.
317
+ Preserve the adapter repo ID, dataset version, code commit, and evaluation
318
+ artifact commit in experiment reports so results are reproducible.
319
+
320
+ ```bibtex
321
+ @misc{egonu2026privacyfilternigeria,
322
+ author = {Egonu Narcisse},
323
+ title = {Privacy Filter Nigeria LoRA (v0.1 research preview)},
324
+ year = {2026},
325
+ url = {https://github.com/iamNarcisse/naija-privacy-filter},
326
+ note = {Adapter on top of openai/privacy-filter}
327
+ }
328
+ ```
329
+
330
+ ## License
331
 
332
+ This adapter is released under the Apache License, Version 2.0. The base
333
+ model `openai/privacy-filter` is governed by its own license; consult the
334
+ upstream model card for terms.