AI model · Japanese only · v0.2.0
Check the text
before it reaches an AI.
Safe Privacy Detect is a small AI model that checks whether Japanese text contains personal or sensitive information, such as a name or a medical history.
For each of six categories it returns “detected”, “not detected” or “abstain”. It runs on a CPU without a GPU, and it does not generate text.
- Runs on a CPU
- No GPU needed
- No network at run time
- MIT licence
safe-privacy-detect-ja-70m Hugging Face and Kaggle host the model.
Text (Japanese)
口座名義は大森健太郎です。先月から整形外科に通院しています。
Read once, judged for six categories
- NameDetected
- Health, medical history, disabilityDetected
- Criminal record, criminal proceedingsNot detected
- Registered domicileNot detected
- Trade union membershipNot detected
- Religious or political beliefsNot detected
- 6 categories × 3 verdicts
- It returns a verdict and a probability for each category.
- 18.5 ms
- Time to judge one 200-character text (median), measured on a development PC with 4 CPUs.
- CPU 4
- The environment it is designed for: 4 CPUs, no GPU.
- About 70 million
- Parameters. A small classification model that does not generate text.
Place it just before text reaches an AI
When a company uses AI, it does not want personal information, or anything more sensitive, going into the AI. Checking the content after the text has been handed to the AI is too late: by then the text has already gone.
-
1
Text arrives
Japanese text, such as a single chat message or an enquiry.
-
2
Safe Privacy Detect judges it
It returns a verdict and a probability for each of the six categories.
-
3
The caller decides
Pass it to the AI as it is, or ask a person to check it. The model does not decide.
Check before text goes to an AI
Place it in front of an in-house system that uses AI, and check whether the text contains any of the categories.
Prompt a review before sending
When a chat message or an enquiry contains one of the categories, it can be built into a system that asks the writer to review the content before sending.
Support work where people check text
In work where a person checks how received text should be handled, it can serve as a pointer for that check.
Try the verdicts
Choose an example to see the verdicts the model returned for it. The examples are the check sentences shipped with the model; names and places are fictional. They are in Japanese, the only language the model reads, and an English reference translation is shown under each one.
Text (Japanese)
〔応対記録〕大森健太郎様より入電。糖尿病で通院中、前科なしとの申告。
Reference translation (not given to the model): [Call log] Call received from Kentaro Omori. Reports seeing a doctor for diabetes, and no criminal record.
Why these verdicts
Both the surname and the given name are written, and so is the person’s own clinic visit. The negation “no criminal record” still describes that person’s criminal history, so it is detected.
- Name0.9843Detected
- Health, medical history, disability0.9987Detected
- Criminal record, criminal proceedings0.9967Detected
- Registered domicile0.9989Not detected
- Trade union membership0.9992Not detected
- Religious or political beliefs0.9981Not detected
What you see are results saved after running the examples through the model. The model is not running on this page, and you cannot enter your own text. The numbers are the probabilities the model returned for each verdict.
The six categories, and the three verdicts it returns
It judges whether the content of a category is explicitly stated about a person in the text. It does not infer what is not written.
Name
Both the surname and the given name
Health, medical history, disability
Includes results such as health check-ups, and medical treatment and dispensing.
Criminal record, criminal proceedings
Criminal history, criminal proceedings, and juvenile protection proceedings
Registered domicile (honseki)
Down to the city, ward, town or village
Trade union membership
Being a member of a trade union
Religious or political beliefs
Beliefs. Limited to explicit statements of religious or political views.
- Detected
- The content of the category is explicitly stated about a person in the text.
- Not detected
- Not explicitly stated. This includes general statements, product descriptions, figures of speech, statements about organisations, and anything that could only be inferred.
- Abstain
- There is related wording, but the text alone cannot settle whether it is explicit (hearsay or guesswork, masked text, cut-off text, an unclear subject, or indirect wording).
The scope of these verdicts does not match legal definitions. It makes no legal judgement on whether something counts as personal information, or as special care-required personal information, under the law.
Speed and evaluation
Speed was measured; the evaluation uses 1,800 synthetic sentences. Targets that were missed are shown as they are.
Time to judge one text
Development PC
18.5 ms
200 characters, median (95th percentile 24.8 ms). For 800 characters, median 63.5 ms (95th percentile 78.7 ms).
AMD Ryzen 7 5700X, WSL, limited to 4 CPUs
AWS
26.1 ms
200 characters, median (95th percentile 29.2 ms). For 800 characters, median 103.5 ms (95th percentile 107.7 ms), which is over 100 ms.
c7i.xlarge, 4 vCPUs, Tokyo region
Results for v0.2.0, 32-bit ONNX, one text at a time. Network time is not included. Speed depends on the type and number of CPUs, and these figures do not promise the speed you will get.
Miss rate
Of the sentences in which a category is explicitly stated, the share judged “not detected”. 35 of the 36 items meet their targets; the miss rate for trade union membership, 5.0% (8 of 159, 5.03%), does not reach the target of 5% or less.
Sentences in the evaluation were 6 to 110 characters long. Accuracy on longer sentences and on real business text has not been checked. The targets are proposals set by the developer. Confusable sentences produce false positives: 10.0% for health, medical history, disability. False-positive and abstain rates by category, and speed by text length, are on the specification and evaluation page.
How to get it and run it
The model is published on Hugging Face and Kaggle under the MIT licence, with no warranty.
-
1
Get the files
18 files, about 544 MB, in two formats: safetensors and ONNX .
-
2
Install the software and pass it text
Run these in the folder of the files. The bundled script returns the verdicts.
# Install the software pip install -r requirements.txt # Pass a sentence (Japanese for “I have been going to an orthopaedic clinic since last month.”) echo "先月から整形外科に通院しています。" | python predict.py --pretty
-
3
Call it from your own system
From Python, write it like this.
from predict import Detector detector = Detector(".") # The folder of the files. Create one and reuse it result = detector.predict("先月から整形外科に通院しています。") # {"name": {"status": "NOT_DETECTED", "probabilities": {...}}, # "health": {"status": "DETECTED", ...}, ...}
The bundled script does not write the text it receives to its output or to any log.
| Environment | 4 CPUs, no GPU. No network at run time |
|---|---|
| Software | Python, onnxruntime 1.19 or later, transformers 4.48.0 or later, sentencepiece, protobuf, numpy |
| Input | Japanese text. Mainly a single chat message (up to 200 characters); up to 800 characters are accepted. Texts longer than 200 characters are best split and sent in parts. |
The bundled Dockerfile, the breakdown of the download size, the base model and the other statuses the script returns are on the specification and evaluation page.
Limits, and what it does not do
It misses things and gives false positives. “Not detected” does not guarantee that nothing sensitive is there. Do not design a system that relies on this model alone to stop leaks.
What it does
- Reads Japanese text once and returns a verdict and a probability for each of six categories
- Returns “abstain” when the text alone cannot settle it
- Runs on a CPU without a GPU
What it does not do
- Extract the matching part, or mask it automatically
- Decide whether the text may be sent
- Judge addresses, phone numbers, email addresses, account numbers, My Number (Japan’s individual number) and similar
- Infer attributes (nationality from a name, an illness from a clinic, and so on)
- Judge text in languages other than Japanese
Not yet checked
Training and evaluation used synthetic sentences modelled on exchanges at Japanese financial institutions. Accuracy on real business text, and on sentences over 110 characters, has not been checked.
A request from the author
Please do not use it to search out and collect sensitive information, to screen people or treat them unfavourably in hiring, credit or personnel evaluation, or to monitor employees or customers. This is a request, not a licence condition.
For masking email addresses, phone numbers and similar inside an input field, there is the Chrome extension Safe Privacy Mask .
Check the specification, or ask us
Definitions of the categories, speed by text length and every evaluation metric are on the specification and evaluation page. We also welcome questions about whether it fits your work, and joint evaluation.
Why I built this model is written up in a note.