Skip to navigation

Tutorials

View as Markdown

These tutorials cover the two user-facing surfaces of the Anonymizer plugin: the streaming preview workflow for iteration, and the run job for full datasets.

Library vs. Service

Anonymizer separates configuration (what to detect and how to replace it) from execution (where the work runs and how models are reached).

Part 1: Build the config (library)

Use anonymizer.config to define the rewrite or replacement strategy and detection options. This code is identical whether you run Anonymizer standalone or through NeMo Helix service.

from anonymizer.config.anonymizer_config import AnonymizerConfig
from anonymizer.config.replace_strategies import Redact
config = AnonymizerConfig(
replace=Redact(format_template="[REDACTED_{label}]"),
)

Part 2: Execute (platform)

Submit the config to the Anonymizer service. The plugin owns the request shape (PreviewRequest, AnonymizerRequest) so it can also describe the input source and model routing:

import os
from anonymizer.config.anonymizer_config import AnonymizerConfig
from anonymizer.config.replace_strategies import Redact
from data_designer.config import ModelConfig
from nemo_anonymizer_plugin.app.input import AnonymizerInputSpec
from nemo_anonymizer_plugin.app.task_config import PreviewRequest
from nemo_anonymizer_plugin.sdk.resources import AnonymizerResource
from nemo_helix_plugin.client.client import NemoClient
MODEL_PROVIDER = os.environ.get("NHX_ANON_PROVIDER", "nvidia-build")
GENERAL_MODEL = os.environ.get("NHX_ANON_GENERAL_MODEL", "openai/gpt-oss-20b")
config = AnonymizerConfig(
replace=Redact(format_template="[REDACTED_{label}]"),
)
model_configs = [
# The Anonymizer plugin manages a default PII entity detector, so it is not
# configured here (you may override it with a ModelConfig, but that is
# optional). These entries cover the remaining LLM roles.
ModelConfig(alias="gpt-oss-120b", provider=MODEL_PROVIDER, model=GENERAL_MODEL),
ModelConfig(alias="nemotron-30b-thinking", provider=MODEL_PROVIDER, model=os.environ.get("NVIDIA_MODEL", "nvidia/nemotron-3.5-lightning-30b-a3b")),
]
client = NemoClient.from_config()
WORKSPACE = client.resolve_workspace()
anonymizer = AnonymizerResource(client)
preview = anonymizer.preview(
PreviewRequest(
config=config,
data=AnonymizerInputSpec(
source=f"fileset://{WORKSPACE}/anonymizer-inputs#anonymizer-input.csv",
text_column="biography",
id_column="id",
),
model_configs=model_configs,
num_records=10,
)
)

Service-Specific Considerations

When using Anonymizer as a NeMo Helix service:

FeatureDifferenceDetails
InferenceRoutes through the Inference GatewayConfigure providers once and reference them by name from model_configs.
Input dataFilesets and HTTP(S) URLsUse client.files.create_fileset / client.files.upload_file, then reference with #<path>.
ArtifactsPlatform-managedrun stores artifacts in NeMo Helix job storage.

Prerequisites

Complete Setup to install NeMo Helix, run nemo services run, and configure an inference provider. The Anonymizer plugin is currently supported from NeMo Helix monorepo workspace: run make bootstrap at the repo root, or make bootstrap-python / uv sync if you only need Python dependencies, so uv can resolve nemo-anonymizer-plugin and the workspace prerequisites nhx-common, nemo-helix-plugin, and data-designer-nemo.

The root workspace includes the Anonymizer plugin, so nemo services run discovers it automatically and mounts /apis/anonymizer/... on the gateway. Standalone installation from a fresh environment outside the repo is not available. Verify the CLI is registered:

nemo anonymizer --help

You should see validate, preview, and run commands.

These tutorials route inference through an Inference Gateway provider, so a NeMo Helix cluster must be running before you preview or run a job. The examples reference the default NVIDIA Build provider created during setup.

When you configure NVIDIA Build with nemo setup, it registers the nvidia-build model provider in the setup workspace (--workspace, otherwise the active context workspace, falling back to default). These tutorials assume setup used default, so they reference default/nvidia-build. If you used another workspace, substitute <workspace>/nvidia-build and list providers in that workspace. This provider routes inference requests to models hosted on build.nvidia.com using the API base URL https://integrate.api.nvidia.com and the NGC API key with Public API Endpoints permissions provided during deployment.

You can verify this provider exists by running nemo inference providers list --workspace default.

The tutorials in these docs use this provider for inference, but you can alternatively create your own and use it instead.

The NVIDIA provider-creation and evaluation examples support NVIDIA_BASE_URL, an OpenAI-compatible API base including /v1. The default is https://integrate.api.nvidia.com/v1. For another service, export its base URL (for example, export NVIDIA_BASE_URL=https://inference-api.nvidia.com/v1) and set NVIDIA_API_KEY to a credential authorized for that service. Model identifiers and access must also match the service. Set NVIDIA_MODEL to the exact chat-model ID from that service’s /v1/models catalog; no override retains each example’s public NVIDIA Build default. Anonymizer examples also support NHX_ANON_GENERAL_MODEL for their general-purpose model. Retrieval examples give the more specific RETRIEVAL_CHAT_MODEL priority over NVIDIA_MODEL and support RETRIEVAL_EMBED_MODEL for the embedding model. This does not automatically change providers you have already registered.

Upload an Input Fileset

anonymizer.preview, nemo anonymizer preview, and nemo anonymizer run reject local file paths, so the tutorials read from a fileset. Create a small CSV containing PII and upload it to a fileset named anonymizer-inputs:

import tempfile
from pathlib import Path
from nemo_helix_plugin.client.client import NemoClient
from nemo_helix_plugin.files.types import CreateFilesetRequest
FILESET = "anonymizer-inputs"
INPUT_FILENAME = "anonymizer-input.csv"
client = NemoClient.from_config()
WORKSPACE = client.resolve_workspace()
with tempfile.NamedTemporaryFile("w", suffix=".csv", delete=False) as f:
f.write(
"id,biography\n"
"1,Alice Johnson lives in Seattle and works at NVIDIA.\n"
"2,Bob Smith can be reached at bob.smith@example.com.\n"
)
input_path = Path(f.name)
client.files.create_fileset(
workspace=WORKSPACE,
body=CreateFilesetRequest(name=FILESET, description="Anonymizer input files"),
exist_ok=True,
)
client.files.upload_file(
workspace=WORKSPACE,
name=FILESET,
path=INPUT_FILENAME,
content=input_path.read_bytes(),
)

The tutorials reference this file with fileset://{WORKSPACE}/anonymizer-inputs#anonymizer-input.csv.

Tutorials