Own Weights

PII removal from documents with a private model

Remove personal data from documents before they are shared, with a model that runs inside your own network. What GDPR and the Saudi PDPL say, and how to test it.

Updated

PII removal from documents means finding the personal data in a file, such as names, ID numbers, addresses, phone numbers and bank details, and removing or replacing it before the file is shared, archived or reused. A private model can do the finding. It is trained on your own documents for this one job and runs in your cloud account, on your servers or hosted privately by us, so the unredacted text never has to go to an outside service. You own the trained weights.

This page is about redaction as the job itself: preparing copies of documents for a third party, a data request, an analytics team or a test set. If you want to mask prompts before they go to a hosted AI model, read PII redaction before an LLM instead.

This page is general information, not legal advice. Check with counsel what applies to your documents and your jurisdiction.

What counts as personal data?

Both laws below define personal data broadly. A document can carry it in places a quick read misses.

  • GDPR (EU). Article 4(1) defines personal data as “any information relating to an identified or identifiable natural person”. It lists identifiers such as “a name, an identification number, location data, an online identifier”, along with factors specific to a person’s identity, among them physical, genetic, mental, economic and cultural ones.
  • Saudi Personal Data Protection Law (PDPL). Article 1 defines personal data as any data “that may lead to identifying an individual specifically”, or that may make it possible to identify one directly or indirectly. Its list includes “name, personal identification number, addresses, contact numbers, license numbers, records, personal assets, bank and credit card numbers, photos and videos of an individual”.

Both laws also set out stricter categories. GDPR Article 9 covers data revealing racial or ethnic origin, political opinions, religious beliefs, trade union membership, genetic and biometric data, health data, and data on a person’s sex life or sexual orientation. The PDPL’s “Sensitive Data” in Article 1 covers racial or ethnic origin, religious, intellectual or political belief, criminal convictions, biometric or genetic data, health data, and data indicating that one or both of a person’s parents are unknown.

In practice that means a redaction pass has to look past the obvious fields. A diagnosis in a claim note, a nationality in an HR letter or a photo in an ID scan all count.

Removal, pseudonymisation and anonymisation are not the same

Teams use “redaction” for three different outputs. The law treats them differently, so decide which one you need before you build anything.

Output What happens to the personal data Legal status under the GDPR
Removal Deleted or blacked out, with nothing kept to restore it Depends on what is left; other details in the text may still identify the person
Pseudonymisation Replaced with a consistent placeholder, such as PERSON_1, and the key is kept separately Still personal data, per Recital 26
Anonymisation Removed or changed so the person can no longer be identified by any means reasonably likely to be used Outside the GDPR, per Recital 26

The GDPR’s Article 4(5) defines pseudonymisation as processing so the data “can no longer be attributed to a specific data subject without the use of additional information”, provided that information “is kept separately”. Recital 26 then says pseudonymised data that “could be attributed to a natural person by the use of additional information should be considered to be information on an identifiable natural person”. The Regulation does not apply to anonymous information, but the bar is high: Recital 26 asks you to account for “all the means reasonably likely to be used”, including cost, time and available technology.

Pseudonymisation still has value. GDPR Article 25(1) names it as an example of a measure for data protection by design, and Article 32(1) lists “the pseudonymisation and encryption of personal data” among security measures. Article 5(1)(c) asks that personal data be “limited to what is necessary”, which is the principle a redacted copy puts into practice. A model that replaces every name with the same placeholder throughout a file gives you pseudonymised text that is still readable, because a reader can follow who did what.

Why run the redaction step in-house?

The redaction model reads every document in full before anything is removed. Wherever it runs is where your unredacted data goes.

If that step is a hosted service, the provider processes the raw files for you. Under GDPR Article 28(1), a controller “shall use only processors providing sufficient guarantees” of appropriate measures. The PDPL’s Article 8 similarly says a controller “shall only select Processors providing the necessary guarantees” and shall monitor their compliance. If the service runs abroad, transfer rules apply as well: GDPR Article 44 allows transfers to a third country only under the conditions of its Chapter V, and PDPL Article 29 sets conditions for transfers outside the Kingdom, including an adequate level of protection and limiting the transfer to “the minimum amount of Personal Data needed”.

A model in your own cloud account or on your own servers keeps the raw documents where they already are. That gives your legal team a shorter list of parties and places to check. It does not remove your own obligations, and logs, backups and monitoring tools still need the same review. Our data residency guide covers those.

Rules, a trained model, or both?

Use both. They fail in different places.

Kind of personal data Rules and patterns Trained model
Email addresses, phone numbers, IBANs, card numbers Strong, if the format is known Useful as a second check
National ID and passport numbers Strong for known formats; checksums help Catches IDs split across lines or with OCR errors
Names of people Weak; lists go stale The main reason to train a model
Addresses in free text Weak Good when trained on your own document types
Details that identify by context, such as a job title in a small team Cannot see them Partly; a person still reviews
Company names that are not personal data Often over-redacted Can learn your house rules from examples

The model part is a named-entity job: read the text and mark each span that is a person, an ID, an address and so on. Our guide to named entity extraction covers how that is trained and scored. Training on your own files matters here because the hard cases are local: your form layouts, your ID formats, the way your staff write notes.

What usually goes wrong

Most failures come from the file, not the text.

  • Black boxes over live text. Drawing a rectangle over a PDF does not delete the text underneath. Rebuild the output file from the redacted text, or flatten it to an image and check it.
  • Hidden layers. Document metadata, tracked changes, comments, headers, footers and embedded attachments carry names too.
  • Scans and photos. Text that only exists as an image needs OCR first, and OCR errors break pattern rules. Score scanned documents as a separate group.
  • Tables and forms. A name in a table cell, with the label in another cell, is easy for a pattern rule to miss.
  • Signatures and stamps. Names in signature blocks and handwritten initials are common misses.
  • Over-redaction. Removing every capitalised word makes the copy useless. Track it as an error too.

How to measure a redaction model

Missed personal data is a leak. Wrongly removed text is a usability problem. Score them separately.

  1. Recall per type. Of all the names, IDs and addresses a person marked, how many did the model catch? Report it per type, because 99% on emails can hide 85% on names.
  2. Precision. Of everything the model removed, how much was really personal data?
  3. Leak rate per document. The share of documents with at least one miss. This is the number that matters if one leak is one too many.

A worked example, with hypothetical numbers: a team tests 500 HR letters with 6,000 marked names. The model catches 5,940, so name recall is 99%. But the 60 misses are spread over 45 letters, so 9% of documents would leave with at least one name in them. If the rule is “a person reviews every document with a low-confidence span”, the test shows whether that review catches the 45. These numbers are invented to show the arithmetic, not a measured result.

The precision, recall and F1 guide explains the scoring in more depth.

How a pilot works

  1. Free AI cost audit. We map the document flow, where the files go today, and which redaction job is worth testing. Book the free AI cost audit.
  2. Collect a marked sample. A few hundred of your own documents, with every piece of personal data marked by your team. Include scans, forms and the messy cases above.
  3. Split by document source. Test documents come from different files, and ideally different people, than the training documents, so the score measures skill, not memory. See how to build a test set.
  4. Score your current process. Manual redaction, a rules tool or a hosted service gets scored on the same held-out set. That is the bar.
  5. Train and score ours. Recall per type, precision and leak rate per document, side by side.
  6. Ship only if it wins. If ours does not beat what you use today, nothing ships.
  7. Keep a person on the output. Review flagged spans and a fixed sample of unflagged documents every month.

The training data is itself personal data, so it needs the same care. Our guide to fine-tuning on sensitive data covers what stays in the weights and why the model should run where the data already lives.

We do not have a published redaction result yet, and we will not quote one. Our published results are on other narrow tasks: on the Banking77 banking-intent test (1,000 messages, 77 intents), our trained model scored 93.3% accuracy against 87.6% for Claude Opus 5.5. Details are on the benchmark page. If your documents are in more than one language, put every language in the sample and score each one separately. The score on your own files is what tells you whether it works.

Questions

What is PII removal from documents?

It means finding the personal data in a document, such as names, ID numbers, addresses, phone numbers and account numbers, and removing or replacing it before the document is shared, archived or reused. The output is a copy that someone without a need to see the personal data can still work with.

Is a redacted document still personal data under GDPR?

It can be. Recital 26 of the GDPR says data that has been pseudonymised but could be linked back to a person with extra information should still be treated as information on an identifiable person. Only data rendered anonymous, so the person is no longer identifiable, falls outside the Regulation. Ask counsel which side of that line your output sits on.

Why run the redaction model inside our own network?

Because the redaction step sees every document before anything is removed. If that step is a hosted service, the full unredacted text has already left your network. A model running in your cloud account or on your servers keeps that step in-house.

Can a model find every piece of personal data?

No model or rule set finds everything. Measure what it misses on a sample of your own documents, count misses by type, and keep a person reviewing a sample of the output before it goes out.

Is this legal advice?

No. This page summarises what the GDPR and the Saudi Personal Data Protection Law say, as information. What applies to your documents depends on your own facts, so check with counsel before you rely on any redaction process.