@desert-ant-labs/redact
v0.4.0
Published
On-device multilingual PII redaction for JavaScript with local WebAssembly and LiteRT.js inference.
Readme
@desert-ant-labs/redact
On-device multilingual PII redaction for JavaScript (node and browsers). Finds
names, addresses, emails, phone numbers, cards, IBANs, national IDs and more
across the 24 official EU languages, fully locally: the package runs through a
local WebAssembly runtime with inference via LiteRT.js (@litertjs/core).
Inference runs in the browser (LiteRT.js is a browser runtime, using an XNNPACK-accelerated CPU path by default and optional WebGPU). In plain Node the WebAssembly pipeline still loads, but the model session is unavailable, so use this in a browser (or a browser-like environment) for redaction.
npm install @desert-ant-labs/redact @litertjs/coreimport { Redact } from "@desert-ant-labs/redact";
const redact = await Redact.load(); // downloads the model on demand, cached
const r = await redact.redaction("Email Anna at [email protected].");
r.redactedText; // "Email [GIVEN_NAME_1] at [EMAIL_1]."
r.items; // detections: label, original, placeholder, confidence, offsets
const reply = await llm(r.redactedText); // the LLM sees only placeholders
r.restore(reply); // originals filled back inRedact.load() accepts:
directory(node): an explicit model directory; files already there are used offline, otherwise the model is downloaded into it. Omit for the managed cache (~/.cache/desert-ant-models/...).onProgress: download progress callback, fraction in[0, 1].litert: bring-your-own LiteRT.js module (the@litertjs/corenamespace, e.g. a bundler-managed import).litertWasmDir: URL/path to the LiteRT.js Wasm files (defaults to the installed package, or the jsDelivr CDN in the browser).accelerator:"wasm"(XNNPACK CPU, default),"webgpu", or"webnn".
The model repo and revision are pinned to the package version. @litertjs/core
is an optional peer dependency.
The same model ships as a Swift package (iOS/macOS) and an Android AAR from the same repository: https://github.com/Desert-Ant-Labs/redact
License
Desert Ant Labs Source-Available License 1.0: free below 100,000 monthly active devices per platform; above that a commercial license is required ([email protected]). Full terms: https://license.desertant.ai/1.0
