Preview a Config
This tutorial walks through the anonymizer.preview flow: defining a request, streaming a small anonymized sample, and inspecting the resulting frames.
For detection and replacement strategy details, see the open-source library documentation.
Prerequisites
Complete the tutorials prerequisites, which cover:
- A running NeMo Helix cluster with the
nemo anonymizerCLI available (see Setup). - An inference provider configured (default examples use
nvidia-build). - A fileset named
anonymizer-inputscontaininganonymizer-input.csvin your current workspace. Upload a CSV withidandbiographycolumns before running this notebook; see Upload an Input Fileset.
What preview Does
preview runs the Anonymizer pipeline on a small number of records and streams results back from the plugin service. The Python SDK collects the stream into a pandas DataFrame; the basic CLI streams NDJSON frames to stdout.
The plugin emits these frame kinds:
Available preview surfaces:
Step 1: Build a PreviewRequest
A preview request bundles the AnonymizerConfig, the input spec, and model_configs / selected_models.
Set NVIDIA_MODEL and NHX_ANON_GENERAL_MODEL to override the thinking and general-purpose model IDs below. Use exact IDs from the chosen provider’s catalog, with credentials authorized for both models; the role aliases stay unchanged.
Field reference:
Step 2: Run with the Python SDK
AnonymizerResource.preview calls the plugin service: use a fileset or http(s) source, and include model_configs.
The CLI accepts the same request as a YAML or JSON spec file and streams NDJSON frames.
To use the request from Step 1 with the CLI instead of calling anonymizer.preview, first
serialize it to a local YAML file (no preview call is needed to write the spec):
Preview frames may contain original input text and PII. Treat both terminal output and saved files as sensitive. To display and save all emitted frames as NDJSON in a new owner-only file, run:
The saved file contains all frame kinds, not just the anonymized records. This CLI
path does not create the Python preview variable used in Step 3.
Async client
AsyncAnonymizerResource.preview has the same signature and return type. In a notebook, use top-level await (the notebook already runs an event loop):
In a standalone Python script, use asyncio.run(run_preview()) instead (with import asyncio).
Step 3: Persist Preview Records (Python SDK)
This step applies only if you called the sync or async Python SDK above. For the
CLI path, use the NDJSON file saved by tee instead.
AnonymizerPreviewResult.dataset and trace_dataset are pandas DataFrames, so save them with standard pandas methods:
More about preview results
AnonymizerPreviewResult stores everything in memory; nothing is persisted to disk by default. The dataset field is a regular pandas DataFrame and can be saved with to_csv or to_parquet.
Input Source Forms
The plugin accepts HTTP(S) URLs or Fileset references for data.source. Fileset references take any of the forms below; the workspace and fileset must already exist:
The #<path> fragment must resolve to a single .csv or .parquet file. The plugin downloads the file before constructing the Anonymizer library input and cleans up the temp directory when the preview completes.
Validate the Config Independently
If you want to validate just the AnonymizerConfig (and optionally a model_configs YAML) without running a preview, use nemo anonymizer validate:
validate checks the config against the model selection (for example, that a Substitute strategy has a replacement_generator model defined) and prints Config is valid. on success. It does not accept data.source, so input-source validation happens during preview or run.
Next Steps
- Run a full job and inspect parquet output in the run tutorial.
- Refer to SDK Resources for
AnonymizerPreviewResultandAnonymizerResource.previewdetails. - Learn about rewrite and replacement strategy parameters in the library docs.