PII Detection
Personally Identifiable Information (PII) detection helps protect user privacy by detecting and masking sensitive data in user inputs, LLM outputs, and retrieved content.
GLiNER-based PII Detection
The NeMo Guardrails library supports PII detection and masking using the NVIDIA GLiNER-PII NIM. For a full step-by-step walkthrough that includes CLI usage, Python SDK usage, and local deployment, refer to the GLiNER Integration page. The examples below assume each configuration lives in its own subdirectory under config/ (NeMo Guardrails merges every .yml / .yaml file it finds in a --config directory, so detection and masking rule sets need separate folders).
NVIDIA-Hosted Endpoint
Use the NVIDIA-hosted NIM by setting api_key_env_var in both the models block and the gliner config block.
nvidia/gliner-pii does not appear in the configs below because it is the default value of rails.config.gliner.model. You only need to set that field explicitly if you want to use a different model:
PII detection (save as config/pii_detection/config.yml) blocks input or output that contains PII:
PII masking (save as config/pii_masking/config.yml) replaces detected PII with label placeholders, such as changing Hi John to Hi [FIRST_NAME]:
Locally Hosted NIMs
To run both NIMs locally, pull the Docker containers and point each endpoint to localhost. No api_key_env_var is needed for local inference.
Important: You still need an
NGC_API_KEY(starting withnvapi-) to pull the Docker images and download model artifacts. You can generate one at org.ngc.nvidia.com/setup/api-keys or build.nvidia.com. Legacy NGC keys (older format, not starting withnvapi-) will cause the container to fail during artifact download.If you already have an
NVIDIA_API_KEYstarting withnvapi-, you can reuse it:Alternatively, you can pass the key directly at container runtime — this avoids overwriting any existing
NGC_API_KEYin your environment:See the GLiNER Integration — Deploy NIMs Locally section for full
docker runinstructions.
PII detection (update config/pii_detection/config.yml):
PII masking (update config/pii_masking/config.yml):
See the GLiNER Integration page for Docker pull and run instructions.
Presidio-based Sensitive Data Detection
The NeMo Guardrails library supports detecting sensitive data out-of-the-box using Presidio, which provides fast identification and anonymization modules for private entities in text such as credit card numbers, names, locations, social security numbers, bitcoin wallets, US phone numbers, financial data and more. You can detect sensitive data on user input, bot output, or the relevant chunks retrieved from the knowledge base.
To activate a sensitive data detection input rail, you have to configure the entities that you want to detect:
Example usage
For more details, check out the Presidio Integration page.
Private AI PII Detection
The NeMo Guardrails library supports using Private AI API for PII detection and masking input, output and retrieval flows.
To activate the PII detection or masking, you need specify server_endpoint, and the entities that you want to detect or mask. You’ll also need to set the PAI_API_KEY environment variable if you’re using the Private AI cloud API.
Example usage
PII detection
For more details, check out the Private AI Integration page.