Amazon iconAmazonSep 10, 2026 ~7 min source read

Model-agnostic PII detection with LLMs

An instruction-driven detector that turns any LLM managed on Amazon Bedrock into a configurable PII scanner. The detector uses prompts (not retraining) to define entities, runs on a swappable inference backend, and was evaluated against existing tools across public PII corpora.

Model-agnostic PII detection with LLMs

Share this story

Send the public story page.

Useful takeaways from this story.

PII detection is driven by instructions in the prompt, so adding or removing entity types requires a one-line edit, not retraining.

A uniform Inferencer interface makes the solution model-agnostic and deployable on Amazon Bedrock or in private infrastructure via a custom adapter.

Benchmarks on five public corpora across nine LLM-based detectors show the approach outperforming an off-the-shelf tool in the reported evaluation.

# 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.

More context around this story.

Loading more related stories...

Keep reading in the app

Open the app view to save this story, compare related coverage, and continue from the same source.

Open in app