Instructions to use desert-ant-labs/redact with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use desert-ant-labs/redact with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
redact: on-device multilingual PII redaction
Detects and redacts personal data (names, addresses, emails, phone numbers,
cards, IBANs, national IDs and more) in text across all 24 official EU
languages (Latin, Greek and Cyrillic scripts). A BIOES token classifier plus a
portable, dependency-free deterministic layer for structured IDs. The deployable
model is ~11.6 MB (4-bit Core ML on Apple) or ~24 MB (int8 LiteRT
.tflite on Android, Linux and the web).
"Call Anna Kovács at anna@example.hu, IBAN GB29NWBK60161331926819"→"Call [GIVEN_NAME] [SURNAME] at [EMAIL], IBAN [BANK_ACCOUNT]"
Try it
All platforms ship from one repo: Desert-Ant-Labs/redact (Swift, Kotlin, and JavaScript in a single codebase).
- Live demo: desert-ant-labs/redact-demo: paste text and watch PII get highlighted or masked, fully in your browser.
- iOS / macOS / tvOS / visionOS: the Swift SDK (Swift Package Manager) with a built-in demo app. It bundles the compiled Core ML model below.
- Android / JVM (Kotlin): Maven Central
ai.desertant:redact— LiteRT (.tflite), with the model downloaded on demand or bundled viaai.desertant:redact-tflite-resources. - Node / browser (JavaScript / TypeScript):
npm i @desert-ant-labs/redact @litertjs/core— a local WebAssembly pipeline with LiteRT.js inference; fetches the model from this repo and caches it.
import Redact
let redact = Redact()
let r = try await redact.redaction(of: "Email Anna Kovács at anna@example.hu.")
r.redactedText // "Email [GIVEN_NAME_1] [SURNAME_1] at [EMAIL_1]."
Files
| File | Format | Size | Contents |
|---|---|---|---|
redact.tflite |
LiteRT / TFLite (int8) | ~24 MB | Dynamic-range int8, fixed [1, 256] window; runs on Android, Linux and the web (used by the Kotlin and JavaScript SDKs) |
redact.mlmodelc |
Compiled Core ML (4-bit) | ~11.6 MB | Palettized model, ready to load on Apple platforms (used by the Swift SDK) |
redact.pt |
PyTorch checkpoint | ~90 MB | Full-precision weights + config (for retraining / other runtimes) |
config.json |
JSON | tiny | Transformer + label config |
tokenizer.json, tokenizer_config.json |
JSON | ~2.3 MB | EU-trimmed (31,475-piece) SentencePiece tokenizer (XLM-R lineage) |
redact_tokenizer.bin |
Binary | ~0.4 MB | Compact SentencePiece vocab bundled by the SDKs |
labels.json |
JSON | tiny | BIOES id2label / label2id |
redact_meta.json |
JSON | tiny | Public labels, deterministic-owner labels, recommended thresholds, base-model info |
Older revisions (tags v0.2.x) additionally carry redact.onnx for SDK
versions that predate the LiteRT migration.
Taxonomy (20 public labels)
GIVEN_NAME, SURNAME, STREET_NAME, BUILDING_NUMBER, SECONDARY_ADDRESS,
CITY, STATE, ZIP_CODE, EMAIL, PHONE, CREDIT_CARD, BANK_ACCOUNT,
ROUTING_NUMBER, IP_ADDRESS, URL, GOVERNMENT_ID, PASSPORT,
DRIVERS_LICENSE, TAX_ID, SSN.
The deterministic layer additionally emits IMEI (device identifier), a
deterministic-only label outside the 20-label neural head.
Architecture
- Encoder: Multilingual-MiniLM (XLM-R lineage) truncated to 6 layers with an EU-script-trimmed vocab (~23 M params), fine-tuned for BIOES tagging.
- Deterministic layer: a pure-stdlib post-processor owns high-confidence structured labels (email, URL, IP/MAC, card, IBAN/BIC, VIN, SSN, routing, tax id, government id, passport, driving licence, IMEI) with real validation (Luhn, ISO-13616 IBAN, ISO-7064, per-country checksums) and reconciles them with the model's contextual predictions. EU structured coverage includes checksum-validated national IDs for all 24 EU countries, all 27 EU VAT numbers, IMEI, and per-country driving-licence numbers. The same layer is ported byte-for-byte to the JS and Swift runtimes (span-for-span parity).
- Recommended runtime:
min_score = 0.6,max_length = 256,stride = 64.
Benchmark
On a fair, all-label, 24-language evaluation (external WikiANN + MultiNERD for names/places, plus a neutral format-valid structured-PII set): fair composite leak-safe recall 88.8, typed F1 85.4, strict F1 71.0, best among on-device models by a wide margin, with better labeling accuracy and precision than models 100×+ its size.
License
Desert Ant Labs Source-Available License. Free for most apps; a commercial license is required at scale. Full terms are at the link. Licensing: licensing@desertant.ai.
- Downloads last month
- 53