en flag +1 214 306 68 37

Inside ScienceSoft’s Multilingual PII Detection Model for On-Device AI Security

6 min read

Last updated:

Editor’s note: Vadim Belski presents ScienceSoft’s R&D work on a multilingual AI model meant to detect personally identifiable information (PII). ScienceSoft, an AI transformation and software engineering company, undertook this research as part of its work on the On-Device AI Firewall, a product designed to detect sensitive information and prevent corporate data leaks when employees use AI assistants. Vadim explains why the team chose to fine-tune an existing language model, how they trained and evaluated it, and what the results show.

When we started working on the ScienceSoft On-Device AI Firewall, our major goal was to detect sensitive information before employees sent it to external AI services. That meant that the firewall needed to analyze prompts and files locally, on an employee’s device, and apply company-defined policies to decide what information can be shared.

To make this possible, we had to overcome three major challenges:

  • Some sensitive data has an unpredictable structure. Email addresses, phone numbers, IBANs, and similar identifiers can be detected with deterministic rules, but names, organizations, locations, addresses, and dates are much less strict. Their form changes with language and context, so we needed a named entity recognition (NER) model for them.
  • Multilingual support was another challenge. Since ScienceSoft works with organizations in both the United States and the GCC, we needed one model that could handle English and Arabic, including Arabizi (Arabic written using Latin characters and numerals). We also wanted to cover other widely used languages in the Americas and EMEA, which meant working across three common writing systems: Latin, Cyrillic, and Arabic.
  • The model had to run efficiently on a CPU, without requiring graphics acceleration or an internet connection.

We couldn't find a ready-to-use named entity recognition (NER) model that met all these requirements, so we decided to adapt an existing multilingual model for our task. In this article, I'll explain how we approached its development, trained and evaluated it, and what we're working to improve next.

Choosing the Base Model and Defining Its Job

We chose XLM-RoBERTa as our starting point. It had already been trained on text in 100 languages, giving us a foundation for the languages and writing systems we needed. This model was also compact enough to optimize for CPU inference on employee devices.

Next, we defined what the model should detect. We focused on five categories where linguistic variability and context made fixed detection patterns unreliable: people (PERSON), organizations (ORGANIZATION), locations (LOCATION), addresses (ADDRESS), and dates and times (DATE_TIME).

We fine-tuned XLM-RoBERTa to recognize these entities. For each detection, the model identifies the relevant text, its category, and a confidence score. The firewall then uses its configured policies to decide what to do with the results — whether to mask the information, block the request, or allow it to proceed.

Multilingual NER Is More Than Adding More Languages

Working across different writing systems required us to reconsider some rules for processing text. For example, we initially used capitalization as a clue for recognizing people's names. This can be useful in English, but Arabic has no uppercase letters. During testing, we discovered that this rule caused us to miss 694 correct detections in Arabic text. We addressed the problem by refining our training data and further fine-tuning the model.

We also had to account for differences in how languages represent numbers and handle text direction. These considerations influenced how we prepared training data and evaluated the model.

The examples below show the model analyzing text in English, Arabic, and Arabizi. It highlights the information it recognizes and identifies its type, such as a person's name, an organization, a location, or a date, with a confidence score for each.

Model analyzing text in English

Model analyzing text in Arabic

Model analyzing text in Arabizi

Building the Training Data

We fine-tuned the model on approximately 155,000 synthetic examples and reserved another 5,300 for testing. To make the examples realistic, we used sources such as Faker, libpostal, GeoNames, and public name lists for names, organizations, locations, and addresses. We then combined these elements into fictional scenarios. Individual names and places could be real, but the resulting examples did not reproduce actual relationships between particular people, their employers, and their locations. This approach helped us create diverse training data without relying on real personal records.

We also wanted the model to recognize sensitive information in the different types of content employees might share with AI assistants. Alongside ordinary sentences, we included emails, tables, configuration files, logs, and structured data such as JSON and CSV.

Another important part of the training data was negative examples — text that might resemble personal information but isn't. For instance, the model once incorrectly identified “web” as a person's name in a configuration field reading “name: web.” We added more examples like that to the training data to help the model distinguish actual names from ordinary configuration values.

Evaluating the Model

We started by testing the model on synthetic data, where we knew exactly which entities it was supposed to recognize. However, since these test examples were generated using the same approach as our training data, good results could give us an overly optimistic picture of the model's accuracy. To check how well it handled unfamiliar text, we used external datasets created independently of our training pipeline. We also evaluated the model using the Rust-based inference engine used by the firewall's endpoint agent, rather than relying only on our research environment.

We established a set of criteria for evaluating model versions, including detection accuracy, processing speed, the impact of reducing the model's size, and whether previously identified errors reappeared. One specific metric, which we call touch rate, measures how often the model identifies data that belongs to the firewall's separate rule-based detection layer. This layer handles identifiers with recognizable formats, such as email addresses, phone numbers, and payment card numbers. We check the touch rate to see whether the model starts misclassifying these identifiers as the entity types it was trained to recognize.

We also repeated experiments when improvements were small, since training the same model multiple times can produce slightly different results. In one experiment, adding more organization names improved recognition of unfamiliar companies but made the model less accurate at identifying name boundaries. Testing on several datasets helped us identify this problem before accepting the change as an improvement. We subsequently revised the training data to include more examples where words such as the or company precede an organization name without being part of it. After retraining, the updated model passed our checks for these previously identified errors.

Comparing Our Model With Other PII Detectors

We also wanted to compare our model with existing alternatives under consistent testing conditions. For this, we created PII Bench, a publicly available set of tests and evaluation tools for PII detection.

PII Bench contains 3,500 text samples from seven third-party datasets. As with our training data, we accounted for the variety of formats found in AI traffic. Alongside ordinary text, the tests include JSON, XML, SQL, CSV, logs, tables, and text with errors typical of optical character recognition (OCR).

To compare models that recognize different categories of personal information, PII Bench measures how accurately they identify sensitive portions of text, regardless of the labels they assign. We evaluate three indicators: precision (how many of the model's detections are correct), recall (how much of the sensitive information it successfully finds), and F1 — a score that balances the two.

In the published leaderboard, our PII encoder (v23) achieved an F1 of 0.777, compared with 0.753 for NVIDIA's GLiNER-PII, the highest-scoring independent model in this comparison. Our model achieved higher recall (0.878 versus 0.783), while NVIDIA's showed higher precision (0.744 versus 0.710). We deliberately prioritize recall because, for a data protection tool, we consider a false positive (mistakenly flagging harmless information) less harmful than a false negative that allows sensitive data to go undetected and potentially reach an external AI service.

We have published the test data, evaluation methodology, and individual model results on Hugging Face so that others can inspect the comparison and reproduce the tests.

Optimizing the Model for On-Device Inference

Since we were developing the model for on-device AI security, it had to run efficiently on a regular CPU, without requiring a dedicated graphics card. To achieve this, we exported the fine-tuned model to ONNX, a format designed for efficient model execution, and applied int8 quantization to reduce its size and computational requirements. The resulting model is approximately 278 MB.

Processing speed was another important requirement. In our CPU performance checks for v23, the current version at the time of writing this article (fall 2026), the model processed a 512-token input in 192.6 milliseconds or less in 95% of runs, meeting our target of 200 milliseconds. This measurement covers the model's processing time, not the entire firewall workflow.

In a separate CPU benchmark on an Apple M4 Max, an earlier version of our model (v15) achieved a median processing time of 20.3 milliseconds per test sample, compared with 140.6 milliseconds for NVIDIA's GLiNER-PII. Our v23 model uses the same architecture and int8 ONNX optimization, although we haven't repeated this particular speed test for it.

We also designed the model to handle longer documents by splitting them into smaller sections and processing several sections in parallel across available CPU cores. This reduces the time needed compared with analyzing each section sequentially. The model also performs detection locally without requiring an internet connection after installation.

What We’re Working on Next

Our PII model currently supports seven languages: English, German, French, Italian, Spanish, Russian, and Arabic, including several regional varieties of Arabic and Arabizi. However, the depth of our evaluation varies across languages. Arabic remains one of the more challenging areas, particularly for location detection. Our Arabizi training examples are synthetically generated rather than collected from real-world texts, and we still lack independent real-text benchmarks for French and Italian.

We continue improving the model's detection accuracy and expanding our evaluation datasets. We're also refining a smaller version of the PII encoder, approximately 100 MB in size, intended for mobile devices and older hardware. Another ongoing project is a multilingual OCR model designed to recognize text in several languages locally, without requiring separate models for each language.

Explore On-Device PII Protection for Your Business

Want to know how sensitive-data detection can help your organization use AI more securely? ScienceSoft's experts can explain how PII detection works within our On-Device AI Firewall and discuss your specific AI security requirements.