Nº04 · WebGPUIn-browser privacy model · 2026浏览器内隐私模型 · 2026
PII Detector
Finds cards, emails, phones and API keys before text reaches a model.在文本进入模型之前,找出卡号、邮箱、电话和 API 密钥。

0 network requests
01Problem问题
Employees paste customer data into AI tools. Masking has to happen before the text leaves the device, and it has to work for Chinese text as well as English.员工会把客户数据贴进 AI 工具。脱敏必须在文本离开设备之前完成,而且中文和英文都要能用。
02Flow流程
- Text文本
- Rules + Luhn规则 + Luhn
- Local model本地模型
- Leaves device?离开设备?
- Masked placeholders → LLM占位符 → LLM
03What I built我做了什么
- Rules first: card numbers must pass Luhn, so an order number is never called a card. Repeated values keep the same placeholder.规则优先:卡号必须通过 Luhn 校验,订单号不会被当成卡号;重复的值保持同一个占位符。
- An optional local model adds names, addresses and dates, running on WebGPU after a one-time download; the page counts network requests during detection.可选的本地模型补充姓名、地址和日期,一次下载后在 WebGPU 上运行;页面统计检测期间的网络请求数。
- Found that Presidio's
\bpatterns never match an ID written straight after Chinese text, and replaced them with boundary-safe patterns plus check digits.发现 Presidio 的\b模式匹配不到紧跟中文的证件号,改为边界安全的模式并加校验位。
04Watch it run看它运行
05Measured测量结果
0 → 100%
Chinese national-ID recall after boundary-safe rules (cards 23% → 91%)边界安全规则后的中文身份证召回率(卡号 23% → 91%)
src · bilingual-pii-detector/README.md
136 ms
p95 per record, rules + model, local NVIDIA GB10 (rules alone 0.5 ms)每条记录 p95,规则 + 模型,本地 NVIDIA GB10(仅规则 0.5 ms)
src · governance-platform/evals/results
30
detector service tests (pytest)检测服务测试(pytest)
src · governance-platform/apps/detector/tests
06Limits, stated plainly局限,直说
- Chinese person names reach 39% recall and addresses 67%; no openly licensed Chinese NER model had training data I could verify.中文人名召回 39%、地址 67%;没有找到训练数据可核实的开源中文 NER 模型。
- The corpus is synthetic, so the numbers compare configurations, not production accuracy. The model download is about 840 MB and needs Chrome or Edge.语料是合成的,数字用于比较配置而非生产准确率。模型约 840 MB,需要 Chrome 或 Edge。