Skip to content

🕵️ NeMo Anonymizer

GitHub License Python 3.11+

NeMo Anonymizer detects and protects PII through context-aware replacement and rewriting. It offers high-quality user-guided entity detection, followed by modification options that maintain context while inducing privacy. You can review what sensitive information was found, adjust your masking strategy, and generate anonymized text.

NeMo Anonymizer query flow: detect entities, choose a replace or rewrite strategy, then evaluate the anonymized output.

Pick a strategy:

Alice met with Bob and his daughter to review kindergarten application #A9349.

Maya met with Daniel and his daughter to review kindergarten application #B5821.

[REDACTED_FIRST_NAME] met with [REDACTED_FIRST_NAME] and his daughter to review kindergarten application #[REDACTED_ID].

<Alice, first_name> met with <Bob, first_name> and his daughter to review kindergarten application #<A9349, id>.

<HASH_FIRST_NAME_3bc51062973c> met with <HASH_FIRST_NAME_cd9fb1e148cc> and his daughter to review kindergarten application #<HASH_ID_f2a5f83e2a4c>.

The family met with the admissions counselor to review their school application.


Get Started

Install

pip install nemo-anonymizer

Setup

# Get an API key from OpenRouter
export OPENROUTER_API_KEY="your-openrouter-api-key"
By default, Anonymizer runs GLiNER2 detection locally and uses OpenRouter for LLM-based anonymization. You can also bring your own models.

Review the default provider's data policies

OpenRouter's terms of service and privacy practices apply independently of the NeMo Framework library. Review those terms and the data policies of the models you select before sending sensitive data to the default endpoint.

Record length

Records up to 2,000 tokens each work with the default model configs. Longer text will require adjustment of model providers and model configs.

Anonymize

from anonymizer import Anonymizer, AnonymizerConfig, AnonymizerInput, Substitute

input_data = AnonymizerInput(
    source="https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv",
    text_column="biography",
    data_summary="Biographical profiles of individuals",
)
anonymizer = Anonymizer()
config = AnonymizerConfig(replace=Substitute())

anonymizer.validate_config(config)

preview = anonymizer.preview(
    config=config,
    data=input_data,
    num_records=5,
)
preview.display_record()

# Inspect the preview, adjust parameters if needed, then run full data.
output = anonymizer.run(
    config=config,
    data=input_data,
)
# Preview a few rows first
anonymizer preview \
  --source "https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv" \
  --text-column biography \
  --data-summary "Biographical profiles of individuals" \
  --replace substitute \
  --num-records 5

# Then run the full dataset
anonymizer run \
  --source "https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv" \
  --text-column biography \
  --data-summary "Biographical profiles of individuals" \
  --replace substitute \
  --output biographies_anonymized.csv

data_summary improves detection

data_summary is optional but recommended for domain-specific data. It helps the LLM find more entities and reduce false drops.

Language And Regional Coverage

Anonymizer has been tested most extensively on English-language data. Multilingual quality has not yet been evaluated systematically across languages, domains, and models.

Although testing so far has been primarily in English, the supported entity set is not limited to U.S.-specific identifiers. Detection and anonymization can also apply to international formats such as non-U.S. phone numbers, addresses, legal references, and national or regional identification numbers, though coverage will vary by language, region, and model configuration.

If you are working with another language, we encourage you to experiment on a small sample first with preview(), validate detected entities and transformed output carefully, and adjust your model providers and model configs as needed.

Inspect

View an interactive visualization with entity highlights.

preview.display_record()
Access the main results -- original text, entities, and transformed text.
preview.dataframe
Access the full pipeline trace with all internal columns.
preview.trace_dataframe


Telemetry and Privacy

NeMo Anonymizer includes an optional function to share anonymous run-level telemetry with NVIDIA for product improvement. One event is emitted per Anonymizer.run() / Anonymizer.preview() invocation and contains only technical metadata:

  • Run outcome — final task status (completed / error / canceled) and wall-clock duration
  • Pipeline configuration — transformation type (annotate, redact, hash, substitute, rewrite), whether data_summary / privacy_goal / Substitute(instructions=...) were customized, max_repair_iterations, strict_entity_protection
  • Models used per step — model aliases for the detector, validator, augmenter, rewriter, etc. (whichever steps ran in this mode)
  • Model hosts — coarse classification of the inference endpoints used (nvidia-build, nvidia-internal, openrouter, local, other)
  • Aggregate counts — number of input records, success and failure counts, average tokens per record (estimated with tiktoken cl100k_base), and failure attribution by pipeline workflow
  • Deployment type — sdk or cli

No user data, record contents, prompts, model outputs, or device information are collected. Aggregate usage data (such as which models are most popular) will be shared back with the community; it is not used to track any individual user behavior.

You may opt out of telemetry collection at any time. Opting out applies only to data collection by NeMo Anonymizer itself.

To disable telemetry in the SDK, set emit_telemetry=False on AnonymizerConfig:

config = AnonymizerConfig(replace=Redact(), emit_telemetry=False)

To disable telemetry for one CLI invocation, pass --no-emit-telemetry:

uv run anonymizer run --source data.csv --text-column text --replace redact --no-emit-telemetry

To disable telemetry for the current shell, set NEMO_TELEMETRY_ENABLED=false (other accepted disabling values: 0, no) in your environment before running:

export NEMO_TELEMETRY_ENABLED=false

Use of third-party endpoints, including OpenRouter and NVIDIA Build: Anonymizer can be configured to use various inference endpoints, including OpenRouter, build.nvidia.com, or local model servers. If you choose to use a third-party endpoint, that endpoint's own terms of service and privacy practices apply independently of this library. Any opt-out you exercise within Anonymizer does not extend to data collection by your chosen endpoint.


Next up

  • Detect

    Refine how to search for entities.

  • Replace

    Customize how to replace entities -- substitute, redact, annotate, or hash.

  • Rewrite

    Generate a privacy-safe paraphrase of the entire text.

  • Tutorials

    End-to-end notebooks for replace and rewrite.