Worka PII: Deterministic Redaction for AI Pipelines
A Rust-first PII detection and anonymization library with stable offsets, capability-aware NLP, and audit-friendly outputs designed for CPU-only runtimes.
Why Worka PII?
๐งญ Deterministic Output
Stable byte offsets and reproducible spans make redaction and audits reliable across runs and environments.
๐งฉ Modular Pipeline
Regex, validators, dictionaries, and optional NER are composed into a capability-aware pipeline with controlled degradation.
๐ก๏ธ Policy-Driven Redaction
Per-entity operators (redact, mask, replace, hash) with explicit configuration and audit logging.
โ๏ธ CPU-Only Friendly
Designed to run fast without GPUs, with optional Candle-based NER for higher recall when available.
Quick Start
Detect and anonymize PII in a few lines. See the docs for full configuration.
use pii::anonymize::{AnonymizeConfig, Anonymizer, Operator};
use pii::nlp::SimpleNlpEngine;
use pii::presets::default_recognizers;
use pii::{Analyzer, PolicyConfig};
use pii::types::Language;
use std::collections::HashMap;
let analyzer = Analyzer::new(
Box::new(SimpleNlpEngine::default()),
default_recognizers(),
Vec::new(),
PolicyConfig::default(),
);
let text = "Email jane@example.com or call +1 415-555-1212.";
let result = analyzer.analyze(text, &Language::from("en")).unwrap();
let mut config = AnonymizeConfig::default();
let mut per_entity = HashMap::new();
per_entity.insert("Email".to_string(), Operator::Replace { with: "<EMAIL>".into() });
per_entity.insert("Phone".to_string(), Operator::Mask { ch: '*', from_end: 4 });
config.per_entity = per_entity;
let redacted = Anonymizer::anonymize(text, &result.entities, &config).unwrap();
println!("{}", redacted.text);Fits Into Worka
LLM Safety Layer
Scrub prompts and responses before they reach models.
Audit-Ready Events
Stable spans and operators allow reproducible auditing.
Policy Control
Per-entity policies for redaction, masking, or hashing.
Use Cases
Prompt Sanitization
Remove PII before LLM calls.
Log Redaction
Sanitize logs and traces at the edge.
Secure Exports
Ship data with anonymization rules.
Support Workflows
Hide sensitive fields in tickets.
Ready to ship safer AI apps?
Worka PII is open source and designed for production systems that need deterministic redaction, auditability, and performance.