PII Restoration

Restore reversible PII tokens in LLM responses back to their original values.

PII Restoration is the POST-stage counterpart to PII Tokenization. It reads the token → original value map from Redis and replaces all [PII_<ID>] tokens found in the LLM response with their corresponding real values, then immediately deletes the token map.

This module has no configuration — it operates automatically based on the token map written by PII Tokenization for the same request.

Requires PII Tokenization

PII Restoration only works when PII Tokenization is attached to the PRE stage of the same deployment. Without it, there is no token map to restore from.


Stage

StageBehavior
POST onlyReads the Redis token map for the current request and replaces all [PII_<ID>] tokens in the LLM response with their original values

Configuration

This module has no configuration parameters. Its behavior is fully determined by the token map created by PII Tokenization for the same request.


Lifecycle

PRE Stage → PII Tokenization writes token map to Redis
LLM processes anonymized request
POST Stage → PII Restoration reads token map, replaces tokens, deletes map

The map is deleted from Redis immediately upon successful restoration, minimizing the window during which sensitive data is stored outside your infrastructure.


Failure Behavior

If the token map has expired (TTL elapsed) or is missing, PII Restoration will pass the LLM response through unchanged. Your client will receive the raw LLM output, which may contain [PII_<ID>] placeholders instead of real values.

To prevent this, ensure the Token Map TTL configured in PII Tokenization is set to a value that safely exceeds the maximum expected LLM response time for your deployment.


Example Use Cases

  • Restoring personalized LLM responses: After tokenizing user data before an LLM call, automatically restore the real values so the response reads naturally for the end user.
  • Round-trip PII protection: Together with PII Tokenization, creates a complete shield around the LLM call — PII never touches the provider, but the response remains fully meaningful.

On this page