RepositoryPythonKRSouth Korea
newmean-ai

newmean-ai/pii

Mask PII before it reaches OpenAI, Anthropic or any LLM: small multilingual models (54 languages, 2.6 to 15.5 MB) that run in the browser, on iOS and Android, or on a server. JavaScript, Python, Swift, Kotlin, Flutter, Rust.

204stars
20forks
1issues
2views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: data-masking

#1 Repository of the day

1
TINIX TRENDING·Topic: webassembly

#1 Repository of the day

1
TINIX TRENDING·Topic: multilingual

#1 Repository of the day

English | 한국어 | 繁體中文

@newmean-ai/pii

Browser-side PII redaction. Detect and mask personal information (names, emails, phone numbers, addresses, IDs, …) in text entirely in the browser, so the original text never leaves the user's device.

  • 54 languages, 11 labels plus 2 level-2 labels for indirect identifiers (IP addresses are learned as ID_NUMBER); an optional pattern layer (e-mail, URL, card/account, phone, Korean resident number) is off by default
  • Four model sizes: nano 2.6 MB, small 7.1 MB, medium 11.3 MB (default), large 15.5 MB
  • Runs in WebAssembly: the SDK's own built-in engine (default, about 13 KB) or onnxruntime-web
  • Free for any use, including commercial use
  • The same models for Python, iOS, Android and Flutter (Install)
npm install @newmean-ai/pii
import { createRedactor } from "@newmean-ai/pii";

const redactor = await createRedactor({ size: "medium" });
const { text, spans } = await redactor.redact("My email is kim@example.com");
// text: "My email is [EMAIL]"

See js/README.md for the full API.

Install

PlatformPackageInstall
Browser, Node.js@newmean-ai/piinpm install @newmean-ai/pii
Python 3.9+newmean-piipip install newmean-pii
iOS 15+, macOS 12+NewmeanPII (Swift Package Manager)add https://github.com/newmean-ai/pii, from 1.6.1
Android 7.0+ai.newmean:piiimplementation("ai.newmean:pii:1.6.1")
Flutter, Dartnewmean_piiflutter pub add newmean_pii
Rustnewmean-piicargo add newmean-pii

The Python, iOS, Android and Flutter packages run the same models on the device through one C engine (native/core), whose token ids, offsets and logits equal the npm package's. Model files are downloaded once from Hugging Face and checked against pinned SHA-256 values, or bundled with the app.

from newmean_pii import create_redactor

create_redactor(size="medium").redact("My email is kim@example.com").text  # 'My email is [EMAIL]'
import NewmeanPII

let (text, _) = try await PIIRedactor(size: .medium).redact("My email is kim@example.com")
import ai.newmean.pii.PiiRedactor

val (text, spans) = PiiRedactor.create(context).redact("My email is kim@example.com")  // create: suspend, model from the app's assets
import 'package:newmean_pii/newmean_pii.dart';

final r = await (await NewmeanPii.create(size: 'medium')).redact('My email is kim@example.com');

Guides: Python · Swift · Android · Flutter · Rust

Tables (CSV, TSV)

const { text } = await redactor.redactTable(csv);  // delimiter detected: ",", "\t", ";" or a markdown pipe table
const spans = await redactor.detectTable(tsv, { delimiter: "\t", header: true, vote: true });
const named = await redactor.redactTable(csv, { context: "header" });  // also read each cell after its column title
create_redactor().redact_table(open("survey.csv", encoding="utf-8").read(), context="header").text

Table mode reads the whole table as one text, so cells give each other context, and clips every span to a cell value: delimiters, quotes and line breaks are never masked, so the output is still a valid table. A column of short values that the model reads as names, emails, phone numbers or usernames in at least 80% of its cells is masked whole (source "table"); the header row and free-text columns never take part in that vote. With context: "header", each cell of a column of mostly distinct values is also read on its own after its column title (": <value>"), which finds names split into first and last name columns: on 556 survey and form exports in 54 languages, large then misses 1.4% of PII characters instead of 6.2% and masks 12.3% of PII-free cells instead of 9.6% (all sizes under Results). It costs one more model call per such cell (about twice the time of table mode). Every package has table mode (Swift, Kotlin and Dart: detectTable, redactTable; C: pii_detect_table).

Results

Share of PII characters left unmasked (miss %, lower is better), model only, on newmean-pii-dataset (public test) and four external datasets none of our models was trained on. Full table with over-masking, parameters and speed: technical report, Section 6; weekly scores on newmean-pii-dataset (public and private test): leaderboard.

modeldownloadpublic test (54 lang.)KDPII (ko)OpenPII (30 lang.)Nemotron-PII (en)Gretel finance
newmean-pii-large15.5 MB1.69.64.96.121.4
newmean-pii-medium11.3 MB1.911.56.37.721.5
newmean-pii-small7.1 MB2.410.05.68.422.3
newmean-pii-nano2.6 MB2.99.55.09.921.4
gliner-pii-edge176 MB19.611.95.717.315.7
OpenAI privacy-filter2.8 GB34.634.814.325.732.2
Horizon pii-redactor-small563 MB41.025.711.17.831.6
KoELECTRA Korean PII NER—43.18.824.1*45.937.6
GLiNER2-PII1.2 GB44.934.223.246.332.9
Rampart15 MB56.536.13.5*51.640.5
Mozilla smart-pii-redactor15 MB56.946.025.948.832.9
Rampart-edge1.5 MB74.789.046.155.548.0
regex baseline—75.362.061.144.686.7

How to read it: our models were trained on data of the same design as newmean-pii-dataset (public test), while the other detectors see it for the first time and some follow other labelling policies (for example, leaving organisations unmasked), so that column shows how each serves this masking policy; the four external columns are the fairer comparison. * Trained on OpenPII data (Rampart) or on data that overlaps it (KoELECTRA). GLiNER2-PII ran on Gretel in its library's long-text mode. On phones (mean of four) the 11.3 MB model takes about 26 ms for a 40-token message. With SDK 1.2 (the Python package as shipped) every number of our models in this table stays within 0.04 points, because the SDK changes only texts with emoji or keycaps.

What 1.2 changes. Release 1.2 is SDK 1.2.0 on the v1.1 models; v1.1 was not released on its own, so its model change ships here. Models: lone everyday words in short texts, table cells and survey exports are read as names far less often. On 20,691 short items in 54 languages (column titles, answer options, single words, names and values written alone), the PII-free items masked fall from 30.6% to 7.9% (large; medium 30.6% to 7.8%, small 36.8% to 9.4%, nano 39.3% to 11.1%), and checked cell by cell, large masks 6.6% of the PII-free cells of 228 survey CSV files instead of 24.9%. Trade-off: on KDPII large misses 9.6% (v1.0: 7.6%), medium 11.5% (9.8%), small 10.0% (9.5%); nano is unchanged at 9.5%. SDK: emoji are taken out of the text the model reads, so the model no longer reads them as names (keepEmoji: true turns this off; text without emoji or keycaps gives exactly the spans of 1.1); a keycap such as 3️⃣ is read as its bare character, so numbers written with keycaps are still found; every span is widened to whole grapheme clusters, so an emoji, flag or combining sequence is masked whole or kept whole (the npm package needs Intl.Segmenter for this); and table mode with the context: "header" option (above). The short-text, emoji and table sets are private and synthetic.

Emoji, model only and model + SDK 1.2: share of 4,501 texts (one to three emoji placed outside the PII) in which an emoji is masked. No emoji is cut in half; what is left is mostly a keycap next to a name, masked with it because keycaps are read as digits. PII characters missed on these texts also fall (large 0.87% to 0.31%, medium 1.03% to 0.61%). Release 1.0 masks an emoji in 7.42% (large), 9.46% (medium), 16.69% (small) and 21.88% (nano) of these texts and cuts one in half in 1.9% to 7.6%.

modelmodel onlymodel + SDK 1.2
newmean-pii-large23.95%0.87%
newmean-pii-medium14.89%0.78%
newmean-pii-small20.57%0.89%
newmean-pii-nano26.33%1.00%

Survey and form exports, miss % / PII-free data cells masked %: 556 files (121,272 cells, 54 languages) written by Claude Opus 5.5, which wrote none of our training data; the set was built after the SDK options were fixed and scored once.

modelwhole file, model onlytable mode (default)table mode + context: "header"detect on each cell
newmean-pii-large6.56 / 9.586.17 / 9.591.44 / 12.305.00 / 12.21
newmean-pii-medium8.29 / 9.307.93 / 9.321.93 / 11.665.75 / 12.03
newmean-pii-small7.00 / 15.876.65 / 15.901.72 / 19.036.21 / 14.21
newmean-pii-nano6.47 / 23.626.13 / 23.661.58 / 27.346.31 / 17.74

context: "header" cuts the misses to about a quarter for every size, at 2.3 to 3.7 more points of PII-free cells masked. Table mode alone misses about as much as reading the whole file, but keeps the table valid and masks whole contact columns. small and nano mask many PII-free cells in every mode (16% to 27%). Release 1.0 (v1.0 models, no table mode) reads these files whole and misses more: large 7.52 / 11.30, medium 9.50 / 9.37, small 9.80 / 13.43, nano 8.04 / 24.36. Two more sets, on which the options were chosen, and the full numbers: technical report, Section 6.2.

What 1.3 adds. SDK 1.3.0, same v1.1 models; two options: wholeWords on by default (false gives the 1.2 spans; the numbers above are without it), strictShortNames off. strictShortNames: a text the model reads as at most 8 tokens (a survey answer, a table cell) needs stronger evidence to be read as a name, so 「경기」, 「남성」 or 「네이버」 alone are left unmasked. Short PII-free items masked fall from 7.9% to 4.3% (large; medium 7.8% to 4.5%, small 9.4% to 4.7%, nano 11.1% to 5.9%), and lone names found fall from 98.9% to 96.5% (medium 97.5% to 95.4%, small 97.0% to 93.5%, nano 96.7% to 94.4%); longer texts are unchanged (public test and KDPII within 0.07 points). wholeWords: a span that ends inside a word covers the whole word ("R23" → [ID_NUMBER], not [ID_NUMBER]23; a word ends where Hangul meets digits or Latin letters, so 「010-1234-5678입니다」 → [PHONE]입니다; Korean particles after a Hangul span stay, 「홍길동님께」 → [PERSON]님께), which lowers misses on every set by 0.1 to 1.4 points (large: public test 1.63% to 1.54%, KDPII 9.61% to 9.08%) and masks a little more (large over-masking: public test 0.47% to 0.53%, KDPII 1.70% to 2.09%). Every package also gains info with the package and model versions and the checked model files.

What 1.4 adds. SDK 1.4.0, same v1.1 models; user lists in every package. block: values you know are PII (an instructor's name) are masked wherever they start and end on a word boundary, also before Korean particles (「박지훈님께」 → [PERSON]님께) and where the model misses them (source block). allow: a span whose whole text is a value you know is not PII (a region or brand in a survey) is not masked. ASCII letters are compared case-insensitively, nothing else is normalized (pass NFC text). Lists are checked before any model file is loaded, errors name the list, entry and reason but never the text, and info gives the entry counts and your listsId. On the KDPII dev split (large), a block list holding every name of the set, an upper bound, cuts PERSON characters missed from 24.6% to 3.1% at 0.4 points more over-masking; a generic 136-entry allow list changes little, as expected (allow is for the values of your own columns). Details: js/README.md. Using the C core directly (not through a package): the C API is source-compatible only, so rebuild against each release's pii.h; options structs from another release are rejected (native/core).

What 1.4.1 fixes. SDK 1.4.1, same v1.1 models; bug and doc fixes only, and every valid input gives the 1.4.0 spans. A sensitivity that is NaN or infinite is now an error in every package and in the C core (Android already refused it); before, NaN silently turned the model off and an infinity masked everything or nothing. The npm package also loads with require() on Node versions that can require ES modules (20.19+, 22.12+), and its info.verified is true only when the SHA-256 of both model files was actually checked (it used to copy the verify option). The Flutter package checks its native core at load, before any file is read, as its 1.4.0 notes said. Smaller fixes: npm detectTable checks the delimiter before running the model, the Flutter download names the package version in its User-Agent, and a few README passages were corrected (built-in engine size, the lists example, label names that are not labels).

What 1.5 changes. SDK 1.5.0, same v1.1 models; speed only. On arm64 (Apple silicon, iPhone, 64-bit Android) the native core of the Python, Swift, Android and Flutter packages now fuses multiply and add in its matrix kernel and works on 16 output columns at a time, like the npm package's relaxed-SIMD build: about 1.5 times as fast (medium on Apple M5 Pro, one thread: a short text 14.9 → 10.2 ms, 1,000 tokens 550 → 349 ms). Logits differ from 1.4.1 in the last bits, so a span can differ in rare cases: on 18,692 development texts and the four sizes, 1 of 74,768 results did. Results on arm64 now equal the npm package's relaxed-SIMD build (Chrome, Edge, Firefox) and are no longer bit-identical to x86-64, where nothing changes; building the core with PII_NO_FMA keeps the 1.4 kernel (native/core). The npm package gives the 1.4.1 spans.

What 1.6 adds. SDK 1.6.0, same v1.1 models; adapters only, and detect and redact give the 1.5.0 spans. The Python package gains newmean_pii.langchain (a detector and a ready PIIMiddleware for LangChain 1.0+), newmean_pii.litellm (a guardrail that masks requests or responses inside the LiteLLM proxy, with no second service), newmean_pii.presidio (a recognizer for Microsoft Presidio, one per language on a single model) and newmean_pii.langfuse (a mask function for traces); the npm package gains @newmean-ai/pii/ai-sdk (a Vercel AI SDK language model middleware) and @newmean-ai/pii/langchain (a LangChain.js agent middleware). None of these libraries is a dependency: the Python extras [langchain], [litellm] and [presidio] add them, and langchain is an optional peer dependency of the npm package. The adapters mask what is sent or stored and do not put the values back into a response. Guides: python/README.md, js/README.md. The Swift, Android and Flutter packages change only their version number.

What 1.6.1 fixes. SDK 1.6.1, same v1.1 models and the same spans. With the pattern layer on (regex: true, off by default) or in a direct call of regexSpans, the time grew with the square of the input: the EMAIL pattern was tried again from every character of a long run without "@", and every match was compared with all earlier ones, so a service that passes long text from outside could be kept busy (32,000 letters took 0.5 s in the npm package and 2 s in Python; now about 1 ms in Python and 0.05 ms in npm). The npm, Python, Swift, Android and Flutter packages are fixed; the Rust crate and the C core never had this layer. Each package checks the new matcher against the old one on every string of up to 7 characters over six structural characters and on random Unicode strings. Reported privately by @whatisyourname0 (Joonho Lee). Also in the Python package: the LiteLLM guardrail accepts allow and block entries written in config.yaml. The Rust crate newmean-pii, added after 1.6.0, follows the version. On npm use 1.6.2: 1.6.1 was published there without its built files and cannot be imported; 1.6.2 is the same code, built, and publishing now refuses a package without them.

Repository layout

foldercontents
js/the SDK, @newmean-ai/pii, with its test page, the public demo (playground/) and the phone benchmark (experiments/)
native/core/the C engine shared by the Python, iOS, Android and Flutter packages
python/the Python package newmean-pii
swift/, Package.swiftthe Swift package NewmeanPII (iOS, macOS)
android/the Android library ai.newmean:pii
flutter/the Flutter and Dart package newmean_pii
rust/the Rust crate newmean-pii
docs/report/the technical report and its two appendices (also in Korean)
leaderboard/code of the leaderboard Space on Hugging Face
site/the Worker that serves the demo and the phone benchmark at pii.newmean.ai
tools/data-request/how to request the training data (research free, commercial by inquiry)
training/training, export and evaluation code (the data generator is not included)
release/newmean-pii-dataset (public test) card

License

  • SDK code and model weights: Apache-2.0.
  • If you use them in a product, we would appreciate a "Powered by newmean.ai" mention in your docs or an about or licenses screen (a request, not a license condition).
  • newmean-pii-dataset (public test): CC BY-NC 4.0 (research and evaluation; commercial use by inquiry).
  • Training and validation data: on request through the data request form (research use free; commercial use by inquiry; requests open now, data shared from December 2026); the terms come with the approval email or the contract (tools/data-request).
  • Third-party attributions: NOTICE.

Made by newmean.ai.

Similar Projects

Discover other similar projects and AI models.

Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...

♥0
157.6M
Jun 1, 2026
RepositoryPython
data-privacy-stack/presidio

An open-source framework for detecting, redacting, masking, and anonymizing sensitive data (PII) across text, images, and structured data. Supports NLP, pattern matching, and customizable pipelines.

12.1k
Nov 28, 2026
RepositoryPython
sealandseacat/dbmask

Discover, mask, and verify sensitive data in SQL databases — an auditable scan → mask → validate workflow for safe database copies.

152
Nov 7, 2026
Modeltoken-classification
fastino/gliner2-privacy-filter-PII-multi

GLiNER2-PII: Multilingual PII Detection & Masking GLiNER2-PII is a fine-tune of the GLiNER2(https://github.com/fastino-ai/GLiNER2) model (205M parameters) for detecting and masking personally identifiable information across 42 entity types and 7 lan...

♥0
113.9k
Sep 28, 2026
Modeltoken-classification
OpenMed/privacy-filter-nemotron-v2

privacy-filter-nemotron-v2 OpenMed/privacy-filter-nemotron-v2 is the second-generation Nemotron-schema checkpoint in the OpenMed privacy-filter family. It keeps the same fine-grained 55-category PII vocabulary as OpenMed/privacy-filter-nemotron, whi...

♥0
170.0k
Sep 30, 2026
RepositoryRuby
thoughtbot/top_secret

Filter sensitive information from free text before sending it to external services or APIs, such as chatbots and LLMs.

422
May 14, 2026
RepositoryRuby
thoughtbot/top_secret

Filter sensitive information from free text before sending it to external services or APIs, such as chatbots and LLMs.

421
May 14, 2026
Modeltoken-classification
OpenMed/privacy-filter-multilingual-v2

privacy-filter-multilingual-v2 Fine-tuned openai/privacy-filter(https://huggingface.co/openai/privacy-filter) for fine-grained PII extraction across 54 categories in 16 languages. This v2 checkpoint is the more performant successor to OpenMed/privac...

♥0
119.6k
Jul 3, 2026
RepositoryPHP
clonio-dev/clonio-cli

Clonio is a GDPR and PII compliant CLI that clones production databases into your test, dev and CI stages with automatic anonymization.

143
Nov 22, 2026