local-pii

Detection model (Expo)

Run the Rampart Detection adapter on iOS and Android with onnxruntime-react-native.

The Rampart Q4 model is a Detection model for names, addresses, and IDs. It runs locally through onnxruntime-react-native; the separate Generation model receives only protected content.

bun add onnxruntime-react-native expo-asset expo-file-system @local-pii/model-rampart

Requires a dev client / prebuild, not Expo Go.

Metro

const { getDefaultConfig } = require("expo/metro-config")
const { withLocalPiiMetro } = require("local-pii/metro")

module.exports = withLocalPiiMetro(getDefaultConfig(__dirname))

Configure Detection

import { createAnonymizer } from "local-pii"
import { rampart } from "local-pii/expo"

const privacy = createAnonymizer({
  detection: rampart({
    model: require("@local-pii/model-rampart/assets/rampart-q4.onnx"),
  }),
})

Loading is lazy: the first anonymization resolves the packaged asset and starts the Rampart runtime. Applications consuming the published model package do not run the monorepo's fetch-model development script.

If the model cannot load or inference fails, configured Detection fails closed by default. Set strict: false only when deterministic Detection fallback is an intentional product policy. ner: remains supported as a compatibility alias. CITY, STATE, and ZIP_CODE are kept by default; use keep or redact to change that policy.

On this page