SurrogateShield
A privacy-first guardrail for LLMs and RAG pipelines. SurrogateShield detects, redacts, and reconstructs sensitive PII data on the fly while defending against a
What is SurrogateShield?
A privacy-first guardrail for LLMs and RAG pipelines. SurrogateShield detects, redacts, and reconstructs sensitive PII data on the fly while defending against adversarial attacks.
Overview of SurrogateShield
What it is
SurrogateShield is a privacy-preserving proxy for large language models (LLMs) and retrieval-augmented generation (RAG) pipelines. It detects, redacts, and reconstructs sensitive personally identifiable information (PII) on the fly while defending against adversarial attacks. All cryptographic operations run locally. On the sealed test-3 benchmark of real chat messages, SurrogateShield let 0.8% of 3,677 personal values through, compared to 9.1% for GLiNER-PII and 31.6% for Microsoft Presidio.
Key features
- Layered PII detection: regex patterns, a DeBERTa-v3-small PII tagger, spaCy, and optional distilbert-NER, with presets balanced, strict, fast, and classic.
- Realistic surrogate generation: fake names, SSNs, Bitcoin addresses, etc., that pass format checks.
- AES-256-GCM encrypted ShadowMap: surrogate-to-original mappings are never stored in plaintext.
- Multi-provider support: Claude, Gemini, ChatGPT, or fully offline via Ollama.
- Service-query intelligence: location queries get minimal address fuzzing instead of full replacement.
- Quasi-identifier risk detection: warns when combinations like ZIP+DOB+gender risk re-identification (Sweeney k-anonymity).
- Privacy-aware RAG: documents are anonymised before indexing; surrogates are used in all vector store operations.
Use cases
- Protecting PII in LLM interactions by masking sensitive data before it reaches an LLM provider and restoring it in the reply.
- Anonymizing data for RAG pipelines to prevent PII leakage during indexing and retrieval.
- Evaluating PII detection pipelines with batch evaluation, per-entity-type metrics, and ablation studies.
Getting started
Install the standalone Python library from the repository root:pip install ./python-libraryFor full setup instructions, including configuration and running the dashboard, see the repository README.
License and pricing
License: Apache-2.0. Pricing: open source (free).
Based on the project's public README and repository metadata.