Skip to main content

Overview

The PII Detection evaluator screens a conversation string for personally identifiable information (PII). Pass whatever slice of the interaction you want judged — user and assistant turns only, or a fuller record that also includes system instructions, tool calls, tool results, or retrieved documents. The judge classifies whether any identifying personal data is present in that string. Use it to audit agent traces, experiment runs, and logged conversations for privacy exposure. When include_explanation is True (the default on ClassificationEvaluator), the judge lists each instance in a FINDINGS block on the score’s explanation so downstream filters can act on specific categories (email, national ID, API token, and so on). Set include_explanation=False to skip that reasoning and return only the label and score.
Direction is minimize: detecting PII is the undesirable outcome.

Supported Levels

The level of an evaluator determines the scope of the evaluation in OpenTelemetry terms. Some evaluations are applicable to individual spans, some to full traces or sessions, and some are applicable at multiple levels. Relevant span kinds: AGENT, CHAIN, and LLM spans that preserve conversation text. Include TOOL spans when you are evaluating tool payloads.

Input Requirements

The PII Detection evaluator requires one input:

Formatting Tips

For best results:
  • Include every turn that is in scope, not just the final assistant message.
  • Add tool calls, tool results, or retrieved documents when you care about PII in those payloads. Leave them out when you only want to score the visible dialogue.
  • Use human-readable strings rather than raw JSON when you can.
  • For multi-turn conversations, format turns as:

Output Interpretation

The evaluator returns a Score object with the following properties: Interpretation:
  • PII detected (1.0): The record contains at least one instance of identifying personal data
  • No PII detected (0.0): The record contains none of the rubric categories

Findings

When explanations are enabled, each detected instance appears as one line in a FINDINGS block:
If nothing is found, the judge writes FINDINGS: none. type and source are meant for downstream filters (for example, alert only on national_id_number in tool_call_or_result). They are not separate score fields; parse them from explanation.

Usage Examples

Using Input Mapping

Map a trace, session, or dataset row into the single conversation field. Concatenate whichever columns are in scope — messages only, or messages plus tool calls and retrieved documents.
See Input Mapping for additional mapping options.

Viewing and Modifying the Prompt

The default prompt is maintained in the classification evaluator config. Adapt it when your product has domain-specific identifiers or a different definition of personal data.

Configuration

PiiDetectionEvaluator is a ClassificationEvaluator. The following constructor argument controls whether the judge writes FINDINGS into the score:
include_explanation is a Python constructor argument. The TypeScript createPiiDetectionEvaluator always requests an explanation.
For model and provider options, see Configuring the LLM.

Using with Phoenix

Benchmarks

On a 40-example authored suite (24 with PII, 16 without) using gpt-4o-mini, the default prompt achieves 0.93 accuracy, 0.94 macro precision, 0.91 macro recall, and 0.92 macro F1. See pii_detection.synthetic.eval.ts. On a stratified 150-record sample of nvidia/Nemotron-PII (all positives) using gpt-4o-mini, the same prompt achieves a 0.96 detection rate (recall). Precision cannot be measured on that fixture because it contains effectively no negatives. See pii_detection.eval.ts.

API Reference