# What the project does This work describes a configurable, model-agnostic PII detector built around large language models. Instead of training a token-classification model with a fixed schema, the detector encodes the PII schema and output format into a system prompt. Any LLM that accepts a list of messages and returns assistant text can be used as the backend through a uniform Inferencer interface.
# Why this matters for teams PII appears in messy, multilingual free text (support transcripts, chat logs, HR records) and often includes domain-specific identifiers that fixed-label taggers miss. Traditional token-tagging models require relabeling and retraining to add new PII categories. This instruction-driven approach treats the schema as configuration: add, remove, or change entity types by editing the prompt, not by rebuilding models.
# How the detector is built (high level)
- Backend: an Inferencer adapter handles model calls. The package includes an adapter for Amazon Bedrock models (for managed models like Mistral or OSS-GPT) and accepts custom adapters for open models served on local GPUs or air-gapped environments.
- Call sequence: the system prompt, the model call through the Inferencer, and the parser are tied together by a thin orchestration layer in the provided package.
# Trade-offs and configuration choices
# Evaluation summary The detector was scored span-for-span alongside eight other LLM-based detectors, including the OpenAI PrivacyFilter, using a common ground truth across five public PII corpora. The Amazon Bedrock–based detector outperformed an off-the-shelf tool in that evaluation. The post includes repository code and a walkthrough for running the detector on your own data.
# Practical next steps for teams
- Review the prompt schema included in the sample-llm-pii-detection repository to map your domain-specific PII types into the template.
- Choose a backend based on your constraints: managed Bedrock models for convenience or a custom adapter for on-premises or air-gapped deployment.
- Use the parser/offset module to reconcile LLM-returned spans with original text and to compute exact character offsets before redaction or logging.
# Where to find the implementation The detector is provided as the pii-detector package inside the sample-llm-pii-detection repository. The repository includes the prompt templates, Inferencer adapter examples, parsing modules, and an end-to-end runbook.