local-pii

Browser Detection

Run the Rampart Detection adapter in the browser with onnxruntime-web (WASM + WebGPU).

The pure TypeScript core runs in the browser. local-pii/web supplies the Rampart Q4 Detection adapter; it finds names, addresses, and IDs before a Generation model receives protected content.

bun add local-pii onnxruntime-web @local-pii/model-rampart

Zero-config Detection

import { createAnonymizer } from "local-pii"
import { rampartWeb } from "local-pii/web"

const privacy = createAnonymizer({ detection: rampartWeb() })
const { redactedText } = await privacy.anonymize("Hi, I'm João Silva")

The default fetches the 14.7 MB model, vocabulary, and labels from the Rampart origin. Loading is lazy: the first anonymization starts Rampart artifact and runtime loading. The artifact download contains no user content. For production, prefer self-hosting with a pinned asset and Content Security Policy.

Self-hosted

import { createAnonymizer } from "local-pii"
import { rampartAssets, rampartWeb } from "local-pii/web"

const privacy = createAnonymizer({
  detection: rampartWeb({
    model: "/models/rampart-q4.onnx",
    vocab: rampartAssets.vocab,
    labels: rampartAssets.labels,
    wasmPaths: "/ort/",
    executionProviders: ["webgpu", "wasm"],
  }),
})

The adapter falls through from WebGPU to WASM. Configure a Detection model, then choose a separate Generation adapter or runInlineText for the model call. ner: is still accepted as a compatibility spelling for detection:.

On this page