mypii 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mypii-1.0.0/.gitignore +23 -0
- mypii-1.0.0/CHANGELOG.md +42 -0
- mypii-1.0.0/CITATION.cff +32 -0
- mypii-1.0.0/LICENSE +21 -0
- mypii-1.0.0/PKG-INFO +242 -0
- mypii-1.0.0/README.md +211 -0
- mypii-1.0.0/config/kod_pb.yaml +94 -0
- mypii-1.0.0/config/mypii.yaml +632 -0
- mypii-1.0.0/config/ssm_rob.yaml +47 -0
- mypii-1.0.0/data/README.md +73 -0
- mypii-1.0.0/model/konteks-v2.json +1 -0
- mypii-1.0.0/mypii/__init__.py +11 -0
- mypii-1.0.0/mypii/analisis.py +143 -0
- mypii-1.0.0/mypii/iaa/__init__.py +1 -0
- mypii-1.0.0/mypii/iaa/eksport.py +69 -0
- mypii-1.0.0/mypii/iaa/llm.py +131 -0
- mypii-1.0.0/mypii/iaa/mesej.py +73 -0
- mypii-1.0.0/mypii/iaa/operasi.py +117 -0
- mypii-1.0.0/mypii/iaa/pakej.py +87 -0
- mypii-1.0.0/mypii/iaa/pelayan.py +212 -0
- mypii-1.0.0/mypii/iaa/sampel.py +83 -0
- mypii-1.0.0/mypii/iaa/skor.py +226 -0
- mypii-1.0.0/mypii/iaa/statik/app.css +119 -0
- mypii-1.0.0/mypii/iaa/statik/app.js +206 -0
- mypii-1.0.0/mypii/iaa/statik/index.html +71 -0
- mypii-1.0.0/mypii/iaa/statik/pintu.css +18 -0
- mypii-1.0.0/mypii/iaa/statik/pintu.html +37 -0
- mypii-1.0.0/mypii/iaa/stor.py +98 -0
- mypii-1.0.0/mypii/iaa/teks/en.json +38 -0
- mypii-1.0.0/mypii/iaa/teks/ms.json +38 -0
- mypii-1.0.0/mypii/jana/__init__.py +0 -0
- mypii-1.0.0/mypii/jana/jana.py +322 -0
- mypii-1.0.0/mypii/jana/nilai_palsu.py +141 -0
- mypii-1.0.0/mypii/jana/nilai_v3.py +109 -0
- mypii-1.0.0/mypii/jana/templat_llm.py +649 -0
- mypii-1.0.0/mypii/klien_anthropic.py +137 -0
- mypii-1.0.0/mypii/klien_llm.py +65 -0
- mypii-1.0.0/mypii/konfig.py +46 -0
- mypii-1.0.0/mypii/konteks_latih.py +97 -0
- mypii-1.0.0/mypii/nilai/__init__.py +0 -0
- mypii-1.0.0/mypii/nilai/bandingan.py +187 -0
- mypii-1.0.0/mypii/nilai/bandingan_md.py +133 -0
- mypii-1.0.0/mypii/nilai/bandingan_v2.py +122 -0
- mypii-1.0.0/mypii/nilai/carta.py +224 -0
- mypii-1.0.0/mypii/nilai/garis.py +198 -0
- mypii-1.0.0/mypii/nilai/harness.py +258 -0
- mypii-1.0.0/mypii/nilai/iterasi.py +97 -0
- mypii-1.0.0/mypii/nilai/ketidakpastian.py +123 -0
- mypii-1.0.0/mypii/nilai/kos_claude.py +236 -0
- mypii-1.0.0/mypii/nilai/kuasa.py +77 -0
- mypii-1.0.0/mypii/nilai/pradaftar.py +47 -0
- mypii-1.0.0/mypii/nilai/probe_llm.py +86 -0
- mypii-1.0.0/mypii/nilai/statistik.py +217 -0
- mypii-1.0.0/mypii/nilai/statistik_v2.py +53 -0
- mypii-1.0.0/mypii/nilai/v1_worktree.py +48 -0
- mypii-1.0.0/mypii/pengecam/__init__.py +13 -0
- mypii-1.0.0/mypii/pengecam/ciri.py +44 -0
- mypii-1.0.0/mypii/pengecam/konteks.py +119 -0
- mypii-1.0.0/mypii/pengecam/my_nric_recognizer.py +60 -0
- mypii-1.0.0/mypii/pengecam/my_phone_recognizer.py +52 -0
- mypii-1.0.0/mypii/pengecam/my_ssm_recognizer.py +54 -0
- mypii-1.0.0/mypii/pengecam/normal.py +46 -0
- mypii-1.0.0/mypii/pengecam/pengelas.py +42 -0
- mypii-1.0.0/pyproject.toml +70 -0
mypii-1.0.0/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
.ruff_cache/
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
hasil/*
|
|
6
|
+
!hasil/cache/
|
|
7
|
+
!hasil/cache/**
|
|
8
|
+
!hasil/dev-masa.json
|
|
9
|
+
# PELAN-C (ADR-006): rekod iterasi + carta + statistik dev dikomit; hasil/ramalan/ dan hasil/*ujian* KEKAL diabaikan
|
|
10
|
+
!hasil/iterasi.tsv
|
|
11
|
+
!hasil/kemajuan.svg
|
|
12
|
+
!hasil/dev-statistik.json
|
|
13
|
+
# PELAN-IAA P9 (ADR-015): skor persetujuan + kadar ralat label (kiraan sahaja, tiada teks)
|
|
14
|
+
!hasil/iaa.json
|
|
15
|
+
# PELAN-CLAUDE P3 (ADR-016): anggaran kos Claude dev (kiraan token + USD sahaja)
|
|
16
|
+
!hasil/dev-kos-claude.json
|
|
17
|
+
# PELAN-MODEL-LAIN P3/P4 (ADR-017): probe format eksplorasi (kiraan + jenis ralat sahaja)
|
|
18
|
+
!hasil/dev-probe-llm.json
|
|
19
|
+
# PELAN-V2 P12/P13: statistik + kuasa dev3 (kiraan sahaja) — sumber angka pindaan kuasa v2
|
|
20
|
+
!hasil/dev3-statistik.json
|
|
21
|
+
# 6 Nov 2026: salinan arkib larian ujian muktamad (v1 ujian/ujian2 + v2 ujian3) — keputusan + ramalan + cache, MANIFEST.sha256
|
|
22
|
+
!hasil/arkib/
|
|
23
|
+
!hasil/arkib/**
|
mypii-1.0.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
**BM** · Semua perubahan penting projek ini direkod di sini. Format ikut [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/)
|
|
4
|
+
dan versi ikut [Semantic Versioning](https://semver.org/). Keputusan reka bentuk penuh ada dalam `docs/adr/`.
|
|
5
|
+
**EN** · All notable changes to this project are recorded here. The format follows
|
|
6
|
+
[Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) and versions follow [Semantic Versioning](https://semver.org/).
|
|
7
|
+
Full design decisions live in `docs/adr/`.
|
|
8
|
+
|
|
9
|
+
## [1.0.0] - 2026-11-06
|
|
10
|
+
|
|
11
|
+
Keluaran awam pertama; membawa pengecam v2. / First public release; ships recognizer v2.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Three Presidio recognizers: `MY_NRIC` (MyKad number with birth date and official JPN place-of-birth code check), `MY_SSM`
|
|
16
|
+
(SSM registration number: new 12-digit format, old format, LLP) and `MY_PHONE` (Malaysian phone numbers), with context words for
|
|
17
|
+
Malay, English and Manglish text (ADR-001).
|
|
18
|
+
- Recognizer v2: OCR normalisation inside numbers, line-broken numbers, bracketed Sabah and Sarawak area codes, the LLP rule
|
|
19
|
+
(year 2012 or later) and a small local context classifier (logistic regression, numpy only, sha256-checked artifact) (ADR-018).
|
|
20
|
+
- `all_recognizers()`, an English alias of `semua_pengecam()`.
|
|
21
|
+
- MyPII-Bench: 11,000 synthetic documents in seven splits, three of them sealed test splits locked by sha256 (`ujian`, `ujian2`,
|
|
22
|
+
`ujian3`), with a dataset card and a canary string (`data/README.md`).
|
|
23
|
+
- Evaluation script with span-level precision, recall and F1, bootstrap intervals, Holm-corrected tests and an iteration log
|
|
24
|
+
(ADR-006, ADR-007, ADR-014).
|
|
25
|
+
- Baselines scored by the same evaluation script: stock Presidio, `malaysia-pii-guard` and zero-shot LLMs, with LLM answers cached in the repo so
|
|
26
|
+
scores reproduce offline (ADR-011, ADR-016, ADR-017).
|
|
27
|
+
- Pre-registration (`docs/PRA-DAFTAR.md`) and the archive of every test run with manifests (`hasil/arkib/`, `docs/PROVENANS.md`).
|
|
28
|
+
- Human label review protocol and results on a 300-document sample: one human plus one LLM reviewer (ADR-015).
|
|
29
|
+
- Comparison reports `docs/BANDINGAN.md` (dev, v1) and `docs/BANDINGAN-V2.md` (dev3 and `ujian3`, v2).
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- The wheel now carries `config/` and the classifier artifact inside the package, so `pip install mypii` works without a clone.
|
|
34
|
+
- Evaluation and training tools moved from extras to dependency groups (`uv sync --group nilai --group garis --group latih`),
|
|
35
|
+
because PyPI rejects direct URL dependencies in package metadata.
|
|
36
|
+
|
|
37
|
+
### Known limitations
|
|
38
|
+
|
|
39
|
+
- All benchmark text is synthetic and labels are machine-generated; results on real text are not measured.
|
|
40
|
+
- On the older-style `dev` split, v2 scores lower than v1 (F1 0.840 versus 0.888), mostly `MY_SSM` precision.
|
|
41
|
+
- Phone recall is optimistic: synthetic phone labels only use number ranges that libphonenumber accepts (ADR-002).
|
|
42
|
+
- The label review has one human reviewer, not two.
|
mypii-1.0.0/CITATION.cff
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use MyPII or MyPII-Bench, please cite it using the metadata in this file."
|
|
3
|
+
type: software
|
|
4
|
+
title: "MyPII: Malaysian PII recognizers for Presidio and the MyPII-Bench synthetic benchmark"
|
|
5
|
+
abstract: >-
|
|
6
|
+
MyPII is a set of Malaysian PII recognizers for Presidio. It detects MyKad (NRIC) numbers,
|
|
7
|
+
SSM company registration numbers and Malaysian phone numbers in Malay, English and Manglish text.
|
|
8
|
+
It runs entirely on the local machine (rules, validation and a small logistic-regression context classifier; no external API), so text
|
|
9
|
+
never leaves the machine and every decision can be audited. The repository also ships MyPII-Bench,
|
|
10
|
+
a synthetic benchmark with machine-generated labels for evaluating recognizers like these.
|
|
11
|
+
authors:
|
|
12
|
+
- family-names: Malib
|
|
13
|
+
given-names: Aiman
|
|
14
|
+
orcid: "https://orcid.org/0009-0000-1719-9800"
|
|
15
|
+
affiliation: "Sasa Teguh"
|
|
16
|
+
version: 1.0.0
|
|
17
|
+
date-released: "2026-11-06"
|
|
18
|
+
license: MIT
|
|
19
|
+
repository-code: "https://github.com/sasateguh/mypii"
|
|
20
|
+
keywords:
|
|
21
|
+
- privacy
|
|
22
|
+
- nlp
|
|
23
|
+
- benchmark
|
|
24
|
+
- synthetic-data
|
|
25
|
+
- named-entity-recognition
|
|
26
|
+
- pii
|
|
27
|
+
- data-privacy
|
|
28
|
+
- anonymization
|
|
29
|
+
- pii-detection
|
|
30
|
+
- malaysia
|
|
31
|
+
- presidio
|
|
32
|
+
- phone-numbers
|
mypii-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aiman Malib (Sasa Teguh)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
mypii-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mypii
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Malaysian PII recognizers (MyKad, SSM, phone) for Presidio, plus the MyPII-Bench synthetic BM/EN/Manglish benchmark
|
|
5
|
+
Project-URL: Homepage, https://github.com/sasateguh/mypii
|
|
6
|
+
Project-URL: Source, https://github.com/sasateguh/mypii
|
|
7
|
+
Project-URL: Issues, https://github.com/sasateguh/mypii/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/sasateguh/mypii/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Aiman Malib
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: anonymization,data-privacy,malaysia,mykad,nlp,nric,pii,pii-detection,presidio
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Natural Language :: English
|
|
17
|
+
Classifier: Natural Language :: Malay
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Security
|
|
23
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
24
|
+
Requires-Python: <3.14,>=3.11
|
|
25
|
+
Requires-Dist: numpy>=1.26
|
|
26
|
+
Requires-Dist: phonenumbers>=8.13
|
|
27
|
+
Requires-Dist: presidio-analyzer>=2.2.366
|
|
28
|
+
Requires-Dist: pyyaml>=6
|
|
29
|
+
Requires-Dist: regex>=2023.0
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# MyPII
|
|
33
|
+
|
|
34
|
+
**BM** · MyPII mengesan nombor MyKad, nombor pendaftaran SSM dan nombor telefon Malaysia dalam teks BM, EN dan Manglish, sebagai
|
|
35
|
+
pengecam tambahan untuk [Presidio](https://github.com/data-privacy-stack/presidio). Ia berjalan sepenuhnya pada mesin anda: peraturan,
|
|
36
|
+
pengesahan (tarikh lahir dan kod tempat lahir JPN, format SSM, libphonenumber) dan satu pengelas konteks kecil (regresi logistik,
|
|
37
|
+
numpy). Tiada API luar, jadi teks tidak keluar dari mesin. Repo ini juga membawa MyPII-Bench, penanda aras sintetik untuk menilai
|
|
38
|
+
pengecam seperti ini, berserta pra-daftar hipotesis dan arkib setiap larian ujian.
|
|
39
|
+
|
|
40
|
+
**EN** · MyPII detects Malaysian MyKad (NRIC) numbers, SSM company registration numbers and Malaysian phone numbers in Malay, English
|
|
41
|
+
and Manglish text, as add-on recognizers for [Presidio](https://github.com/data-privacy-stack/presidio). It runs entirely on your
|
|
42
|
+
machine: rules, validation (JPN birth date and place-of-birth codes, SSM format, libphonenumber) and one small context classifier
|
|
43
|
+
(logistic regression, numpy). There is no external API, so text never leaves the machine. The repo also ships MyPII-Bench, a synthetic
|
|
44
|
+
benchmark for evaluating recognizers like these, together with a pre-registration and the archive of every test run.
|
|
45
|
+
|
|
46
|
+
## Pasang / Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install mypii
|
|
50
|
+
python -m spacy download en_core_web_sm
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**BM** · Python 3.11 hingga 3.13. Model spaCy kecil itu ialah enjin NLP untuk Presidio dalam contoh di bawah. Sebelum pakej ada di
|
|
54
|
+
PyPI, pasang terus dari GitHub: `pip install "mypii @ git+https://github.com/sasateguh/mypii@v1.0.0"`.
|
|
55
|
+
**EN** · Python 3.11 to 3.13. The small spaCy model is the NLP engine Presidio uses in the example below. If the package is not on
|
|
56
|
+
PyPI yet, install straight from GitHub: `pip install "mypii @ git+https://github.com/sasateguh/mypii@v1.0.0"`.
|
|
57
|
+
|
|
58
|
+
## Contoh / Example
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from presidio_analyzer import AnalyzerEngine
|
|
62
|
+
from presidio_analyzer.nlp_engine import NlpEngineProvider
|
|
63
|
+
from mypii import semua_pengecam
|
|
64
|
+
|
|
65
|
+
nlp = NlpEngineProvider(nlp_configuration={
|
|
66
|
+
"nlp_engine_name": "spacy",
|
|
67
|
+
"models": [{"lang_code": "en", "model_name": "en_core_web_sm"}],
|
|
68
|
+
}).create_engine()
|
|
69
|
+
engine = AnalyzerEngine(nlp_engine=nlp, supported_languages=["en"])
|
|
70
|
+
for r in semua_pengecam():
|
|
71
|
+
engine.registry.add_recognizer(r)
|
|
72
|
+
|
|
73
|
+
teks = "No IC saya 900101-08-1234, call 012-345 6789. Syarikat SSM 201901000005."
|
|
74
|
+
hasil = engine.analyze(teks, language="en", entities=["MY_NRIC", "MY_SSM", "MY_PHONE"])
|
|
75
|
+
for r in sorted(hasil, key=lambda r: r.start):
|
|
76
|
+
print(r.entity_type, teks[r.start:r.end], r.score)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Output:
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
MY_NRIC 900101-08-1234 1.0
|
|
83
|
+
MY_PHONE 012-345 6789 1.0
|
|
84
|
+
MY_SSM 201901000005 1.0
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**BM** · `all_recognizers()` ialah nama Inggeris untuk fungsi yang sama dengan `semua_pengecam()`. Konfigurasi `en_core_web_sm` itu
|
|
88
|
+
sengaja: `AnalyzerEngine()` lalai memuat turun `en_core_web_lg` (382 MB). Tanpa `entities=`, pengecam asal Presidio turut
|
|
89
|
+
memulangkan jenis lain (contohnya `UK_NHS`, `DATE_TIME`) atas nombor yang sama.
|
|
90
|
+
**EN** · `all_recognizers()` is the English name for the same function as `semua_pengecam()`. The `en_core_web_sm` configuration is
|
|
91
|
+
deliberate: a default `AnalyzerEngine()` downloads `en_core_web_lg` (382 MB). Without `entities=`, stock Presidio recognizers also
|
|
92
|
+
return other types (for example `UK_NHS`, `DATE_TIME`) on the same numbers.
|
|
93
|
+
|
|
94
|
+
## Entiti / Entities
|
|
95
|
+
|
|
96
|
+
| Entiti | Contoh (sintetik) | Pengesahan / Validation |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `MY_NRIC` | `900101-08-1234` | Tarikh lahir sah + kod tempat lahir JPN (86 kod, [JPN](https://www.jpn.gov.my/my/kod-negeri)) / valid birth date + official place-of-birth code |
|
|
99
|
+
| `MY_SSM` | `201901000005` | Tahun + kod jenis entiti 01 hingga 06 (format SSM sejak 11 Okt 2019), format lama, LLP / year + entity type code, old format, LLP |
|
|
100
|
+
| `MY_PHONE` | `+60 12-345 6789` | libphonenumber, rantau MY / region MY |
|
|
101
|
+
|
|
102
|
+
## Keputusan / Results
|
|
103
|
+
|
|
104
|
+
F1 padanan tepat mikro, semua entiti / exact-match micro F1, all entities. Versi 1.0.0 membawa pengecam **v2** / release 1.0.0 ships
|
|
105
|
+
recognizer **v2**.
|
|
106
|
+
|
|
107
|
+
| Split | Teks / Text | MyPII v1 | MyPII v2 (1.0.0) | Claude Haiku 5.5 | Claude Sonnet 5.5 | Presidio asal / stock |
|
|
108
|
+
|---|---|---|---|---|---|---|
|
|
109
|
+
| `dev` | pembangunan v1 / v1 development | 0.888 | 0.840 | 0.915 | 0.878 | 0.431 |
|
|
110
|
+
| `ujian` † | templat simpanan v1 / held-out v1 templates | **0.993** | – | 0.965 | 0.982 | 0.526 |
|
|
111
|
+
| `ujian2` † | templat Kimi K3 / Kimi K3 templates | **0.940** | – | 0.873 | 0.885 | 0.419 |
|
|
112
|
+
| `dev3` | pembangunan v2, templat Nemotron / v2 development | 0.615 | 0.998 | 0.791 | – | 0.290 |
|
|
113
|
+
| `ujian3` † | templat Claude Sonnet 5.5 / Claude Sonnet 5.5 templates | 0.587 | **0.980** | 0.871 | – | 0.325 |
|
|
114
|
+
|
|
115
|
+
† Split ujian: dikunci sha256 sebelum dinilai, dibuka sekali sahaja, hipotesis didaftar dahulu dalam
|
|
116
|
+
[`docs/PRA-DAFTAR.md`](docs/PRA-DAFTAR.md) / test split: locked by sha256 before scoring, opened once, hypotheses registered in
|
|
117
|
+
advance. `dev` dan `dev3` dipakai semasa pembangunan, jadi angka MyPII di situ optimistik / `dev` and `dev3` were used during
|
|
118
|
+
development, so MyPII's numbers there are optimistic. – = tidak dijalankan / not run.
|
|
119
|
+
|
|
120
|
+
**BM** · Cara membaca jadual ini:
|
|
121
|
+
- Hipotesis pra-daftar yang diuji semuanya disokong selepas pembetulan Holm: v1 mengatasi enam garis dasar atas `ujian2` (H1a hingga
|
|
122
|
+
H1f, utama) dan atas `ujian` (H2a hingga H2f, sekunder); v2 tidak kalah kepada Haiku (Δ +0.109) dan mengatasi v1 (Δ +0.393) atas
|
|
123
|
+
`ujian3` (H4a, H4b). Beza v1 dengan Sonnet atas `ujian` kecil (Δ +0.0115) walaupun signifikan. Hipotesis sekunder H3 (setiap
|
|
124
|
+
entiti) belum dilapor.
|
|
125
|
+
- v2 menambah normalisasi OCR dalam nombor, nombor yang dipecah baris, kod kawasan Sabah dan Sarawak berkurung, peraturan LLP dan
|
|
126
|
+
pengelas konteks. Atas teks gaya baharu (`dev3`, `ujian3`) ia jauh lebih baik. Atas teks gaya lama (`dev`) ia lebih rendah daripada
|
|
127
|
+
v1 (0.840 lawan 0.888), terutamanya `MY_SSM` (ketepatan 0.51). Tiada versi yang menang di setiap gaya teks, jadi nilai atas data anda
|
|
128
|
+
sendiri dahulu.
|
|
129
|
+
- v2 tidak dinilai atas `ujian` dan `ujian2` kerana kedua-dua split itu sudah dibuka untuk v1. Larian v2 di situ sekarang ialah
|
|
130
|
+
analisis selepas kejadian, bukan ujian.
|
|
131
|
+
- Selang keyakinan, ketepatan dan dapatan semula setiap entiti, setiap bahasa dan setiap kategori ada dalam
|
|
132
|
+
[`docs/BANDINGAN-V2.md`](docs/BANDINGAN-V2.md) dan [`docs/BANDINGAN.md`](docs/BANDINGAN.md). Keputusan `ujian` dan `ujian2` ada
|
|
133
|
+
dalam [`docs/LOG-ITERASI.md`](docs/LOG-ITERASI.md) dan arkib `hasil/arkib/`.
|
|
134
|
+
|
|
135
|
+
**EN** · How to read this table:
|
|
136
|
+
- Every pre-registered hypothesis tested so far is supported after Holm correction: v1 beats six baselines on `ujian2` (H1a to H1f,
|
|
137
|
+
primary) and on `ujian` (H2a to H2f, secondary); v2 is not worse than Haiku (Δ +0.109) and beats v1 (Δ +0.393) on `ujian3` (H4a,
|
|
138
|
+
H4b). The v1 margin over Sonnet on `ujian` is small (Δ +0.0115) although significant. The secondary per-entity hypothesis H3 is not
|
|
139
|
+
reported yet.
|
|
140
|
+
- v2 adds OCR normalisation inside numbers, line-broken numbers, bracketed Sabah and Sarawak area codes, the LLP rule and the context
|
|
141
|
+
classifier. On new-style text (`dev3`, `ujian3`) it is far better. On old-style text (`dev`) it is lower than v1 (0.840 versus
|
|
142
|
+
0.888), mostly `MY_SSM` (precision 0.51). No version wins on every text style, so evaluate on your own data first.
|
|
143
|
+
- v2 was not scored on `ujian` and `ujian2` because both splits were already opened for v1. A v2 run there now would be a post-hoc
|
|
144
|
+
analysis, not a test.
|
|
145
|
+
- Confidence intervals and per-entity, per-language and per-category precision and recall are in
|
|
146
|
+
[`docs/BANDINGAN-V2.md`](docs/BANDINGAN-V2.md) and [`docs/BANDINGAN.md`](docs/BANDINGAN.md). The `ujian` and `ujian2` results are in
|
|
147
|
+
[`docs/LOG-ITERASI.md`](docs/LOG-ITERASI.md) and the `hasil/arkib/` archive.
|
|
148
|
+
|
|
149
|
+
## Had kajian / Limitations
|
|
150
|
+
|
|
151
|
+
**BM**
|
|
152
|
+
- **Sintetik sepenuhnya.** Teks ditulis LLM dengan slot bertanda, kemudian diisi nilai rekaan, jadi label diketahui tanpa anotasi
|
|
153
|
+
manual. Pembina yang sama menulis penjana data dan pengecam. Keputusan atas teks sebenar belum diukur dan mungkin lebih rendah.
|
|
154
|
+
- **Keluarga Claude terlibat di tiga tempat.** Kod ditulis dengan ejen Claude, templat `ujian3` dijana Claude Sonnet, dan Claude Haiku
|
|
155
|
+
ialah pembanding H4a. Arah bias itu menentang MyPII bagi H4a.
|
|
156
|
+
- **Semakan label = satu manusia + satu LLM, bukan dua manusia.** Atas sampel 300 dokumen, penyemak manusia mendapati 0.000 span
|
|
157
|
+
salah dan 0.067 [0.027, 0.113] dokumen ada PII yang tidak bertanda. κ tidak bermakna kerana hampir tiada varians.
|
|
158
|
+
- **Dapatan semula telefon optimistik.** Label telefon dijana dalam julat sah libphonenumber, pustaka yang sama dipakai pengecam
|
|
159
|
+
([ADR-002](docs/adr/002-penanda-aras-sintetik.md)).
|
|
160
|
+
- **MyPII mengesan span, bukan menilai risiko.** Ia bukan alat anonimisasi lengkap dan bukan bukti pematuhan PDPA.
|
|
161
|
+
|
|
162
|
+
**EN**
|
|
163
|
+
- **Fully synthetic.** Text is written by LLMs with marked slots and filled with invented values, so labels are known without manual
|
|
164
|
+
annotation. The same builder wrote the data generator and the recognizer. Results on real text are not measured and may be lower.
|
|
165
|
+
- **The Claude family appears in three places.** The code was written with Claude agents, the `ujian3` templates were generated by
|
|
166
|
+
Claude Sonnet, and Claude Haiku is the H4a comparator. That bias runs against MyPII for H4a.
|
|
167
|
+
- **Label review = one human + one LLM, not two humans.** On a 300-document sample the human reviewer found 0.000 wrong spans and
|
|
168
|
+
0.067 [0.027, 0.113] of documents with unmarked PII. κ is not meaningful because there is almost no variance.
|
|
169
|
+
- **Phone recall is optimistic.** Phone labels are drawn from libphonenumber's valid ranges, the same library the recognizer uses
|
|
170
|
+
([ADR-002](docs/adr/002-penanda-aras-sintetik.md)).
|
|
171
|
+
- **MyPII finds spans; it does not assess risk.** It is not a complete anonymisation tool and not evidence of PDPA compliance.
|
|
172
|
+
|
|
173
|
+
## Penanda aras / Benchmark
|
|
174
|
+
|
|
175
|
+
**BM** · MyPII-Bench (`data/`, CC-BY-4.0) ada lima split 1000 dokumen setiap satu (`dev`, `ujian`, `ujian2`, `dev3`, `ujian3`)
|
|
176
|
+
serta split latihan. Kad set data: [`data/README.md`](data/README.md). Split ujian kini awam, jadi model yang dilatih selepas tarikh
|
|
177
|
+
keluaran mungkin pernah melihatnya; rentetan canary dalam kad set data membantu pembina model menapisnya.
|
|
178
|
+
**EN** · MyPII-Bench (`data/`, CC-BY-4.0) has five 1000-document splits (`dev`, `ujian`, `ujian2`, `dev3`, `ujian3`) plus training
|
|
179
|
+
splits. Dataset card: [`data/README.md`](data/README.md). The test splits are now public, so models trained after the release date may
|
|
180
|
+
have seen them; the canary string in the dataset card helps model builders filter them out.
|
|
181
|
+
|
|
182
|
+
## Jana semula / Reproduce
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
git clone https://github.com/sasateguh/mypii.git && cd mypii
|
|
186
|
+
uv sync --all-groups # alat penilaian: model spaCy, malaysia-pii-guard, SDK Anthropic, scikit-learn
|
|
187
|
+
make uji # ujian unit + kunci sha256 setiap split
|
|
188
|
+
make bandingan-v2 # docs/BANDINGAN-V2.md dari arkib ujian3, tanpa rangkaian
|
|
189
|
+
make bandingan # docs/BANDINGAN.md dari cache LLM yang dikomit, tanpa rangkaian
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**BM** · Jawapan LLM disimpan dalam cache yang dikomit, jadi skor garis dasar boleh dijana semula tanpa kunci API. Bukti meterai,
|
|
193
|
+
arkib larian ujian dan suntingan dokumen diterangkan dalam [`docs/PROVENANS.md`](docs/PROVENANS.md).
|
|
194
|
+
**EN** · LLM answers are stored in the committed cache, so baseline scores regenerate without API keys. Seal evidence, test-run
|
|
195
|
+
archives and document redactions are explained in [`docs/PROVENANS.md`](docs/PROVENANS.md).
|
|
196
|
+
|
|
197
|
+
## Dokumen / Documents
|
|
198
|
+
|
|
199
|
+
- [`docs/PRA-DAFTAR.md`](docs/PRA-DAFTAR.md): hipotesis, split, ujian statistik dan pindaan / hypotheses, splits, statistical tests and amendments.
|
|
200
|
+
- [`docs/BANDINGAN-V2.md`](docs/BANDINGAN-V2.md), [`docs/BANDINGAN.md`](docs/BANDINGAN.md): laporan bandingan / comparison reports.
|
|
201
|
+
- [`docs/LOG-ITERASI.md`](docs/LOG-ITERASI.md): log setiap langkah dan ukuran / log of every step and measurement.
|
|
202
|
+
- [`docs/ANALISIS-RALAT.md`](docs/ANALISIS-RALAT.md): analisis ralat v1 / v1 error analysis.
|
|
203
|
+
- [`docs/adr/`](docs/adr/): rekod keputusan / decision records.
|
|
204
|
+
- [`docs/IAA-SEMAKAN.md`](docs/IAA-SEMAKAN.md): cara semakan label manusia / how the human label review works.
|
|
205
|
+
- [`docs/PENDEDAHAN-AI.md`](docs/PENDEDAHAN-AI.md): apa yang dibuat ejen AI dan apa yang dibuat manusia / what AI agents did and what humans did.
|
|
206
|
+
- [`docs/PROVENANS.md`](docs/PROVENANS.md): meterai, arkib dan suntingan / seals, archives and redactions.
|
|
207
|
+
|
|
208
|
+
## Keputusan dev v1 (sejarah) / v1 dev results (history)
|
|
209
|
+
|
|
210
|
+
**BM** · Jadual ini dijana sebelum v2 wujud, jadi baris `mypii` ialah **MyPII v1**. Enam garis dasar ialah pengesahan (Holm k = 6);
|
|
211
|
+
Mistral Small 3.1 dan GLM-5.3-Flash ialah eksplorasi (ADR-017), bukan dakwaan.
|
|
212
|
+
**EN** · This table was generated before v2 existed, so the `mypii` row is **MyPII v1**. Six baselines are confirmatory (Holm k = 6);
|
|
213
|
+
Mistral Small 3.1 and GLM-5.3-Flash are exploratory (ADR-017), not claims.
|
|
214
|
+
|
|
215
|
+
<!-- jadual-dev:mula -->
|
|
216
|
+
<!-- dijana `make readme` (scripts/jana_readme.py) dari hasil/dev-*.json; jangan sunting dengan tangan -->
|
|
217
|
+
|
|
218
|
+
Split `dev`, 1000 dokumen / documents, padanan tepat / exact match, `semua|*`. Selang = bootstrap 95% (1000 ulangan / resamples, unit `dokumen`). Δ = F1 MyPII tolak F1 sistem / MyPII minus system (negatif = sistem lebih baik / negative = system is better). P/R: `docs/BANDINGAN.md`.
|
|
219
|
+
|
|
220
|
+
| Sistem / System | F1 | Selang F1 / F1 interval | Δ F1 [selang / interval] |
|
|
221
|
+
|---|---|---|---|
|
|
222
|
+
| `mypii` | **0.8877** | [0.8701, 0.9037] | rujukan / reference |
|
|
223
|
+
| `anthropic/claude-haiku-5-5` | **0.9149** | [0.8979, 0.9312] | -0.0272 [-0.0465, -0.0094] |
|
|
224
|
+
| `anthropic/claude-sonnet-5-5` | **0.8782** | [0.8578, 0.8966] | +0.0095 [-0.0086, 0.0268] |
|
|
225
|
+
| `cf/@cf/meta/llama-3.3-70b-instruct-fp8-fast` | **0.7060** | [0.6777, 0.7335] | +0.1817 [0.1591, 0.2028] |
|
|
226
|
+
| `cf/@cf/mistralai/mistral-small-3.1-24b-instruct` (eksplorasi / exploratory) | **0.8513** | [0.8290, 0.8710] | +0.0364 [0.0165, 0.0583] |
|
|
227
|
+
| `rv/deepseek-ai/DeepSeek-V4.1-Flash` | **0.7193** | [0.6899, 0.7483] | +0.1684 [0.1467, 0.1897] |
|
|
228
|
+
| `rv/zai-org/GLM-5.3-Flash` (eksplorasi / exploratory) | **0.8889** | [0.8699, 0.9059] | -0.0012 [-0.0197, 0.0169] |
|
|
229
|
+
| `pii-guard` | **0.7209** | [0.6977, 0.7434] | +0.1668 [0.1415, 0.1908] |
|
|
230
|
+
| `presidio-asal` | **0.4309** | [0.4078, 0.4554] | +0.4568 [0.4299, 0.4813] |
|
|
231
|
+
<!-- jadual-dev:tamat -->
|
|
232
|
+
|
|
233
|
+
## Petik / Cite
|
|
234
|
+
|
|
235
|
+
**BM** · Metadata petikan ada dalam [`CITATION.cff`](CITATION.cff) (GitHub memaparkannya sebagai "Cite this repository"). DOI Zenodo
|
|
236
|
+
ditambah di sini selepas keluaran pertama.
|
|
237
|
+
**EN** · Citation metadata lives in [`CITATION.cff`](CITATION.cff) (GitHub shows it as "Cite this repository"). The Zenodo DOI is
|
|
238
|
+
added here after the first release.
|
|
239
|
+
|
|
240
|
+
## Lesen / License
|
|
241
|
+
|
|
242
|
+
Kod / code: MIT ([`LICENSE`](LICENSE)). Set data / dataset (`data/`): CC-BY-4.0. © 2026 Aiman Malib (Sasa Teguh).
|
mypii-1.0.0/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# MyPII
|
|
2
|
+
|
|
3
|
+
**BM** · MyPII mengesan nombor MyKad, nombor pendaftaran SSM dan nombor telefon Malaysia dalam teks BM, EN dan Manglish, sebagai
|
|
4
|
+
pengecam tambahan untuk [Presidio](https://github.com/data-privacy-stack/presidio). Ia berjalan sepenuhnya pada mesin anda: peraturan,
|
|
5
|
+
pengesahan (tarikh lahir dan kod tempat lahir JPN, format SSM, libphonenumber) dan satu pengelas konteks kecil (regresi logistik,
|
|
6
|
+
numpy). Tiada API luar, jadi teks tidak keluar dari mesin. Repo ini juga membawa MyPII-Bench, penanda aras sintetik untuk menilai
|
|
7
|
+
pengecam seperti ini, berserta pra-daftar hipotesis dan arkib setiap larian ujian.
|
|
8
|
+
|
|
9
|
+
**EN** · MyPII detects Malaysian MyKad (NRIC) numbers, SSM company registration numbers and Malaysian phone numbers in Malay, English
|
|
10
|
+
and Manglish text, as add-on recognizers for [Presidio](https://github.com/data-privacy-stack/presidio). It runs entirely on your
|
|
11
|
+
machine: rules, validation (JPN birth date and place-of-birth codes, SSM format, libphonenumber) and one small context classifier
|
|
12
|
+
(logistic regression, numpy). There is no external API, so text never leaves the machine. The repo also ships MyPII-Bench, a synthetic
|
|
13
|
+
benchmark for evaluating recognizers like these, together with a pre-registration and the archive of every test run.
|
|
14
|
+
|
|
15
|
+
## Pasang / Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install mypii
|
|
19
|
+
python -m spacy download en_core_web_sm
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**BM** · Python 3.11 hingga 3.13. Model spaCy kecil itu ialah enjin NLP untuk Presidio dalam contoh di bawah. Sebelum pakej ada di
|
|
23
|
+
PyPI, pasang terus dari GitHub: `pip install "mypii @ git+https://github.com/sasateguh/mypii@v1.0.0"`.
|
|
24
|
+
**EN** · Python 3.11 to 3.13. The small spaCy model is the NLP engine Presidio uses in the example below. If the package is not on
|
|
25
|
+
PyPI yet, install straight from GitHub: `pip install "mypii @ git+https://github.com/sasateguh/mypii@v1.0.0"`.
|
|
26
|
+
|
|
27
|
+
## Contoh / Example
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from presidio_analyzer import AnalyzerEngine
|
|
31
|
+
from presidio_analyzer.nlp_engine import NlpEngineProvider
|
|
32
|
+
from mypii import semua_pengecam
|
|
33
|
+
|
|
34
|
+
nlp = NlpEngineProvider(nlp_configuration={
|
|
35
|
+
"nlp_engine_name": "spacy",
|
|
36
|
+
"models": [{"lang_code": "en", "model_name": "en_core_web_sm"}],
|
|
37
|
+
}).create_engine()
|
|
38
|
+
engine = AnalyzerEngine(nlp_engine=nlp, supported_languages=["en"])
|
|
39
|
+
for r in semua_pengecam():
|
|
40
|
+
engine.registry.add_recognizer(r)
|
|
41
|
+
|
|
42
|
+
teks = "No IC saya 900101-08-1234, call 012-345 6789. Syarikat SSM 201901000005."
|
|
43
|
+
hasil = engine.analyze(teks, language="en", entities=["MY_NRIC", "MY_SSM", "MY_PHONE"])
|
|
44
|
+
for r in sorted(hasil, key=lambda r: r.start):
|
|
45
|
+
print(r.entity_type, teks[r.start:r.end], r.score)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Output:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
MY_NRIC 900101-08-1234 1.0
|
|
52
|
+
MY_PHONE 012-345 6789 1.0
|
|
53
|
+
MY_SSM 201901000005 1.0
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**BM** · `all_recognizers()` ialah nama Inggeris untuk fungsi yang sama dengan `semua_pengecam()`. Konfigurasi `en_core_web_sm` itu
|
|
57
|
+
sengaja: `AnalyzerEngine()` lalai memuat turun `en_core_web_lg` (382 MB). Tanpa `entities=`, pengecam asal Presidio turut
|
|
58
|
+
memulangkan jenis lain (contohnya `UK_NHS`, `DATE_TIME`) atas nombor yang sama.
|
|
59
|
+
**EN** · `all_recognizers()` is the English name for the same function as `semua_pengecam()`. The `en_core_web_sm` configuration is
|
|
60
|
+
deliberate: a default `AnalyzerEngine()` downloads `en_core_web_lg` (382 MB). Without `entities=`, stock Presidio recognizers also
|
|
61
|
+
return other types (for example `UK_NHS`, `DATE_TIME`) on the same numbers.
|
|
62
|
+
|
|
63
|
+
## Entiti / Entities
|
|
64
|
+
|
|
65
|
+
| Entiti | Contoh (sintetik) | Pengesahan / Validation |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `MY_NRIC` | `900101-08-1234` | Tarikh lahir sah + kod tempat lahir JPN (86 kod, [JPN](https://www.jpn.gov.my/my/kod-negeri)) / valid birth date + official place-of-birth code |
|
|
68
|
+
| `MY_SSM` | `201901000005` | Tahun + kod jenis entiti 01 hingga 06 (format SSM sejak 11 Okt 2019), format lama, LLP / year + entity type code, old format, LLP |
|
|
69
|
+
| `MY_PHONE` | `+60 12-345 6789` | libphonenumber, rantau MY / region MY |
|
|
70
|
+
|
|
71
|
+
## Keputusan / Results
|
|
72
|
+
|
|
73
|
+
F1 padanan tepat mikro, semua entiti / exact-match micro F1, all entities. Versi 1.0.0 membawa pengecam **v2** / release 1.0.0 ships
|
|
74
|
+
recognizer **v2**.
|
|
75
|
+
|
|
76
|
+
| Split | Teks / Text | MyPII v1 | MyPII v2 (1.0.0) | Claude Haiku 5.5 | Claude Sonnet 5.5 | Presidio asal / stock |
|
|
77
|
+
|---|---|---|---|---|---|---|
|
|
78
|
+
| `dev` | pembangunan v1 / v1 development | 0.888 | 0.840 | 0.915 | 0.878 | 0.431 |
|
|
79
|
+
| `ujian` † | templat simpanan v1 / held-out v1 templates | **0.993** | – | 0.965 | 0.982 | 0.526 |
|
|
80
|
+
| `ujian2` † | templat Kimi K3 / Kimi K3 templates | **0.940** | – | 0.873 | 0.885 | 0.419 |
|
|
81
|
+
| `dev3` | pembangunan v2, templat Nemotron / v2 development | 0.615 | 0.998 | 0.791 | – | 0.290 |
|
|
82
|
+
| `ujian3` † | templat Claude Sonnet 5.5 / Claude Sonnet 5.5 templates | 0.587 | **0.980** | 0.871 | – | 0.325 |
|
|
83
|
+
|
|
84
|
+
† Split ujian: dikunci sha256 sebelum dinilai, dibuka sekali sahaja, hipotesis didaftar dahulu dalam
|
|
85
|
+
[`docs/PRA-DAFTAR.md`](docs/PRA-DAFTAR.md) / test split: locked by sha256 before scoring, opened once, hypotheses registered in
|
|
86
|
+
advance. `dev` dan `dev3` dipakai semasa pembangunan, jadi angka MyPII di situ optimistik / `dev` and `dev3` were used during
|
|
87
|
+
development, so MyPII's numbers there are optimistic. – = tidak dijalankan / not run.
|
|
88
|
+
|
|
89
|
+
**BM** · Cara membaca jadual ini:
|
|
90
|
+
- Hipotesis pra-daftar yang diuji semuanya disokong selepas pembetulan Holm: v1 mengatasi enam garis dasar atas `ujian2` (H1a hingga
|
|
91
|
+
H1f, utama) dan atas `ujian` (H2a hingga H2f, sekunder); v2 tidak kalah kepada Haiku (Δ +0.109) dan mengatasi v1 (Δ +0.393) atas
|
|
92
|
+
`ujian3` (H4a, H4b). Beza v1 dengan Sonnet atas `ujian` kecil (Δ +0.0115) walaupun signifikan. Hipotesis sekunder H3 (setiap
|
|
93
|
+
entiti) belum dilapor.
|
|
94
|
+
- v2 menambah normalisasi OCR dalam nombor, nombor yang dipecah baris, kod kawasan Sabah dan Sarawak berkurung, peraturan LLP dan
|
|
95
|
+
pengelas konteks. Atas teks gaya baharu (`dev3`, `ujian3`) ia jauh lebih baik. Atas teks gaya lama (`dev`) ia lebih rendah daripada
|
|
96
|
+
v1 (0.840 lawan 0.888), terutamanya `MY_SSM` (ketepatan 0.51). Tiada versi yang menang di setiap gaya teks, jadi nilai atas data anda
|
|
97
|
+
sendiri dahulu.
|
|
98
|
+
- v2 tidak dinilai atas `ujian` dan `ujian2` kerana kedua-dua split itu sudah dibuka untuk v1. Larian v2 di situ sekarang ialah
|
|
99
|
+
analisis selepas kejadian, bukan ujian.
|
|
100
|
+
- Selang keyakinan, ketepatan dan dapatan semula setiap entiti, setiap bahasa dan setiap kategori ada dalam
|
|
101
|
+
[`docs/BANDINGAN-V2.md`](docs/BANDINGAN-V2.md) dan [`docs/BANDINGAN.md`](docs/BANDINGAN.md). Keputusan `ujian` dan `ujian2` ada
|
|
102
|
+
dalam [`docs/LOG-ITERASI.md`](docs/LOG-ITERASI.md) dan arkib `hasil/arkib/`.
|
|
103
|
+
|
|
104
|
+
**EN** · How to read this table:
|
|
105
|
+
- Every pre-registered hypothesis tested so far is supported after Holm correction: v1 beats six baselines on `ujian2` (H1a to H1f,
|
|
106
|
+
primary) and on `ujian` (H2a to H2f, secondary); v2 is not worse than Haiku (Δ +0.109) and beats v1 (Δ +0.393) on `ujian3` (H4a,
|
|
107
|
+
H4b). The v1 margin over Sonnet on `ujian` is small (Δ +0.0115) although significant. The secondary per-entity hypothesis H3 is not
|
|
108
|
+
reported yet.
|
|
109
|
+
- v2 adds OCR normalisation inside numbers, line-broken numbers, bracketed Sabah and Sarawak area codes, the LLP rule and the context
|
|
110
|
+
classifier. On new-style text (`dev3`, `ujian3`) it is far better. On old-style text (`dev`) it is lower than v1 (0.840 versus
|
|
111
|
+
0.888), mostly `MY_SSM` (precision 0.51). No version wins on every text style, so evaluate on your own data first.
|
|
112
|
+
- v2 was not scored on `ujian` and `ujian2` because both splits were already opened for v1. A v2 run there now would be a post-hoc
|
|
113
|
+
analysis, not a test.
|
|
114
|
+
- Confidence intervals and per-entity, per-language and per-category precision and recall are in
|
|
115
|
+
[`docs/BANDINGAN-V2.md`](docs/BANDINGAN-V2.md) and [`docs/BANDINGAN.md`](docs/BANDINGAN.md). The `ujian` and `ujian2` results are in
|
|
116
|
+
[`docs/LOG-ITERASI.md`](docs/LOG-ITERASI.md) and the `hasil/arkib/` archive.
|
|
117
|
+
|
|
118
|
+
## Had kajian / Limitations
|
|
119
|
+
|
|
120
|
+
**BM**
|
|
121
|
+
- **Sintetik sepenuhnya.** Teks ditulis LLM dengan slot bertanda, kemudian diisi nilai rekaan, jadi label diketahui tanpa anotasi
|
|
122
|
+
manual. Pembina yang sama menulis penjana data dan pengecam. Keputusan atas teks sebenar belum diukur dan mungkin lebih rendah.
|
|
123
|
+
- **Keluarga Claude terlibat di tiga tempat.** Kod ditulis dengan ejen Claude, templat `ujian3` dijana Claude Sonnet, dan Claude Haiku
|
|
124
|
+
ialah pembanding H4a. Arah bias itu menentang MyPII bagi H4a.
|
|
125
|
+
- **Semakan label = satu manusia + satu LLM, bukan dua manusia.** Atas sampel 300 dokumen, penyemak manusia mendapati 0.000 span
|
|
126
|
+
salah dan 0.067 [0.027, 0.113] dokumen ada PII yang tidak bertanda. κ tidak bermakna kerana hampir tiada varians.
|
|
127
|
+
- **Dapatan semula telefon optimistik.** Label telefon dijana dalam julat sah libphonenumber, pustaka yang sama dipakai pengecam
|
|
128
|
+
([ADR-002](docs/adr/002-penanda-aras-sintetik.md)).
|
|
129
|
+
- **MyPII mengesan span, bukan menilai risiko.** Ia bukan alat anonimisasi lengkap dan bukan bukti pematuhan PDPA.
|
|
130
|
+
|
|
131
|
+
**EN**
|
|
132
|
+
- **Fully synthetic.** Text is written by LLMs with marked slots and filled with invented values, so labels are known without manual
|
|
133
|
+
annotation. The same builder wrote the data generator and the recognizer. Results on real text are not measured and may be lower.
|
|
134
|
+
- **The Claude family appears in three places.** The code was written with Claude agents, the `ujian3` templates were generated by
|
|
135
|
+
Claude Sonnet, and Claude Haiku is the H4a comparator. That bias runs against MyPII for H4a.
|
|
136
|
+
- **Label review = one human + one LLM, not two humans.** On a 300-document sample the human reviewer found 0.000 wrong spans and
|
|
137
|
+
0.067 [0.027, 0.113] of documents with unmarked PII. κ is not meaningful because there is almost no variance.
|
|
138
|
+
- **Phone recall is optimistic.** Phone labels are drawn from libphonenumber's valid ranges, the same library the recognizer uses
|
|
139
|
+
([ADR-002](docs/adr/002-penanda-aras-sintetik.md)).
|
|
140
|
+
- **MyPII finds spans; it does not assess risk.** It is not a complete anonymisation tool and not evidence of PDPA compliance.
|
|
141
|
+
|
|
142
|
+
## Penanda aras / Benchmark
|
|
143
|
+
|
|
144
|
+
**BM** · MyPII-Bench (`data/`, CC-BY-4.0) ada lima split 1000 dokumen setiap satu (`dev`, `ujian`, `ujian2`, `dev3`, `ujian3`)
|
|
145
|
+
serta split latihan. Kad set data: [`data/README.md`](data/README.md). Split ujian kini awam, jadi model yang dilatih selepas tarikh
|
|
146
|
+
keluaran mungkin pernah melihatnya; rentetan canary dalam kad set data membantu pembina model menapisnya.
|
|
147
|
+
**EN** · MyPII-Bench (`data/`, CC-BY-4.0) has five 1000-document splits (`dev`, `ujian`, `ujian2`, `dev3`, `ujian3`) plus training
|
|
148
|
+
splits. Dataset card: [`data/README.md`](data/README.md). The test splits are now public, so models trained after the release date may
|
|
149
|
+
have seen them; the canary string in the dataset card helps model builders filter them out.
|
|
150
|
+
|
|
151
|
+
## Jana semula / Reproduce
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
git clone https://github.com/sasateguh/mypii.git && cd mypii
|
|
155
|
+
uv sync --all-groups # alat penilaian: model spaCy, malaysia-pii-guard, SDK Anthropic, scikit-learn
|
|
156
|
+
make uji # ujian unit + kunci sha256 setiap split
|
|
157
|
+
make bandingan-v2 # docs/BANDINGAN-V2.md dari arkib ujian3, tanpa rangkaian
|
|
158
|
+
make bandingan # docs/BANDINGAN.md dari cache LLM yang dikomit, tanpa rangkaian
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**BM** · Jawapan LLM disimpan dalam cache yang dikomit, jadi skor garis dasar boleh dijana semula tanpa kunci API. Bukti meterai,
|
|
162
|
+
arkib larian ujian dan suntingan dokumen diterangkan dalam [`docs/PROVENANS.md`](docs/PROVENANS.md).
|
|
163
|
+
**EN** · LLM answers are stored in the committed cache, so baseline scores regenerate without API keys. Seal evidence, test-run
|
|
164
|
+
archives and document redactions are explained in [`docs/PROVENANS.md`](docs/PROVENANS.md).
|
|
165
|
+
|
|
166
|
+
## Dokumen / Documents
|
|
167
|
+
|
|
168
|
+
- [`docs/PRA-DAFTAR.md`](docs/PRA-DAFTAR.md): hipotesis, split, ujian statistik dan pindaan / hypotheses, splits, statistical tests and amendments.
|
|
169
|
+
- [`docs/BANDINGAN-V2.md`](docs/BANDINGAN-V2.md), [`docs/BANDINGAN.md`](docs/BANDINGAN.md): laporan bandingan / comparison reports.
|
|
170
|
+
- [`docs/LOG-ITERASI.md`](docs/LOG-ITERASI.md): log setiap langkah dan ukuran / log of every step and measurement.
|
|
171
|
+
- [`docs/ANALISIS-RALAT.md`](docs/ANALISIS-RALAT.md): analisis ralat v1 / v1 error analysis.
|
|
172
|
+
- [`docs/adr/`](docs/adr/): rekod keputusan / decision records.
|
|
173
|
+
- [`docs/IAA-SEMAKAN.md`](docs/IAA-SEMAKAN.md): cara semakan label manusia / how the human label review works.
|
|
174
|
+
- [`docs/PENDEDAHAN-AI.md`](docs/PENDEDAHAN-AI.md): apa yang dibuat ejen AI dan apa yang dibuat manusia / what AI agents did and what humans did.
|
|
175
|
+
- [`docs/PROVENANS.md`](docs/PROVENANS.md): meterai, arkib dan suntingan / seals, archives and redactions.
|
|
176
|
+
|
|
177
|
+
## Keputusan dev v1 (sejarah) / v1 dev results (history)
|
|
178
|
+
|
|
179
|
+
**BM** · Jadual ini dijana sebelum v2 wujud, jadi baris `mypii` ialah **MyPII v1**. Enam garis dasar ialah pengesahan (Holm k = 6);
|
|
180
|
+
Mistral Small 3.1 dan GLM-5.3-Flash ialah eksplorasi (ADR-017), bukan dakwaan.
|
|
181
|
+
**EN** · This table was generated before v2 existed, so the `mypii` row is **MyPII v1**. Six baselines are confirmatory (Holm k = 6);
|
|
182
|
+
Mistral Small 3.1 and GLM-5.3-Flash are exploratory (ADR-017), not claims.
|
|
183
|
+
|
|
184
|
+
<!-- jadual-dev:mula -->
|
|
185
|
+
<!-- dijana `make readme` (scripts/jana_readme.py) dari hasil/dev-*.json; jangan sunting dengan tangan -->
|
|
186
|
+
|
|
187
|
+
Split `dev`, 1000 dokumen / documents, padanan tepat / exact match, `semua|*`. Selang = bootstrap 95% (1000 ulangan / resamples, unit `dokumen`). Δ = F1 MyPII tolak F1 sistem / MyPII minus system (negatif = sistem lebih baik / negative = system is better). P/R: `docs/BANDINGAN.md`.
|
|
188
|
+
|
|
189
|
+
| Sistem / System | F1 | Selang F1 / F1 interval | Δ F1 [selang / interval] |
|
|
190
|
+
|---|---|---|---|
|
|
191
|
+
| `mypii` | **0.8877** | [0.8701, 0.9037] | rujukan / reference |
|
|
192
|
+
| `anthropic/claude-haiku-5-5` | **0.9149** | [0.8979, 0.9312] | -0.0272 [-0.0465, -0.0094] |
|
|
193
|
+
| `anthropic/claude-sonnet-5-5` | **0.8782** | [0.8578, 0.8966] | +0.0095 [-0.0086, 0.0268] |
|
|
194
|
+
| `cf/@cf/meta/llama-3.3-70b-instruct-fp8-fast` | **0.7060** | [0.6777, 0.7335] | +0.1817 [0.1591, 0.2028] |
|
|
195
|
+
| `cf/@cf/mistralai/mistral-small-3.1-24b-instruct` (eksplorasi / exploratory) | **0.8513** | [0.8290, 0.8710] | +0.0364 [0.0165, 0.0583] |
|
|
196
|
+
| `rv/deepseek-ai/DeepSeek-V4.1-Flash` | **0.7193** | [0.6899, 0.7483] | +0.1684 [0.1467, 0.1897] |
|
|
197
|
+
| `rv/zai-org/GLM-5.3-Flash` (eksplorasi / exploratory) | **0.8889** | [0.8699, 0.9059] | -0.0012 [-0.0197, 0.0169] |
|
|
198
|
+
| `pii-guard` | **0.7209** | [0.6977, 0.7434] | +0.1668 [0.1415, 0.1908] |
|
|
199
|
+
| `presidio-asal` | **0.4309** | [0.4078, 0.4554] | +0.4568 [0.4299, 0.4813] |
|
|
200
|
+
<!-- jadual-dev:tamat -->
|
|
201
|
+
|
|
202
|
+
## Petik / Cite
|
|
203
|
+
|
|
204
|
+
**BM** · Metadata petikan ada dalam [`CITATION.cff`](CITATION.cff) (GitHub memaparkannya sebagai "Cite this repository"). DOI Zenodo
|
|
205
|
+
ditambah di sini selepas keluaran pertama.
|
|
206
|
+
**EN** · Citation metadata lives in [`CITATION.cff`](CITATION.cff) (GitHub shows it as "Cite this repository"). The Zenodo DOI is
|
|
207
|
+
added here after the first release.
|
|
208
|
+
|
|
209
|
+
## Lesen / License
|
|
210
|
+
|
|
211
|
+
Kod / code: MIT ([`LICENSE`](LICENSE)). Set data / dataset (`data/`): CC-BY-4.0. © 2026 Aiman Malib (Sasa Teguh).
|