diff --git a/docs/notebook_source/01_your_first_anonymization.py b/docs/notebook_source/01_your_first_anonymization.py
index ee34ee7a..65f96b6d 100644
--- a/docs/notebook_source/01_your_first_anonymization.py
+++ b/docs/notebook_source/01_your_first_anonymization.py
@@ -1,6 +1,3 @@
-# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0
-
# ---
# jupyter:
# jupytext:
@@ -15,6 +12,10 @@
# ---
# %% [markdown]
+#
# # 🕵️ Your First Anonymization
#
# Detect sensitive entities and replace them with LLM-generated substitutes --
diff --git a/docs/notebook_source/02_inspecting_detected_entities.py b/docs/notebook_source/02_inspecting_detected_entities.py
index c3dc4d90..110bf75c 100644
--- a/docs/notebook_source/02_inspecting_detected_entities.py
+++ b/docs/notebook_source/02_inspecting_detected_entities.py
@@ -1,6 +1,3 @@
-# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0
-
# ---
# jupyter:
# jupytext:
@@ -15,6 +12,10 @@
# ---
# %% [markdown]
+#
# # 🕵️ Inspecting Detected Entities
#
# Dig into the entity detection pipeline output -- what was detected,
@@ -26,6 +27,10 @@
# We use **Annotate** mode because it preserves the original text while tagging each entity
# with its label, making it ideal for reviewing detection quality.
#
+# > **Privacy warning:** `Annotate` does not anonymize the text. Sensitive values
+# > remain in the output, so use it only for inspection -- not as a privacy-safe
+# > production strategy.
+#
# #### 📚 What you'll learn
#
# - Run the detection pipeline and inspect its output using Annotate mode
@@ -100,13 +105,15 @@
# %% [markdown]
# ## 📋 Columns
#
-# - `trace_dataframe` contains all internal columns from the pipeline
-# (detection, validation, replacement, etc.).
+# - `result.dataframe["final_entities"]` is the stable, public entity output.
+# - `trace_dataframe` contains internal pipeline columns for deeper debugging;
+# those underscore-prefixed columns may change between releases.
# %%
-df = result.trace_dataframe
-print(f"Records: {len(df)}")
-print(f"Columns: {list(df.columns)}")
+trace_df = result.trace_dataframe
+final_entities = result.dataframe["final_entities"]
+print(f"Records: {len(trace_df)}")
+print(f"Columns: {list(trace_df.columns)}")
# %% [markdown]
# ## 🎯 Detected entities
@@ -116,7 +123,7 @@
# %%
row_idx = 0
-raw = df.loc[row_idx, "_detected_entities"]
+raw = final_entities.iloc[row_idx]
entities = raw["entities"] if isinstance(raw, dict) else raw
print(f"Record {row_idx}: {len(entities)} entities detected\n")
@@ -132,7 +139,7 @@
# %%
label_counts = Counter()
-for raw in df["_detected_entities"]:
+for raw in final_entities:
entity_list = raw["entities"] if isinstance(raw, dict) else raw
for entity in entity_list:
label_counts[entity["label"]] += 1
@@ -152,7 +159,7 @@
# %%
source_counts = Counter()
-for raw in df["_detected_entities"]:
+for raw in final_entities:
entity_list = raw["entities"] if isinstance(raw, dict) else raw
for entity in entity_list:
source_counts[entity.get("source", "unknown")] += 1
@@ -168,7 +175,7 @@
# %%
row_idx = 0
-raw_bv = df.loc[row_idx, "_entities_by_value"]
+raw_bv = trace_df.loc[row_idx, "_entities_by_value"]
by_value = raw_bv["entities_by_value"] if isinstance(raw_bv, dict) else raw_bv
print(f"Record {row_idx}: {len(by_value)} unique entity values\n")
diff --git a/docs/notebook_source/03_choosing_a_replacement_strategy.py b/docs/notebook_source/03_choosing_a_replacement_strategy.py
index aef23a4f..9095fccc 100644
--- a/docs/notebook_source/03_choosing_a_replacement_strategy.py
+++ b/docs/notebook_source/03_choosing_a_replacement_strategy.py
@@ -1,6 +1,3 @@
-# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0
-
# ---
# jupyter:
# jupytext:
@@ -15,6 +12,10 @@
# ---
# %% [markdown]
+#
# # 🕵️ Choosing a Replacement Strategy
#
# Four [replace mode](../../concepts/replace/) strategies compared side-by-side on the same data.
@@ -25,6 +26,7 @@
# | **Redact** | Label-based markers (`[REDACTED_FIRST_NAME]`) |
# | **Annotate** | Tags entities but keeps original text |
# | **Hash** | Deterministic hash digest |
+#
# #### 📚 What you'll learn
#
# - Compare **Redact**, **Annotate**, **Hash**, and **Substitute** on the same input
diff --git a/docs/notebook_source/04_rewriting_biographies.py b/docs/notebook_source/04_rewriting_biographies.py
index 9a961a3d..2199678d 100644
--- a/docs/notebook_source/04_rewriting_biographies.py
+++ b/docs/notebook_source/04_rewriting_biographies.py
@@ -1,6 +1,3 @@
-# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0
-
# ---
# jupyter:
# jupytext:
@@ -15,16 +12,22 @@
# ---
# %% [markdown]
+#
# # 🕵️ Rewriting Biographies
#
# Instead of replacing entities with tokens, rewrite mode generates a
-# privacy-safe transformation of the entire text. The pipeline:
+# privacy-safe transformation of the entire text. The `run()` / `preview()` pipeline:
#
# 1. Detects entities (same as replace mode, plus latent entity detection)
# 2. Classifies the domain and assigns sensitivity dispositions
# 3. Generates a rewritten version that obscures sensitive entities
# 4. Evaluates quality (utility) and privacy (leakage) with an automated repair loop
-# 5. Runs a final optional LLM judge for informational scores
+#
+# Afterward, a separate optional `evaluate()` call runs LLM judges for
+# detection validity and holistic privacy, quality, and style scores.
#
#
# #### 📚 What you'll learn
@@ -103,6 +106,8 @@
protect="All direct identifiers and quasi-identifier combinations (names, locations, employers, dates)",
preserve="Career trajectory, educational background, and professional accomplishments",
),
+ risk_tolerance="low",
+ max_repair_iterations=3,
),
)
@@ -125,6 +130,11 @@
preview.display_record(1)
# %% [markdown]
+# > **How to interpret leakage:** Leakage is measured against the sensitivity
+# > disposition. Details marked `leave_as_is` may remain without increasing
+# > `leakage_mass`. If an output retains something you expected the privacy goal
+# > to protect, inspect the Entity Disposition table.
+#
# ## 🚀 Full run
#
# - `result.dataframe` has user-facing columns: rewritten text, scores, and the review flag.
@@ -145,6 +155,8 @@
# ## 🚩 Filter by review flag
#
# - Records where automated metrics exceed thresholds are flagged for manual review.
+# - `needs_human_review` is threshold-based, so a record can have small nonzero
+# leakage without being flagged.
# - Use this to prioritize human attention on the records that need it most.
# - See [Working with flagged records](../../concepts/rewrite/#working-with-flagged-records)
# for guidance on diagnosing and resolving flagged records.
@@ -159,6 +171,9 @@
# ## 🔬 Evaluate (optional)
#
# Call `evaluate()` to run LLM-as-judge scoring on the rewrite result — detection validity and three quality rubrics (privacy, quality, style).
+# Evaluation makes additional LLM calls per record. For larger datasets, evaluate
+# a preview first; this tutorial evaluates all 25 rows to demonstrate the complete workflow.
+# This holistic judge is independent of pipeline leakage scoring, so their assessments may differ.
# See [Evaluation](../../concepts/evaluation/#rewrite-evaluation) for details.
# %%
diff --git a/docs/notebook_source/05_rewriting_legal_documents.py b/docs/notebook_source/05_rewriting_legal_documents.py
index d75d790a..a2354af8 100644
--- a/docs/notebook_source/05_rewriting_legal_documents.py
+++ b/docs/notebook_source/05_rewriting_legal_documents.py
@@ -1,6 +1,3 @@
-# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0
-
# ---
# jupyter:
# jupytext:
@@ -15,6 +12,10 @@
# ---
# %% [markdown]
+#
# # 🕵️ Rewriting Legal Documents
#
# Rewriting legal text (TAB dataset) with a domain-specific privacy goal
@@ -115,6 +116,8 @@
# ## 🎛️ Configure
#
# - `Detect(entity_labels=...)` overrides the default entity set with legal-specific labels.
+# The explicit list is a strict allowlist for both detection and LLM augmentation:
+# labels not included here are filtered out, so include every entity type you need.
# - `PrivacyGoal` tells the rewriter what to **protect** (identifiers, case numbers,
# institutional references) and what to **preserve** (legal reasoning, statutory references,
# ruling structure).
@@ -153,9 +156,16 @@
preview.display_record(1)
# %% [markdown]
+# > **How to interpret leakage:** Leakage is measured against the sensitivity
+# > disposition. Details marked `leave_as_is` may remain without increasing
+# > `leakage_mass`. If an output retains something you expected the privacy goal
+# > to protect, inspect the Entity Disposition table.
+#
# ## 🚀 Full run
#
# - `result.dataframe` has user-facing columns: rewritten text, scores, and the review flag.
+# - This notebook uses `risk_tolerance="minimal"`, which applies stricter repair
+# and review thresholds than notebook 04.
# %%
result = anonymizer.run(config=config, data=input_data)
@@ -169,6 +179,8 @@
# ## 🚩 Filter by review flag
#
# - Records where automated metrics exceed thresholds are flagged for manual review.
+# - The repair loop stops after `max_repair_iterations`; records that still need
+# repair remain flagged for human review but are not pipeline failures.
# - Use this to prioritize human attention on the records that need it most.
# - See [Working with flagged records](../../concepts/rewrite/#working-with-flagged-records)
# for guidance on diagnosing and resolving flagged records.
@@ -183,6 +195,9 @@
# ## 🔬 Evaluate (optional)
#
# Call `evaluate()` to run LLM-as-judge scoring on the rewrite result — detection validity and three quality rubrics (privacy, quality, style).
+# Evaluation makes additional LLM calls per record. For larger datasets, evaluate
+# a preview first; this tutorial evaluates all 25 rows to demonstrate the complete workflow.
+# This holistic judge is independent of pipeline leakage scoring, so their assessments may differ.
# See [Evaluation](../../concepts/evaluation/#rewrite-evaluation) for details.
# %%
diff --git a/docs/notebooks/01_your_first_anonymization.ipynb b/docs/notebooks/01_your_first_anonymization.ipynb
index 8c8004ca..2ac6dcf0 100644
--- a/docs/notebooks/01_your_first_anonymization.ipynb
+++ b/docs/notebooks/01_your_first_anonymization.ipynb
@@ -1,47 +1,20 @@
{
"cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "id": "81e3af42",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-05-19T20:13:44.721521Z",
- "iopub.status.busy": "2026-05-19T20:13:44.721435Z",
- "iopub.status.idle": "2026-05-19T20:13:44.724942Z",
- "shell.execute_reply": "2026-05-19T20:13:44.724759Z"
- }
- },
- "outputs": [],
- "source": [
- "# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n",
- "# SPDX-License-Identifier: Apache-2.0\n",
- "\n",
- "# ---\n",
- "# jupyter:\n",
- "# jupytext:\n",
- "# text_representation:\n",
- "# extension: .py\n",
- "# format_name: percent\n",
- "# format_version: '1.3'\n",
- "# kernelspec:\n",
- "# display_name: Python 3\n",
- "# language: python\n",
- "# name: python3\n",
- "# ---"
- ]
- },
{
"cell_type": "markdown",
- "id": "8650bc79",
+ "id": "613a67fc",
"metadata": {},
"source": [
- "# \ud83d\udd75\ufe0f Your First Anonymization\n",
+ "\n",
+ "# 🕵️ Your First Anonymization\n",
"\n",
"Detect sensitive entities and replace them with LLM-generated substitutes --\n",
"the simplest end-to-end example of Anonymizer.\n",
"\n",
- "#### \ud83d\udcda What you'll learn\n",
+ "#### 📚 What you'll learn\n",
"\n",
"- Load a CSV dataset and configure Anonymizer in a few lines\n",
"- Preview anonymized results on a small sample before committing to a full run\n",
@@ -54,10 +27,10 @@
},
{
"cell_type": "markdown",
- "id": "b2466e59",
+ "id": "3a4fa002",
"metadata": {},
"source": [
- "## \u2699\ufe0f Setup\n",
+ "## ⚙️ Setup\n",
"\n",
"- Check if your `NVIDIA_API_KEY` from [build.nvidia.com](https://build.nvidia.com) is registered for model access.\n",
" - The default `build.nvidia.com` (NVIDIA Build) setup is a convenient way to try Anonymizer and iterate on previews. Use of NVIDIA Build is subject to NVIDIA Build's own terms of service and privacy practices, which are separate from and independent of the NeMo Framework library. NVIDIA Build is intended for evaluation and testing purposes only and may not be used in production environments. Do not upload any confidential information or personal data when using NVIDIA Build. Your use of NVIDIA Build is logged for security purposes and to improve NVIDIA products and services.\n",
@@ -70,13 +43,13 @@
{
"cell_type": "code",
"execution_count": 2,
- "id": "50ae3123",
+ "id": "fbf6447d",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:13:44.726216Z",
- "iopub.status.busy": "2026-05-19T20:13:44.726138Z",
- "iopub.status.idle": "2026-05-19T20:13:44.730543Z",
- "shell.execute_reply": "2026-05-19T20:13:44.730304Z"
+ "iopub.execute_input": "2026-07-13T15:59:16.717835Z",
+ "iopub.status.busy": "2026-07-13T15:59:16.717720Z",
+ "iopub.status.idle": "2026-07-13T15:59:16.720198Z",
+ "shell.execute_reply": "2026-07-13T15:59:16.719800Z"
}
},
"outputs": [],
@@ -93,14 +66,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "id": "6afc9d91",
+ "execution_count": 3,
+ "id": "ec575508",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:13:44.731760Z",
- "iopub.status.busy": "2026-05-19T20:13:44.731681Z",
- "iopub.status.idle": "2026-05-19T20:13:46.433632Z",
- "shell.execute_reply": "2026-05-19T20:13:46.433359Z"
+ "iopub.execute_input": "2026-07-13T15:59:16.722073Z",
+ "iopub.status.busy": "2026-07-13T15:59:16.721882Z",
+ "iopub.status.idle": "2026-07-13T15:59:16.724707Z",
+ "shell.execute_reply": "2026-07-13T15:59:16.724381Z"
}
},
"outputs": [],
@@ -113,13 +86,13 @@
{
"cell_type": "code",
"execution_count": 4,
- "id": "dde4de1b",
+ "id": "cebcb5f6",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:13:46.434938Z",
- "iopub.status.busy": "2026-05-19T20:13:46.434815Z",
- "iopub.status.idle": "2026-05-19T20:13:46.447149Z",
- "shell.execute_reply": "2026-05-19T20:13:46.446991Z"
+ "iopub.execute_input": "2026-07-13T15:59:16.726293Z",
+ "iopub.status.busy": "2026-07-13T15:59:16.726172Z",
+ "iopub.status.idle": "2026-07-13T15:59:16.740990Z",
+ "shell.execute_reply": "2026-07-13T15:59:16.740720Z"
}
},
"outputs": [
@@ -127,28 +100,28 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:13:46] [INFO] \ud83d\udd27 Anonymizer initialized with 3 model configs\n"
+ "[10:59:16] [INFO] 🔧 Anonymizer initialized with 3 model configs\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:13:46] [INFO] |-- \ud83d\udd0e detector: gliner-pii-detector\n"
+ "[10:59:16] [INFO] |-- 🔎 detector: gliner-pii-detector\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:13:46] [INFO] |-- \u2705 validator: gpt-oss-120b\n"
+ "[10:59:16] [INFO] |-- ✅ validator: gpt-oss-120b\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:13:46] [INFO] |-- \ud83e\udde9 augmenter: gpt-oss-120b\n"
+ "[10:59:16] [INFO] |-- 🧩 augmenter: gpt-oss-120b\n"
]
}
],
@@ -158,10 +131,10 @@
},
{
"cell_type": "markdown",
- "id": "89072886",
+ "id": "166afbad",
"metadata": {},
"source": [
- "## \ud83d\udce6 Load data and configure\n",
+ "## 📦 Load data and configure\n",
"\n",
"- `AnonymizerInput` points to your CSV and names the text column. `data_summary`\n",
" gives the LLM context about the kind of text it will process.\n",
@@ -173,13 +146,13 @@
{
"cell_type": "code",
"execution_count": 5,
- "id": "51b69933",
+ "id": "4dbfad73",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:13:46.448114Z",
- "iopub.status.busy": "2026-05-19T20:13:46.448058Z",
- "iopub.status.idle": "2026-05-19T20:13:46.449524Z",
- "shell.execute_reply": "2026-05-19T20:13:46.449361Z"
+ "iopub.execute_input": "2026-07-13T15:59:16.742434Z",
+ "iopub.status.busy": "2026-07-13T15:59:16.742329Z",
+ "iopub.status.idle": "2026-07-13T15:59:16.744372Z",
+ "shell.execute_reply": "2026-07-13T15:59:16.744109Z"
}
},
"outputs": [],
@@ -195,10 +168,10 @@
},
{
"cell_type": "markdown",
- "id": "d7fac15c",
+ "id": "d612ed0e",
"metadata": {},
"source": [
- "## \ud83d\udc41\ufe0f Preview\n",
+ "## 👁️ Preview\n",
"\n",
"- `preview()` runs on a small sample so you can iterate quickly.\n",
"- Always preview before processing the full dataset -- it's the fastest way\n",
@@ -208,13 +181,13 @@
{
"cell_type": "code",
"execution_count": 6,
- "id": "2d0a5bf0",
+ "id": "35e8e2c7",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:13:46.450477Z",
- "iopub.status.busy": "2026-05-19T20:13:46.450419Z",
- "iopub.status.idle": "2026-05-19T20:15:14.792646Z",
- "shell.execute_reply": "2026-05-19T20:15:14.792335Z"
+ "iopub.execute_input": "2026-07-13T15:59:16.745790Z",
+ "iopub.status.busy": "2026-07-13T15:59:16.745675Z",
+ "iopub.status.idle": "2026-07-13T16:00:55.092795Z",
+ "shell.execute_reply": "2026-07-13T16:00:55.092177Z"
}
},
"outputs": [
@@ -222,56 +195,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:13:46] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[10:59:17] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:13:46] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[10:59:17] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:13:46] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[10:59:17] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:14:17] [INFO] |-- \ud83d\udccb Detection complete \u2014 80 entities found across 3 records (0 failed) [30.6s]\n"
+ "[11:00:13] [INFO] |-- 📋 Detection complete — 77 entities found across 3 records (0 failed) [56.4s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:14:17] [INFO] |-- labels: first_name=23, state=6, organization_name=6, age=5, occupation=5, city=5, company_name=4, last_name=3, race_ethnicity=3, language=3, political_view=3, education_level=3, field_of_study=2, religious_belief=2, street_address=2, degree=1, university=1, place_name=1, date_of_birth=1, employment_status=1\n"
+ "[11:00:13] [INFO] |-- labels: first_name=22, organization_name=7, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, political_view=4, last_name=3, race_ethnicity=3, language=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1, religious_belief=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:14:17] [INFO] \ud83d\udd04 Running Substitute replacement\n"
+ "[11:00:13] [INFO] 🔄 Running Substitute replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:15:14] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [57.4s]\n"
+ "[11:00:54] [INFO] |-- 📋 Replacement complete (0 failed) [40.9s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:15:14] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:00:54] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
}
],
@@ -281,10 +254,10 @@
},
{
"cell_type": "markdown",
- "id": "c404d7f6",
+ "id": "9c88ca80",
"metadata": {},
"source": [
- "## \ud83d\udd0d Inspect\n",
+ "## 🔍 Inspect\n",
"\n",
"- `display_record()` shows the original text with highlighted entities,\n",
" the replacement map, and the anonymized output -- all in one view.\n",
@@ -294,13 +267,13 @@
{
"cell_type": "code",
"execution_count": 7,
- "id": "75c164c2",
+ "id": "a8ab2a19",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:15:14.794423Z",
- "iopub.status.busy": "2026-05-19T20:15:14.794340Z",
- "iopub.status.idle": "2026-05-19T20:15:14.797657Z",
- "shell.execute_reply": "2026-05-19T20:15:14.797420Z"
+ "iopub.execute_input": "2026-07-13T16:00:55.095951Z",
+ "iopub.status.busy": "2026-07-13T16:00:55.095780Z",
+ "iopub.status.idle": "2026-07-13T16:00:55.101640Z",
+ "shell.execute_reply": "2026-07-13T16:00:55.101274Z"
}
},
"outputs": [
@@ -315,19 +288,23 @@
"
\n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| degree at the
University of Colorado Boulder| university, where he also completed a research stint in
wildlife health| field_of_study. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria| first_name and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria and Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
Ethan| first_name Henderson| last_name, a
45| age\u2011year\u2011old
Vietnamese| race_ethnicity marine biologist| occupation living in
Portland| city,
Oregon| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Lincoln High| organization_name, he earned his
Ph.D.| degree at the
University of Oregon| university, where he also completed a research stint in
marine ecology| field_of_study. Fluent in
Spanish| language,
Ethan| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Ethan| first_name Kline| last_name, a 45| age‑year‑old Filipino| race_ethnicity zoological researcher| occupation living in Portland| city, Oregon| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Lincoln High| organization_name, he earned his Master of Veterinary Science| degree at the Oregon State University| university, where he also completed a research stint in conservation genetics| field_of_study. Fluent in Spanish| language, Ethan| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Ethan| first_name has worked at PetCare Medical Center| company_name and later at the Oregon Animal Wellness Center| organization_name, where he now leads a busy mixed\u2011practice team. He identifies as a Libertarian| political_view and often volunteers at local shelters, a habit encouraged by his wife, Leah| first_name, and their two teenage children, Sofia| first_name and Noah| first_name. Outside the clinic, Ethan| first_name enjoys hiking the Cascade Range| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Ethan| first_name has worked at
Pacific Veterinary Group| organization_name and later at the
Oregon Animal Care Center| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Green Party| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Leah| first_name, and their two teenage children,
Sofia and Mateo| first_name. Outside the clinic,
Ethan| first_name enjoys hiking the
Cascade Range| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| 40 | age | 45 |
| Aria | first_name | Sofia |
| Bobby | first_name | Ethan |
| Christian Democrat | political_view | Libertarian |
| Colorado | state | Oregon |
| Colorado Veterinary Clinic | organization_name | Oregon Animal Wellness Center |
| DVM | degree | Ph.D. |
| Denver | city | Portland |
| English | language | Spanish |
| Jefferson High | organization_name | Lincoln High |
| Leo | first_name | Noah |
| Maya | first_name | Leah |
| Mexican | race_ethnicity | Vietnamese |
| Rockies | place_name | Cascade Range |
| University of Colorado Boulder | university | University of Oregon |
| VCA Animal Hospital | company_name | PetCare Medical Center |
| Watford | last_name | Henderson |
| veterinarian | occupation | marine biologist |
| wildlife health | field_of_study | marine ecology |
\n",
+ "
| Original | Label | Replacement |
|---|
| 40 | age | 45 |
| Aria and Leo | first_name | Sofia and Mateo |
| Bobby | first_name | Ethan |
| Christian Democrat | political_view | Green Party |
| Colorado | state | Oregon |
| Colorado Veterinary Clinic | organization_name | Oregon Animal Care Center |
| DVM | degree | Master of Veterinary Science |
| Denver | city | Portland |
| English | language | Spanish |
| Jefferson High | organization_name | Lincoln High |
| Maya | first_name | Leah |
| Mexican | race_ethnicity | Filipino |
| Rockies | place_name | Cascade Range |
| University of Colorado Boulder | university | Oregon State University |
| VCA Animal Hospital | organization_name | Pacific Veterinary Group |
| Watford | last_name | Kline |
| veterinarian | occupation | zoological researcher |
| wildlife health | field_of_study | conservation genetics |
\n",
"
\n",
"
\n",
" \n",
@@ -348,13 +325,13 @@
{
"cell_type": "code",
"execution_count": 8,
- "id": "27b96466",
+ "id": "89112998",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:15:14.798612Z",
- "iopub.status.busy": "2026-05-19T20:15:14.798543Z",
- "iopub.status.idle": "2026-05-19T20:15:14.800530Z",
- "shell.execute_reply": "2026-05-19T20:15:14.800327Z"
+ "iopub.execute_input": "2026-07-13T16:00:55.103380Z",
+ "iopub.status.busy": "2026-07-13T16:00:55.103263Z",
+ "iopub.status.idle": "2026-07-13T16:00:55.106440Z",
+ "shell.execute_reply": "2026-07-13T16:00:55.106133Z"
}
},
"outputs": [
@@ -369,19 +346,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Idilio| first_name Bell| last_name is a
37| age\u2011year\u2011old
astronomer| occupation living in
Edison| city,
New Jersey| state. Born on
November\u202f21,\u202f1988| date_of_birth, he grew up in a bilingual
Italian| race_ethnicity household and speaks
English| language at home and work. He earned his
bachelor\u2019s degree| education_level in physics| field_of_study from the University of
New\u202fJersey| state and later completed a
PhD in astrophysics| education_level at
Princeton| city, where his dissertation focused on exoplanet atmospheres. After graduation he spent three years at
NASA| organization_name\u2019s
Goddard Space Flight Center| organization_name before joining
SpaceX| organization_name\u2019s research division, where he now leads a team analyzing data from the
Starlink| organization_name telescope array.
Idilio| first_name describes himself as
secular| religious_belief and leans
progressive| political_view on most political issues, often volunteering for science outreach programs in his community.\n",
+ "
Idilio| first_name Bell| last_name is a 37| age‑year‑old astronomer| occupation living in Edison| city, New Jersey| state. Born on November 21, 1988| date_of_birth, he grew up in a bilingual Italian| race_ethnicity household and speaks English| language at home and work. He earned his bachelor’s degree| degree in physics| field_of_study from the University of New Jersey| university and later completed a PhD| degree in astrophysics| field_of_study at Princeton| university, where his dissertation focused on exoplanet atmospheres. After graduation he spent three years at NASA’s Goddard Space Flight Center| organization_name before joining SpaceX| organization_name’s research division, where he now leads a team analyzing data from the Starlink telescope array. Idilio| first_name describes himself as secular| political_view and leans progressive| political_view on most political issues, often volunteering for science outreach programs in his community.\n",
"\n",
- "Outside the lab, Idilio| first_name shares a modest house on West Roberts Drive| street_address with his wife, Maya| first_name, and their two young daughters, Lina| first_name and Zara| first_name. His mother, Elena| first_name, lives nearby and still cooks the family\u2019s favorite pasta on Sundays, while his father, Marco| first_name, retired| employment_status from an engineering firm| company_name in New\u202fYork| state. Family gatherings are a mix of lively conversation and stargazing sessions on the backyard deck, where Idilio| first_name points out constellations and tells stories of the cosmos that inspire his children\u2019s curiosity.
\n",
+ "Outside the lab,
Idilio| first_name shares a modest house on
West Roberts Drive| street_address with his wife,
Maya| first_name, and their two young daughters,
Lina| first_name and
Zara| first_name. His mother,
Elena| first_name, lives nearby and still cooks the family’s favorite pasta on Sundays, while his father,
Marco| first_name,
retired| employment_status from an engineering firm in
New York| state. Family gatherings are a mix of lively conversation and stargazing sessions on the backyard deck, where
Idilio| first_name points out constellations and tells stories of the cosmos that inspire his children’s curiosity.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
Santiago| first_name Kumar| last_name is a
36| age\u2011year\u2011old
geophysicist| occupation living in
Austin| city,
Texas| state. Born on
July 5, 1989| date_of_birth, he grew up in a bilingual
Greek| race_ethnicity household and speaks
Spanish| language at home and work. He earned his
associate\u2019s degree| education_level in chemistry| field_of_study from the University of
Oregon| state and later completed a
master\u2019s degree in planetary geology| education_level at
Portland| city, where his dissertation focused on exoplanet atmospheres. After graduation he spent three years at
European Space Agency| organization_name\u2019s
National Renewable Energy Laboratory| organization_name before joining
Blue Origin| organization_name\u2019s research division, where he now leads a team analyzing data from the
OneWeb| organization_name telescope array.
Santiago| first_name describes himself as
agnostic| religious_belief and leans
centrist| political_view on most political issues, often volunteering for science outreach programs in his community.\n",
+ "
Dario| first_name Hawthorne| last_name is a 36| age‑year‑old geologist| occupation living in Boulder| city, Colorado| state. Born on April 3, 1990| date_of_birth, he grew up in a bilingual Greek| race_ethnicity household and speaks Spanish| language at home and work. He earned his Associate’s degree| degree in chemistry| field_of_study from the University of Colorado| university and later completed a Doctor of Medicine| degree in planetary science| field_of_study at University of Chicago| university, where his dissertation focused on exoplanet atmospheres. After graduation he spent three years at European Space Agency’s ESTEC| organization_name before joining Blue Origin| organization_name’s research division, where he now leads a team analyzing data from the Starlink telescope array. Dario| first_name describes himself as agnostic| political_view and leans centrist| political_view on most political issues, often volunteering for science outreach programs in his community.\n",
"\n",
- "Outside the lab, Santiago| first_name shares a modest house on North Willow Lane| street_address with his wife, Priya| first_name, and their two young daughters, Aisha| first_name and Nadia| first_name. His mother, Sofia| first_name, lives nearby and still cooks the family\u2019s favorite pasta on Sundays, while his father, Diego| first_name, part-time| employment_status from an architectural studio| company_name in Florida| state. Family gatherings are a mix of lively conversation and stargazing sessions on the backyard deck, where Santiago| first_name points out constellations and tells stories of the cosmos that inspire his children\u2019s curiosity.
\n",
+ "Outside the lab,
Dario| first_name shares a modest house on
East Maple Avenue| street_address with his wife,
Isabel| first_name, and their two young daughters,
Mia| first_name and
Nina| first_name. His mother,
Sofia| first_name, lives nearby and still cooks the family’s favorite pasta on Sundays, while his father,
Antonio| first_name,
on sabbatical| employment_status from an engineering firm in
Oregon| state. Family gatherings are a mix of lively conversation and stargazing sessions on the backyard deck, where
Dario| first_name points out constellations and tells stories of the cosmos that inspire his children’s curiosity.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| 37 | age | 36 |
| Bell | last_name | Kumar |
| Edison | city | Austin |
| Elena | first_name | Sofia |
| English | language | Spanish |
| Goddard Space Flight Center | organization_name | National Renewable Energy Laboratory |
| Idilio | first_name | Santiago |
| Italian | race_ethnicity | Greek |
| Lina | first_name | Aisha |
| Marco | first_name | Diego |
| Maya | first_name | Priya |
| NASA | organization_name | European Space Agency |
| New Jersey | state | Texas |
| New\u202fJersey | state | Oregon |
| New\u202fYork | state | Florida |
| November\u202f21,\u202f1988 | date_of_birth | July 5, 1989 |
| PhD in astrophysics | education_level | master\u2019s degree in planetary geology |
| Princeton | city | Portland |
| SpaceX | organization_name | Blue Origin |
| Starlink | organization_name | OneWeb |
| West Roberts Drive | street_address | North Willow Lane |
| Zara | first_name | Nadia |
| astronomer | occupation | geophysicist |
| bachelor\u2019s degree | education_level | associate\u2019s degree |
| engineering firm | company_name | architectural studio |
| in physics | field_of_study | in chemistry |
| progressive | political_view | centrist |
| retired | employment_status | part-time |
| secular | religious_belief | agnostic |
\n",
+ "
| Original | Label | Replacement |
|---|
| 37 | age | 36 |
| Bell | last_name | Hawthorne |
| Edison | city | Boulder |
| Elena | first_name | Sofia |
| English | language | Spanish |
| Idilio | first_name | Dario |
| Italian | race_ethnicity | Greek |
| Lina | first_name | Mia |
| Marco | first_name | Antonio |
| Maya | first_name | Isabel |
| NASA’s Goddard Space Flight Center | organization_name | European Space Agency’s ESTEC |
| New Jersey | state | Colorado |
| New York | state | Oregon |
| November 21, 1988 | date_of_birth | April 3, 1990 |
| PhD | degree | Doctor of Medicine |
| Princeton | university | University of Chicago |
| SpaceX | organization_name | Blue Origin |
| University of New Jersey | university | University of Colorado |
| West Roberts Drive | street_address | East Maple Avenue |
| Zara | first_name | Nina |
| astronomer | occupation | geologist |
| bachelor’s degree | degree | Associate’s degree |
| in astrophysics | field_of_study | in planetary science |
| in physics | field_of_study | in chemistry |
| progressive | political_view | centrist |
| retired | employment_status | on sabbatical |
| secular | political_view | agnostic |
\n",
"
\n",
"
\n",
" \n",
@@ -402,13 +383,13 @@
{
"cell_type": "code",
"execution_count": 9,
- "id": "a4ecf192",
+ "id": "9b90a2f3",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:15:14.801448Z",
- "iopub.status.busy": "2026-05-19T20:15:14.801390Z",
- "iopub.status.idle": "2026-05-19T20:15:14.810652Z",
- "shell.execute_reply": "2026-05-19T20:15:14.810406Z"
+ "iopub.execute_input": "2026-07-13T16:00:55.107881Z",
+ "iopub.status.busy": "2026-07-13T16:00:55.107775Z",
+ "iopub.status.idle": "2026-07-13T16:00:55.135661Z",
+ "shell.execute_reply": "2026-07-13T16:00:55.135367Z"
}
},
"outputs": [
@@ -442,49 +423,36 @@
" \n",
" \n",
" | 0 | \n",
- " Bobby Watford, a 40\u2011year\u2011old Mexican veterinar... | \n",
+ " Bobby Watford, a 40‑year‑old Mexican veterinar... | \n",
" <first_name>Bobby</first_name> <last_name>Watf... | \n",
" {'entities': [{'end_position': 5, 'id': 'first... | \n",
- " Ethan Henderson, a 45\u2011year\u2011old Vietnamese mari... | \n",
+ " Ethan Kline, a 45‑year‑old Filipino zoological... | \n",
"
\n",
" \n",
" | 1 | \n",
- " Idilio Bell is a 37\u2011year\u2011old astronomer living... | \n",
+ " Idilio Bell is a 37‑year‑old astronomer living... | \n",
" <first_name>Idilio</first_name> <last_name>Bel... | \n",
" {'entities': [{'end_position': 6, 'id': 'first... | \n",
- " Santiago Kumar is a 36\u2011year\u2011old geophysicist l... | \n",
+ " Dario Hawthorne is a 36‑year‑old geologist liv... | \n",
"
\n",
" \n",
" | 2 | \n",
- " Jodi Allison,\u202f36, lives at 204\u202fBluegrass in Cl... | \n",
+ " Jodi Allison, 36, lives at 204 Bluegrass in Cl... | \n",
" <first_name>Jodi</first_name> <last_name>Allis... | \n",
" {'entities': [{'end_position': 4, 'id': 'first... | \n",
- " Sofia Keller,\u202f42, lives at 587\u202fMaple in Macon,... | \n",
+ " Tara Harper, 42, lives at 317 Riverbend in Cha... | \n",
"
\n",
" \n",
"\n",
""
],
"text/plain": [
- " biography \\\n",
- "0 Bobby Watford, a 40\u2011year\u2011old Mexican veterinar... \n",
- "1 Idilio Bell is a 37\u2011year\u2011old astronomer living... \n",
- "2 Jodi Allison,\u202f36, lives at 204\u202fBluegrass in Cl... \n",
+ " biography ... biography_replaced\n",
+ "0 Bobby Watford, a 40‑year‑old Mexican veterinar... ... Ethan Kline, a 45‑year‑old Filipino zoological...\n",
+ "1 Idilio Bell is a 37‑year‑old astronomer living... ... Dario Hawthorne is a 36‑year‑old geologist liv...\n",
+ "2 Jodi Allison, 36, lives at 204 Bluegrass in Cl... ... Tara Harper, 42, lives at 317 Riverbend in Cha...\n",
"\n",
- " biography_with_spans \\\n",
- "0 Bobby Watf... \n",
- "1 Idilio Bel... \n",
- "2 Jodi Allis... \n",
- "\n",
- " final_entities \\\n",
- "0 {'entities': [{'end_position': 5, 'id': 'first... \n",
- "1 {'entities': [{'end_position': 6, 'id': 'first... \n",
- "2 {'entities': [{'end_position': 4, 'id': 'first... \n",
- "\n",
- " biography_replaced \n",
- "0 Ethan Henderson, a 45\u2011year\u2011old Vietnamese mari... \n",
- "1 Santiago Kumar is a 36\u2011year\u2011old geophysicist l... \n",
- "2 Sofia Keller,\u202f42, lives at 587\u202fMaple in Macon,... "
+ "[3 rows x 4 columns]"
]
},
"execution_count": 9,
@@ -498,10 +466,10 @@
},
{
"cell_type": "markdown",
- "id": "8e4d2b0e",
+ "id": "c14bb950",
"metadata": {},
"source": [
- "## \ud83d\ude80 Full run\n",
+ "## 🚀 Full run\n",
"\n",
"- `run()` processes the entire dataset with the same config you previewed.\n",
"- Access the output via `result.dataframe`."
@@ -510,13 +478,13 @@
{
"cell_type": "code",
"execution_count": 10,
- "id": "74655558",
+ "id": "aa7b69df",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:15:14.811561Z",
- "iopub.status.busy": "2026-05-19T20:15:14.811504Z",
- "iopub.status.idle": "2026-05-19T20:16:35.900726Z",
- "shell.execute_reply": "2026-05-19T20:16:35.900397Z"
+ "iopub.execute_input": "2026-07-13T16:00:55.137827Z",
+ "iopub.status.busy": "2026-07-13T16:00:55.137721Z",
+ "iopub.status.idle": "2026-07-13T16:04:40.756501Z",
+ "shell.execute_reply": "2026-07-13T16:04:40.755403Z"
}
},
"outputs": [
@@ -524,63 +492,63 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:15:14] [INFO] \ud83d\udcc2 Loaded 25 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:00:55] [INFO] 📂 Loaded 25 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:15:14] [INFO] \ud83d\udd0d Running entity detection on 25 records\n"
+ "[11:00:55] [INFO] 🔍 Running entity detection on 25 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:15:14] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:00:55] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:05] [INFO] |-- \ud83d\udccb Detection complete \u2014 648 entities found across 25 records (0 failed) [50.3s]\n"
+ "[11:03:15] [INFO] |-- 📋 Detection complete — 661 entities found across 25 records (0 failed) [139.8s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:05] [INFO] |-- labels: first_name=152, city=48, occupation=45, company_name=40, education_level=33, race_ethnicity=31, state=30, organization_name=30, last_name=27, age=26, political_view=26, religious_belief=25, street_address=23, university=21, language=21, field_of_study=13, place_name=12, county=11, employment_status=10, date_of_birth=9, date=5, degree=4, school_name=1, landmark=1, journal_name=1, country=1, gender=1, postcode=1\n"
+ "[11:03:15] [INFO] |-- labels: first_name=152, organization_name=68, occupation=45, city=40, field_of_study=36, university=35, race_ethnicity=30, last_name=27, age=26, state=26, degree=26, political_view=25, religious_belief=25, street_address=23, language=18, place_name=12, employment_status=10, county=10, date_of_birth=9, education_level=6, date=5, company_name=3, landmark=1, country=1, gender=1, postcode=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:05] [INFO] \ud83d\udd04 Running Substitute replacement\n"
+ "[11:03:15] [INFO] 🔄 Running Substitute replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:35] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [30.5s]\n"
+ "[11:04:40] [INFO] |-- 📋 Replacement complete (0 failed) [85.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:35] [INFO] \ud83c\udf89 Pipeline complete \u2014 25 records processed, 0 total failures\n"
+ "[11:04:40] [INFO] 🎉 Pipeline complete — 25 records processed, 0 total failures\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
- "AnonymizerResult(rows=25, columns=4, trace_columns=21, failed_records=0)\n"
+ "AnonymizerResult(rows=25, columns=4, trace_columns=22, failed_records=0)\n"
]
}
],
@@ -592,13 +560,13 @@
{
"cell_type": "code",
"execution_count": 11,
- "id": "86e39a15",
+ "id": "22f95ed2",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:16:35.902426Z",
- "iopub.status.busy": "2026-05-19T20:16:35.902335Z",
- "iopub.status.idle": "2026-05-19T20:16:35.906835Z",
- "shell.execute_reply": "2026-05-19T20:16:35.906577Z"
+ "iopub.execute_input": "2026-07-13T16:04:40.760343Z",
+ "iopub.status.busy": "2026-07-13T16:04:40.760100Z",
+ "iopub.status.idle": "2026-07-13T16:04:40.774108Z",
+ "shell.execute_reply": "2026-07-13T16:04:40.773629Z"
}
},
"outputs": [
@@ -632,71 +600,52 @@
" \n",
" \n",
" | 0 | \n",
- " Bobby Watford, a 40\u2011year\u2011old Mexican veterinar... | \n",
+ " Bobby Watford, a 40‑year‑old Mexican veterinar... | \n",
" <first_name>Bobby</first_name> <last_name>Watf... | \n",
" {'entities': array([{'end_position': 5, 'id': ... | \n",
- " Ethan Hernandez, a 52\u2011year\u2011old Filipino zoolog... | \n",
+ " Ethan Hawkins, a 52‑year‑old Filipino zoologis... | \n",
"
\n",
" \n",
" | 1 | \n",
- " Idilio Bell is a 37\u2011year\u2011old astronomer living... | \n",
+ " Idilio Bell is a 37‑year‑old astronomer living... | \n",
" <first_name>Idilio</first_name> <last_name>Bel... | \n",
" {'entities': array([{'end_position': 6, 'id': ... | \n",
- " Rafael Khan is a 42\u2011year\u2011old planetary geologi... | \n",
+ " Ravi Khan is a 42‑year‑old geophysicist living... | \n",
"
\n",
" \n",
" | 2 | \n",
- " Jodi Allison,\u202f36, lives at 204\u202fBluegrass in Cl... | \n",
+ " Jodi Allison, 36, lives at 204 Bluegrass in Cl... | \n",
" <first_name>Jodi</first_name> <last_name>Allis... | \n",
" {'entities': array([{'end_position': 4, 'id': ... | \n",
- " Leah Harper,\u202f42, lives at 204 Willow in Eugene... | \n",
+ " Lena Keller, 42, lives at 317 Willowbrook in E... | \n",
"
\n",
" \n",
" | 3 | \n",
- " James Mills is a 69\u2011year\u2011old paramedic who liv... | \n",
+ " James Mills is a 69‑year‑old paramedic who liv... | \n",
" <first_name>James</first_name> <last_name>Mill... | \n",
" {'entities': array([{'end_position': 5, 'id': ... | \n",
- " Ethan Harper is a 71\u2011year\u2011old firefighter who ... | \n",
+ " Robert Harper is a 74‑year‑old firefighter who... | \n",
"
\n",
" \n",
" | 4 | \n",
- " Nancy Burton is a 21\u2011year\u2011old cashier who live... | \n",
+ " Nancy Burton is a 21‑year‑old cashier who live... | \n",
" <first_name>Nancy</first_name> <last_name>Burt... | \n",
" {'entities': array([{'end_position': 5, 'id': ... | \n",
- " Leah Hawkins is a 27\u2011year\u2011old stock clerk who ... | \n",
+ " Maya Keller is a 23‑year‑old stock clerk who l... | \n",
"
\n",
" \n",
"\n",
""
],
"text/plain": [
- " biography \\\n",
- "0 Bobby Watford, a 40\u2011year\u2011old Mexican veterinar... \n",
- "1 Idilio Bell is a 37\u2011year\u2011old astronomer living... \n",
- "2 Jodi Allison,\u202f36, lives at 204\u202fBluegrass in Cl... \n",
- "3 James Mills is a 69\u2011year\u2011old paramedic who liv... \n",
- "4 Nancy Burton is a 21\u2011year\u2011old cashier who live... \n",
- "\n",
- " biography_with_spans \\\n",
- "0 Bobby Watf... \n",
- "1 Idilio Bel... \n",
- "2 Jodi Allis... \n",
- "3 James Mill... \n",
- "4 Nancy Burt... \n",
+ " biography ... biography_replaced\n",
+ "0 Bobby Watford, a 40‑year‑old Mexican veterinar... ... Ethan Hawkins, a 52‑year‑old Filipino zoologis...\n",
+ "1 Idilio Bell is a 37‑year‑old astronomer living... ... Ravi Khan is a 42‑year‑old geophysicist living...\n",
+ "2 Jodi Allison, 36, lives at 204 Bluegrass in Cl... ... Lena Keller, 42, lives at 317 Willowbrook in E...\n",
+ "3 James Mills is a 69‑year‑old paramedic who liv... ... Robert Harper is a 74‑year‑old firefighter who...\n",
+ "4 Nancy Burton is a 21‑year‑old cashier who live... ... Maya Keller is a 23‑year‑old stock clerk who l...\n",
"\n",
- " final_entities \\\n",
- "0 {'entities': array([{'end_position': 5, 'id': ... \n",
- "1 {'entities': array([{'end_position': 6, 'id': ... \n",
- "2 {'entities': array([{'end_position': 4, 'id': ... \n",
- "3 {'entities': array([{'end_position': 5, 'id': ... \n",
- "4 {'entities': array([{'end_position': 5, 'id': ... \n",
- "\n",
- " biography_replaced \n",
- "0 Ethan Hernandez, a 52\u2011year\u2011old Filipino zoolog... \n",
- "1 Rafael Khan is a 42\u2011year\u2011old planetary geologi... \n",
- "2 Leah Harper,\u202f42, lives at 204 Willow in Eugene... \n",
- "3 Ethan Harper is a 71\u2011year\u2011old firefighter who ... \n",
- "4 Leah Hawkins is a 27\u2011year\u2011old stock clerk who ... "
+ "[5 rows x 4 columns]"
]
},
"execution_count": 11,
@@ -710,10 +659,10 @@
},
{
"cell_type": "markdown",
- "id": "563fb815",
+ "id": "f821776d",
"metadata": {},
"source": [
- "## \ud83d\udcca (Optional) Evaluate replacement quality\n",
+ "## 📊 (Optional) Evaluate replacement quality\n",
"\n",
"- `evaluate()` is a separate, opt-in step that scores the output with LLM-as-judge metrics.\n",
"- For Substitute, all four metrics run: **Detection Validity**, **Type Fidelity**, **Relational Consistency**, **Attribute Fidelity**.\n",
@@ -722,10 +671,58 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "id": "df6a871c",
- "metadata": {},
- "outputs": [],
+ "execution_count": 12,
+ "id": "797d36a2",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:04:40.776046Z",
+ "iopub.status.busy": "2026-07-13T16:04:40.775907Z",
+ "iopub.status.idle": "2026-07-13T16:05:40.485218Z",
+ "shell.execute_reply": "2026-07-13T16:05:40.484901Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Preview (record 0)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| organization_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
\n",
+ "
Replaced
\n",
+ "
Ethan| first_name Kline| last_name, a 45| age‑year‑old Filipino| race_ethnicity zoological researcher| occupation living in Portland| city, Oregon| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Lincoln High| organization_name, he earned his Master of Veterinary Science| degree at the Oregon State University| university, where he also completed a research stint in conservation genetics| field_of_study. Fluent in Spanish| language, Ethan| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Ethan| first_name has worked at Pacific Veterinary Group| organization_name and later at the Oregon Animal Care Center| organization_name, where he now leads a busy mixed‑practice team. He identifies as a Green Party| political_view and often volunteers at local shelters, a habit encouraged by his wife, Leah| first_name, and their two teenage children, Sofia and Mateo| first_name. Outside the clinic, Ethan| first_name enjoys hiking the Cascade Range| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
Detection Judge
Detection Validity: Partially Satisfied (LLM alignment score: 17/18)
LLM alignment score: The level of alignment between the detection and evaluation LLMs across entity classification, attributes, and relationships.
Show 1 flagged entity(ies)
| Value | Label | Reason |
|---|
| Aria and Leo | first_name | wrong_boundary: the span combines two separate first names and a conjunction, should be two distinct first_name entities. |
\n",
+ "
Type Fidelity
Type Fidelity: Satisfied (LLM alignment score: 18/18)
\n",
+ "
Attribute Fidelity
Attribute Fidelity: Satisfied (LLM alignment score: 4/4)
Show 4 evaluated entity(ies)
| Original | Label | Synthetic | Attributes | Status | Reason |
|---|
| 40 | age | 45 | age_bucket | Pass | Age bucket preserved (adult → middle‑aged, adjacent buckets). |
| Aria and Leo | first_name | Sofia and Mateo | gender | Pass | Both names keep the same genders (female → female, male → male). |
| Bobby | first_name | Ethan | gender | Pass | Male gender preserved. |
| Maya | first_name | Leah | gender | Pass | Female gender preserved. |
\n",
+ "
Relational Consistency
Relational Consistency: Satisfied (LLM alignment score: 8/8)
Show 8 checked relation(s)
| Relation | Entities | Status | Reason |
|---|
| city <-> state | Denver (city) -> Portland, Colorado (state) -> Oregon | Pass | Portland is a city in Oregon, preserving the geographic relation. |
| first_name <-> pronouns | Bobby (first_name) -> Ethan | Pass | The pronouns 'he/his' in the text match the male name Ethan. |
| occupation <-> organization_name (Pacific Veterinary Group) | veterinarian (occupation) -> zoological researcher, VCA Animal Hospital (organization_name) -> Pacific Veterinary Group | Pass | A zoological researcher can plausibly work at a veterinary group. |
| occupation <-> organization_name (Oregon Animal Care Center) | veterinarian (occupation) -> zoological researcher, Colorado Veterinary Clinic (organization_name) -> Oregon Animal Care Center | Pass | A zoological researcher can plausibly work at an animal care center. |
| occupation <-> degree | veterinarian (occupation) -> zoological researcher, DVM (degree) -> Master of Veterinary Science | Pass | A Master of Veterinary Science supports a role as a zoological researcher. |
| occupation <-> field_of_study | veterinarian (occupation) -> zoological researcher, wildlife health (field_of_study) -> conservation genetics | Pass | Conservation genetics aligns with a zoological researcher’s work. |
| age <-> occupation | 40 (age) -> 45, veterinarian (occupation) -> zoological researcher | Pass | A 45‑year‑old can reasonably be a zoological researcher. |
| age <-> degree | 40 (age) -> 45, DVM (degree) -> Master of Veterinary Science | Pass | A 45‑year‑old can hold a Master of Veterinary Science. |
\n",
+ "
\n",
+ "
Replacement Map
\n",
+ "
| Original | Label | Replacement |
|---|
| 40 | age | 45 |
| Aria and Leo | first_name | Sofia and Mateo |
| Bobby | first_name | Ethan |
| Christian Democrat | political_view | Green Party |
| Colorado | state | Oregon |
| Colorado Veterinary Clinic | organization_name | Oregon Animal Care Center |
| DVM | degree | Master of Veterinary Science |
| Denver | city | Portland |
| English | language | Spanish |
| Jefferson High | organization_name | Lincoln High |
| Maya | first_name | Leah |
| Mexican | race_ethnicity | Filipino |
| Rockies | place_name | Cascade Range |
| University of Colorado Boulder | university | Oregon State University |
| VCA Animal Hospital | organization_name | Pacific Veterinary Group |
| Watford | last_name | Kline |
| veterinarian | occupation | zoological researcher |
| wildlife health | field_of_study | conservation genetics |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"evaluated = anonymizer.evaluate(preview)\n",
"evaluated.display_record(0)"
@@ -733,16 +730,16 @@
},
{
"cell_type": "markdown",
- "id": "7699994a",
+ "id": "a4cf5e57",
"metadata": {},
"source": [
- "## \u23ed\ufe0f Next steps\n",
+ "## ⏭️ Next steps\n",
"\n",
- "- **[\ud83d\udd0d Inspecting Detected Entities](../02_inspecting_detected_entities/)** --\n",
+ "- **[🔍 Inspecting Detected Entities](../02_inspecting_detected_entities/)** --\n",
" dig into what the detection pipeline found and debug quality.\n",
- "- **[\ud83c\udfaf Choosing a Replacement Strategy](../03_choosing_a_replacement_strategy/)** --\n",
+ "- **[🎯 Choosing a Replacement Strategy](../03_choosing_a_replacement_strategy/)** --\n",
" compare Redact, Annotate, Hash, and Substitute side-by-side.\n",
- "- **[\u270f\ufe0f Rewriting Biographies](../04_rewriting_biographies/)** --\n",
+ "- **[✏️ Rewriting Biographies](../04_rewriting_biographies/)** --\n",
" generate privacy-safe paraphrases instead of token-level replacements."
]
}
diff --git a/docs/notebooks/02_inspecting_detected_entities.ipynb b/docs/notebooks/02_inspecting_detected_entities.ipynb
index 139a5674..c5b2569b 100644
--- a/docs/notebooks/02_inspecting_detected_entities.ipynb
+++ b/docs/notebooks/02_inspecting_detected_entities.ipynb
@@ -1,42 +1,15 @@
{
"cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "id": "d545552d",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-05-19T20:16:37.594213Z",
- "iopub.status.busy": "2026-05-19T20:16:37.594155Z",
- "iopub.status.idle": "2026-05-19T20:16:37.596738Z",
- "shell.execute_reply": "2026-05-19T20:16:37.596531Z"
- }
- },
- "outputs": [],
- "source": [
- "# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n",
- "# SPDX-License-Identifier: Apache-2.0\n",
- "\n",
- "# ---\n",
- "# jupyter:\n",
- "# jupytext:\n",
- "# text_representation:\n",
- "# extension: .py\n",
- "# format_name: percent\n",
- "# format_version: '1.3'\n",
- "# kernelspec:\n",
- "# display_name: Python 3\n",
- "# language: python\n",
- "# name: python3\n",
- "# ---"
- ]
- },
{
"cell_type": "markdown",
- "id": "8084293f",
+ "id": "7ecf3f80",
"metadata": {},
"source": [
- "# \ud83d\udd75\ufe0f Inspecting Detected Entities\n",
+ "\n",
+ "# 🕵️ Inspecting Detected Entities\n",
"\n",
"Dig into the entity detection pipeline output -- what was detected,\n",
"what the LLM validator kept or dropped, and where entities appear in the text.\n",
@@ -47,7 +20,11 @@
"We use **Annotate** mode because it preserves the original text while tagging each entity\n",
"with its label, making it ideal for reviewing detection quality.\n",
"\n",
- "#### \ud83d\udcda What you'll learn\n",
+ "> **Privacy warning:** `Annotate` does not anonymize the text. Sensitive values\n",
+ "> remain in the output, so use it only for inspection -- not as a privacy-safe\n",
+ "> production strategy.\n",
+ "\n",
+ "#### 📚 What you'll learn\n",
"\n",
"- Run the detection pipeline and inspect its output using Annotate mode\n",
"- View tagged text with entities marked inline\n",
@@ -60,10 +37,10 @@
},
{
"cell_type": "markdown",
- "id": "88f2cc08",
+ "id": "9d037c41",
"metadata": {},
"source": [
- "## \u2699\ufe0f Setup\n",
+ "## ⚙️ Setup\n",
"\n",
"- Check if your `NVIDIA_API_KEY` from [build.nvidia.com](https://build.nvidia.com) is registered for model access.\n",
" - The default `build.nvidia.com` (NVIDIA Build) setup is a convenient way to try Anonymizer and iterate on previews. Use of NVIDIA Build is subject to NVIDIA Build's own terms of service and privacy practices, which are separate from and independent of the NeMo Framework library. NVIDIA Build is intended for evaluation and testing purposes only and may not be used in production environments. Do not upload any confidential information or personal data when using NVIDIA Build. Your use of NVIDIA Build is logged for security purposes and to improve NVIDIA products and services.\n",
@@ -76,13 +53,13 @@
{
"cell_type": "code",
"execution_count": 2,
- "id": "d5a3d0cb",
+ "id": "7df825e3",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:16:37.597938Z",
- "iopub.status.busy": "2026-05-19T20:16:37.597881Z",
- "iopub.status.idle": "2026-05-19T20:16:37.952982Z",
- "shell.execute_reply": "2026-05-19T20:16:37.952736Z"
+ "iopub.execute_input": "2026-07-13T16:05:50.726639Z",
+ "iopub.status.busy": "2026-07-13T16:05:50.726580Z",
+ "iopub.status.idle": "2026-07-13T16:05:50.728395Z",
+ "shell.execute_reply": "2026-07-13T16:05:50.728131Z"
}
},
"outputs": [],
@@ -102,14 +79,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "id": "26420ecb",
+ "execution_count": 3,
+ "id": "40fc39b6",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:16:37.954268Z",
- "iopub.status.busy": "2026-05-19T20:16:37.954180Z",
- "iopub.status.idle": "2026-05-19T20:16:40.007621Z",
- "shell.execute_reply": "2026-05-19T20:16:40.006993Z"
+ "iopub.execute_input": "2026-07-13T16:05:50.729340Z",
+ "iopub.status.busy": "2026-07-13T16:05:50.729284Z",
+ "iopub.status.idle": "2026-07-13T16:05:50.730961Z",
+ "shell.execute_reply": "2026-07-13T16:05:50.730776Z"
}
},
"outputs": [],
@@ -122,13 +99,13 @@
{
"cell_type": "code",
"execution_count": 4,
- "id": "eb139f7f",
+ "id": "dbd3db6b",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:16:40.011633Z",
- "iopub.status.busy": "2026-05-19T20:16:40.011402Z",
- "iopub.status.idle": "2026-05-19T20:16:40.021466Z",
- "shell.execute_reply": "2026-05-19T20:16:40.021225Z"
+ "iopub.execute_input": "2026-07-13T16:05:50.731995Z",
+ "iopub.status.busy": "2026-07-13T16:05:50.731930Z",
+ "iopub.status.idle": "2026-07-13T16:05:50.786776Z",
+ "shell.execute_reply": "2026-07-13T16:05:50.786229Z"
}
},
"outputs": [
@@ -136,28 +113,28 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:40] [INFO] \ud83d\udd27 Anonymizer initialized with 3 model configs\n"
+ "[11:05:50] [INFO] 🔧 Anonymizer initialized with 3 model configs\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:40] [INFO] |-- \ud83d\udd0e detector: gliner-pii-detector\n"
+ "[11:05:50] [INFO] |-- 🔎 detector: gliner-pii-detector\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:40] [INFO] |-- \u2705 validator: gpt-oss-120b\n"
+ "[11:05:50] [INFO] |-- ✅ validator: gpt-oss-120b\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:40] [INFO] |-- \ud83e\udde9 augmenter: gpt-oss-120b\n"
+ "[11:05:50] [INFO] |-- 🧩 augmenter: gpt-oss-120b\n"
]
}
],
@@ -167,10 +144,10 @@
},
{
"cell_type": "markdown",
- "id": "be3b0054",
+ "id": "7b8e4226",
"metadata": {},
"source": [
- "## \ud83d\udc41\ufe0f Preview\n",
+ "## 👁️ Preview\n",
"\n",
"- Detection runs as part of any strategy. `Annotate` keeps original text visible\n",
" alongside entity labels -- ideal for debugging.\n",
@@ -180,13 +157,13 @@
{
"cell_type": "code",
"execution_count": 5,
- "id": "62f86d7c",
+ "id": "031b5ed4",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:16:40.023362Z",
- "iopub.status.busy": "2026-05-19T20:16:40.023284Z",
- "iopub.status.idle": "2026-05-19T20:17:12.377438Z",
- "shell.execute_reply": "2026-05-19T20:17:12.377050Z"
+ "iopub.execute_input": "2026-07-13T16:05:50.790678Z",
+ "iopub.status.busy": "2026-07-13T16:05:50.790460Z",
+ "iopub.status.idle": "2026-07-13T16:06:52.644454Z",
+ "shell.execute_reply": "2026-07-13T16:06:52.643827Z"
}
},
"outputs": [
@@ -194,56 +171,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:40] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:05:51] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:40] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:05:51] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:16:40] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:05:51] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:12] [INFO] |-- \ud83d\udccb Detection complete \u2014 77 entities found across 3 records (0 failed) [31.9s]\n"
+ "[11:06:52] [INFO] |-- 📋 Detection complete — 78 entities found across 3 records (0 failed) [61.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:12] [INFO] |-- labels: first_name=23, organization_name=7, state=6, age=5, occupation=5, city=5, last_name=3, race_ethnicity=3, language=3, company_name=3, political_view=3, education_level=3, street_address=2, degree=1, university=1, date_of_birth=1, field_of_study=1, employment_status=1, religious_belief=1\n"
+ "[11:06:52] [INFO] |-- labels: first_name=23, organization_name=7, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, political_view=3, language=2, religious_belief=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:12] [INFO] \ud83d\udd04 Running Annotate replacement\n"
+ "[11:06:52] [INFO] 🔄 Running Annotate replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:12] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [0.0s]\n"
+ "[11:06:52] [INFO] |-- 📋 Replacement complete (0 failed) [0.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:12] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:06:52] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
}
],
@@ -265,10 +242,10 @@
},
{
"cell_type": "markdown",
- "id": "eea0a736",
+ "id": "14f24904",
"metadata": {},
"source": [
- "## \ud83d\udd0d Inspect\n",
+ "## 🔍 Inspect\n",
"\n",
"- `display_record()` renders an interactive view with entity highlights."
]
@@ -276,13 +253,13 @@
{
"cell_type": "code",
"execution_count": 6,
- "id": "13296551",
+ "id": "455d8a65",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:12.379816Z",
- "iopub.status.busy": "2026-05-19T20:17:12.379689Z",
- "iopub.status.idle": "2026-05-19T20:17:12.383871Z",
- "shell.execute_reply": "2026-05-19T20:17:12.383630Z"
+ "iopub.execute_input": "2026-07-13T16:06:52.647632Z",
+ "iopub.status.busy": "2026-07-13T16:06:52.647413Z",
+ "iopub.status.idle": "2026-07-13T16:06:52.654293Z",
+ "shell.execute_reply": "2026-07-13T16:06:52.653664Z"
}
},
"outputs": [
@@ -297,19 +274,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| degree at the
University of Colorado Boulder| university, where he also completed a research stint in wildlife health. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria| first_name and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria| first_name and
Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
<Bobby, first_name>| first_name <Watford, last_name>| last_name, a
<40, age>| age\u2011year\u2011old
<Mexican, race_ethnicity>| race_ethnicity <veterinarian, occupation>| occupation living in
<Denver, city>| city,
<Colorado, state>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
<Jefferson High, organization_name>| organization_name, he earned his
<DVM, degree>| degree at the
<University of Colorado Boulder, university>| university, where he also completed a research stint in wildlife health. Fluent in
<English, language>| language,
<Bobby, first_name>| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
<Bobby, first_name>| first_name <Watford, last_name>| last_name, a <40, age>| age‑year‑old <Mexican, race_ethnicity>| race_ethnicity <veterinarian, occupation>| occupation living in <Denver, city>| city, <Colorado, state>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from <Jefferson High, organization_name>| organization_name, he earned his <DVM, degree>| degree at the <University of Colorado Boulder, university>| university, where he also completed a research stint in <wildlife health, field_of_study>| field_of_study. Fluent in <English, language>| language, <Bobby, first_name>| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, <Bobby, first_name>| first_name has worked at <VCA Animal Hospital, company_name>| company_name and later at the <Colorado Veterinary Clinic, organization_name>| organization_name, where he now leads a busy mixed\u2011practice team. He identifies as a <Christian Democrat, political_view>| political_view and often volunteers at local shelters, a habit encouraged by his wife, <Maya, first_name>| first_name, and their two teenage children, <Aria, first_name>| first_name and <Leo, first_name>| first_name. Outside the clinic, <Bobby, first_name>| first_name enjoys hiking the Rockies with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
<Bobby, first_name>| first_name has worked at
<VCA Animal Hospital, organization_name>| organization_name and later at the
<Colorado Veterinary Clinic, organization_name>| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
<Christian Democrat, political_view>| political_view and often volunteers at local shelters, a habit encouraged by his wife,
<Maya, first_name>| first_name, and their two teenage children,
<Aria, first_name>| first_name and
<Leo, first_name>| first_name. Outside the clinic,
<Bobby, first_name>| first_name enjoys hiking the
<Rockies, place_name>| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <Bobby, first_name> |
| Watford | last_name | <Watford, last_name> |
| 40 | age | <40, age> |
| Mexican | race_ethnicity | <Mexican, race_ethnicity> |
| veterinarian | occupation | <veterinarian, occupation> |
| Denver | city | <Denver, city> |
| Colorado | state | <Colorado, state> |
| Jefferson High | organization_name | <Jefferson High, organization_name> |
| DVM | degree | <DVM, degree> |
| University of Colorado Boulder | university | <University of Colorado Boulder, university> |
| English | language | <English, language> |
| VCA Animal Hospital | company_name | <VCA Animal Hospital, company_name> |
| Colorado Veterinary Clinic | organization_name | <Colorado Veterinary Clinic, organization_name> |
| Christian Democrat | political_view | <Christian Democrat, political_view> |
| Maya | first_name | <Maya, first_name> |
| Aria | first_name | <Aria, first_name> |
| Leo | first_name | <Leo, first_name> |
\n",
+ "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <Bobby, first_name> |
| Watford | last_name | <Watford, last_name> |
| 40 | age | <40, age> |
| Mexican | race_ethnicity | <Mexican, race_ethnicity> |
| veterinarian | occupation | <veterinarian, occupation> |
| Denver | city | <Denver, city> |
| Colorado | state | <Colorado, state> |
| Jefferson High | organization_name | <Jefferson High, organization_name> |
| DVM | degree | <DVM, degree> |
| University of Colorado Boulder | university | <University of Colorado Boulder, university> |
| wildlife health | field_of_study | <wildlife health, field_of_study> |
| English | language | <English, language> |
| VCA Animal Hospital | organization_name | <VCA Animal Hospital, organization_name> |
| Colorado Veterinary Clinic | organization_name | <Colorado Veterinary Clinic, organization_name> |
| Christian Democrat | political_view | <Christian Democrat, political_view> |
| Maya | first_name | <Maya, first_name> |
| Aria | first_name | <Aria, first_name> |
| Leo | first_name | <Leo, first_name> |
| Rockies | place_name | <Rockies, place_name> |
\n",
"
\n",
"
\n",
" \n",
@@ -329,25 +310,26 @@
},
{
"cell_type": "markdown",
- "id": "54073eb9",
+ "id": "8f9f328b",
"metadata": {},
"source": [
- "## \ud83d\udccb Columns\n",
+ "## 📋 Columns\n",
"\n",
- "- `trace_dataframe` contains all internal columns from the pipeline\n",
- " (detection, validation, replacement, etc.)."
+ "- `result.dataframe[\"final_entities\"]` is the stable, public entity output.\n",
+ "- `trace_dataframe` contains internal pipeline columns for deeper debugging;\n",
+ " those underscore-prefixed columns may change between releases."
]
},
{
"cell_type": "code",
"execution_count": 7,
- "id": "8cfca376",
+ "id": "de9aa957",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:12.385072Z",
- "iopub.status.busy": "2026-05-19T20:17:12.384998Z",
- "iopub.status.idle": "2026-05-19T20:17:12.386794Z",
- "shell.execute_reply": "2026-05-19T20:17:12.386610Z"
+ "iopub.execute_input": "2026-07-13T16:06:52.656473Z",
+ "iopub.status.busy": "2026-07-13T16:06:52.656305Z",
+ "iopub.status.idle": "2026-07-13T16:06:52.659400Z",
+ "shell.execute_reply": "2026-07-13T16:06:52.658957Z"
}
},
"outputs": [
@@ -361,17 +343,18 @@
}
],
"source": [
- "df = result.trace_dataframe\n",
- "print(f\"Records: {len(df)}\")\n",
- "print(f\"Columns: {list(df.columns)}\")"
+ "trace_df = result.trace_dataframe\n",
+ "final_entities = result.dataframe[\"final_entities\"]\n",
+ "print(f\"Records: {len(trace_df)}\")\n",
+ "print(f\"Columns: {list(trace_df.columns)}\")"
]
},
{
"cell_type": "markdown",
- "id": "62e4dc1f",
+ "id": "b3244f47",
"metadata": {},
"source": [
- "## \ud83c\udfaf Detected entities\n",
+ "## 🎯 Detected entities\n",
"\n",
"- Final entity list after validation. Each entity has `value`, `label`,\n",
" positions, `score`, and `source` (detector / augmenter / name_split / propagation)."
@@ -380,13 +363,13 @@
{
"cell_type": "code",
"execution_count": 8,
- "id": "ea34ef1c",
+ "id": "75c48f18",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:12.387854Z",
- "iopub.status.busy": "2026-05-19T20:17:12.387790Z",
- "iopub.status.idle": "2026-05-19T20:17:12.394229Z",
- "shell.execute_reply": "2026-05-19T20:17:12.394026Z"
+ "iopub.execute_input": "2026-07-13T16:06:52.661498Z",
+ "iopub.status.busy": "2026-07-13T16:06:52.661349Z",
+ "iopub.status.idle": "2026-07-13T16:06:52.676026Z",
+ "shell.execute_reply": "2026-07-13T16:06:52.675581Z"
}
},
"outputs": [
@@ -394,7 +377,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Record 0: 20 entities detected\n",
+ "Record 0: 22 entities detected\n",
"\n",
" value label start_position end_position source\n",
"0 Bobby first_name 0 5 detector\n",
@@ -406,23 +389,25 @@
"6 Colorado state 68 76 detector\n",
"7 Jefferson High organization_name 180 194 augmenter\n",
"8 DVM degree 210 213 detector\n",
- "9 University of Colorado Boulder university 221 251 augmenter\n",
- "10 English language 324 331 detector\n",
- "11 Bobby first_name 333 338 detector\n",
- "12 Bobby first_name 556 561 detector\n",
- "13 VCA Animal Hospital company_name 576 595 detector\n",
- "14 Colorado Veterinary Clinic organization_name 613 639 augmenter\n",
- "15 Christian Democrat political_view 707 725 detector\n",
- "16 Maya first_name 798 802 detector\n",
- "17 Aria first_name 836 840 augmenter\n",
- "18 Leo first_name 845 848 augmenter\n",
- "19 Bobby first_name 870 875 detector\n"
+ "9 University of Colorado Boulder university 221 251 detector\n",
+ "10 wildlife health field_of_study 297 312 detector\n",
+ "11 English language 324 331 detector\n",
+ "12 Bobby first_name 333 338 detector\n",
+ "13 Bobby first_name 556 561 detector\n",
+ "14 VCA Animal Hospital organization_name 576 595 detector\n",
+ "15 Colorado Veterinary Clinic organization_name 613 639 detector\n",
+ "16 Christian Democrat political_view 707 725 detector\n",
+ "17 Maya first_name 798 802 detector\n",
+ "18 Aria first_name 836 840 augmenter\n",
+ "19 Leo first_name 845 848 augmenter\n",
+ "20 Bobby first_name 870 875 detector\n",
+ "21 Rockies place_name 894 901 detector\n"
]
}
],
"source": [
"row_idx = 0\n",
- "raw = df.loc[row_idx, \"_detected_entities\"]\n",
+ "raw = final_entities.iloc[row_idx]\n",
"entities = raw[\"entities\"] if isinstance(raw, dict) else raw\n",
"print(f\"Record {row_idx}: {len(entities)} entities detected\\n\")\n",
"\n",
@@ -434,10 +419,10 @@
},
{
"cell_type": "markdown",
- "id": "c230e940",
+ "id": "79ec1e65",
"metadata": {},
"source": [
- "## \ud83c\udff7\ufe0f Labels\n",
+ "## 🏷️ Labels\n",
"\n",
"- Entity label distribution across all records -- which types are most common."
]
@@ -445,13 +430,13 @@
{
"cell_type": "code",
"execution_count": 9,
- "id": "6adb5a22",
+ "id": "de6a6398",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:12.395453Z",
- "iopub.status.busy": "2026-05-19T20:17:12.395392Z",
- "iopub.status.idle": "2026-05-19T20:17:12.397416Z",
- "shell.execute_reply": "2026-05-19T20:17:12.397207Z"
+ "iopub.execute_input": "2026-07-13T16:06:52.677741Z",
+ "iopub.status.busy": "2026-07-13T16:06:52.677616Z",
+ "iopub.status.idle": "2026-07-13T16:06:52.680259Z",
+ "shell.execute_reply": "2026-07-13T16:06:52.679958Z"
}
},
"outputs": [
@@ -461,29 +446,28 @@
"text": [
" first_name: 23\n",
" organization_name: 7\n",
- " state: 6\n",
" age: 5\n",
" occupation: 5\n",
- " city: 5\n",
+ " city: 4\n",
+ " state: 4\n",
+ " degree: 4\n",
+ " university: 4\n",
+ " field_of_study: 4\n",
" last_name: 3\n",
" race_ethnicity: 3\n",
- " language: 3\n",
- " company_name: 3\n",
" political_view: 3\n",
- " education_level: 3\n",
+ " language: 2\n",
+ " religious_belief: 2\n",
" street_address: 2\n",
- " degree: 1\n",
- " university: 1\n",
+ " place_name: 1\n",
" date_of_birth: 1\n",
- " field_of_study: 1\n",
- " employment_status: 1\n",
- " religious_belief: 1\n"
+ " employment_status: 1\n"
]
}
],
"source": [
"label_counts = Counter()\n",
- "for raw in df[\"_detected_entities\"]:\n",
+ "for raw in final_entities:\n",
" entity_list = raw[\"entities\"] if isinstance(raw, dict) else raw\n",
" for entity in entity_list:\n",
" label_counts[entity[\"label\"]] += 1\n",
@@ -494,10 +478,10 @@
},
{
"cell_type": "markdown",
- "id": "11a3ee18",
+ "id": "4103be67",
"metadata": {},
"source": [
- "## \ud83d\udce1 Sources\n",
+ "## 📡 Sources\n",
"\n",
"- Where each entity came from in the pipeline:\n",
" - `detector` -- GLiNER NER\n",
@@ -510,13 +494,13 @@
{
"cell_type": "code",
"execution_count": 10,
- "id": "1db9770e",
+ "id": "a96f33b0",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:12.398500Z",
- "iopub.status.busy": "2026-05-19T20:17:12.398442Z",
- "iopub.status.idle": "2026-05-19T20:17:12.400322Z",
- "shell.execute_reply": "2026-05-19T20:17:12.400141Z"
+ "iopub.execute_input": "2026-07-13T16:06:52.681722Z",
+ "iopub.status.busy": "2026-07-13T16:06:52.681617Z",
+ "iopub.status.idle": "2026-07-13T16:06:52.683831Z",
+ "shell.execute_reply": "2026-07-13T16:06:52.683551Z"
}
},
"outputs": [
@@ -524,14 +508,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
- " detector: 68\n",
- " augmenter: 9\n"
+ " detector: 74\n",
+ " augmenter: 4\n"
]
}
],
"source": [
"source_counts = Counter()\n",
- "for raw in df[\"_detected_entities\"]:\n",
+ "for raw in final_entities:\n",
" entity_list = raw[\"entities\"] if isinstance(raw, dict) else raw\n",
" for entity in entity_list:\n",
" source_counts[entity.get(\"source\", \"unknown\")] += 1\n",
@@ -542,10 +526,10 @@
},
{
"cell_type": "markdown",
- "id": "2c9f621a",
+ "id": "2c222365",
"metadata": {},
"source": [
- "## \ud83d\udcca By value\n",
+ "## 📊 By value\n",
"\n",
"- Entities grouped by unique value -- this is what drives consistent replacement\n",
" downstream (same name always maps to the same substitute)."
@@ -554,13 +538,13 @@
{
"cell_type": "code",
"execution_count": 11,
- "id": "591a29b9",
+ "id": "195133a2",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:12.401301Z",
- "iopub.status.busy": "2026-05-19T20:17:12.401244Z",
- "iopub.status.idle": "2026-05-19T20:17:12.402998Z",
- "shell.execute_reply": "2026-05-19T20:17:12.402804Z"
+ "iopub.execute_input": "2026-07-13T16:06:52.685191Z",
+ "iopub.status.busy": "2026-07-13T16:06:52.685086Z",
+ "iopub.status.idle": "2026-07-13T16:06:52.687462Z",
+ "shell.execute_reply": "2026-07-13T16:06:52.687197Z"
}
},
"outputs": [
@@ -568,7 +552,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Record 0: 17 unique entity values\n",
+ "Record 0: 19 unique entity values\n",
"\n",
" '40' -> labels: ['age']\n",
" 'Aria' -> labels: ['first_name']\n",
@@ -583,16 +567,18 @@
" 'Leo' -> labels: ['first_name']\n",
" 'Maya' -> labels: ['first_name']\n",
" 'Mexican' -> labels: ['race_ethnicity']\n",
+ " 'Rockies' -> labels: ['place_name']\n",
" 'University of Colorado Boulder' -> labels: ['university']\n",
- " 'VCA Animal Hospital' -> labels: ['company_name']\n",
+ " 'VCA Animal Hospital' -> labels: ['organization_name']\n",
" 'Watford' -> labels: ['last_name']\n",
- " 'veterinarian' -> labels: ['occupation']\n"
+ " 'veterinarian' -> labels: ['occupation']\n",
+ " 'wildlife health' -> labels: ['field_of_study']\n"
]
}
],
"source": [
"row_idx = 0\n",
- "raw_bv = df.loc[row_idx, \"_entities_by_value\"]\n",
+ "raw_bv = trace_df.loc[row_idx, \"_entities_by_value\"]\n",
"by_value = raw_bv[\"entities_by_value\"] if isinstance(raw_bv, dict) else raw_bv\n",
"print(f\"Record {row_idx}: {len(by_value)} unique entity values\\n\")\n",
"\n",
@@ -602,10 +588,10 @@
},
{
"cell_type": "markdown",
- "id": "aa5a42b8",
+ "id": "edf8c441",
"metadata": {},
"source": [
- "## \u274c Failures\n",
+ "## ❌ Failures\n",
"\n",
"- Records dropped during detection (LLM timeout, parse error, etc.).\n",
"- Check this to understand data loss in your pipeline."
@@ -614,13 +600,13 @@
{
"cell_type": "code",
"execution_count": 12,
- "id": "d7ff250e",
+ "id": "a85e3ee6",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:12.403950Z",
- "iopub.status.busy": "2026-05-19T20:17:12.403900Z",
- "iopub.status.idle": "2026-05-19T20:17:12.405301Z",
- "shell.execute_reply": "2026-05-19T20:17:12.405135Z"
+ "iopub.execute_input": "2026-07-13T16:06:52.688723Z",
+ "iopub.status.busy": "2026-07-13T16:06:52.688634Z",
+ "iopub.status.idle": "2026-07-13T16:06:52.690288Z",
+ "shell.execute_reply": "2026-07-13T16:06:52.690071Z"
}
},
"outputs": [
@@ -642,21 +628,69 @@
},
{
"cell_type": "markdown",
- "id": "919f489e",
+ "id": "ce38736a",
"metadata": {},
"source": [
- "## \ud83d\udcca (Optional) Score the detections with an LLM judge\n",
+ "## 📊 (Optional) Score the detections with an LLM judge\n",
"\n",
"- `evaluate()` is a separate, opt-in step that runs LLM-as-judge metrics on the output.\n",
- "- This notebook uses Annotate, so only **Detection Validity** runs \u2014 it flags entities the detector got wrong (false positives, mislabels, boundary errors). Substitute would also enable Type Fidelity, Relational Consistency, and Attribute Fidelity."
+ "- This notebook uses Annotate, so only **Detection Validity** runs — it flags entities the detector got wrong (false positives, mislabels, boundary errors). Substitute would also enable Type Fidelity, Relational Consistency, and Attribute Fidelity."
]
},
{
"cell_type": "code",
- "execution_count": null,
- "id": "90382b68",
- "metadata": {},
- "outputs": [],
+ "execution_count": 13,
+ "id": "3c972093",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:06:52.691518Z",
+ "iopub.status.busy": "2026-07-13T16:06:52.691443Z",
+ "iopub.status.idle": "2026-07-13T16:07:12.909587Z",
+ "shell.execute_reply": "2026-07-13T16:07:12.909314Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Preview (record 0)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| organization_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria| first_name and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
\n",
+ "
Replaced
\n",
+ "
<Bobby, first_name>| first_name <Watford, last_name>| last_name, a <40, age>| age‑year‑old <Mexican, race_ethnicity>| race_ethnicity <veterinarian, occupation>| occupation living in <Denver, city>| city, <Colorado, state>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from <Jefferson High, organization_name>| organization_name, he earned his <DVM, degree>| degree at the <University of Colorado Boulder, university>| university, where he also completed a research stint in <wildlife health, field_of_study>| field_of_study. Fluent in <English, language>| language, <Bobby, first_name>| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, <Bobby, first_name>| first_name has worked at <VCA Animal Hospital, organization_name>| organization_name and later at the <Colorado Veterinary Clinic, organization_name>| organization_name, where he now leads a busy mixed‑practice team. He identifies as a <Christian Democrat, political_view>| political_view and often volunteers at local shelters, a habit encouraged by his wife, <Maya, first_name>| first_name, and their two teenage children, <Aria, first_name>| first_name and <Leo, first_name>| first_name. Outside the clinic, <Bobby, first_name>| first_name enjoys hiking the <Rockies, place_name>| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
Detection Judge
Detection Validity: Satisfied (LLM alignment score: 19/19)
LLM alignment score: The level of alignment between the detection and evaluation LLMs across entity classification, attributes, and relationships.
\n",
+ " \n",
+ " \n",
+ " \n",
+ "
\n",
+ "
Replacement Map
\n",
+ "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <Bobby, first_name> |
| Watford | last_name | <Watford, last_name> |
| 40 | age | <40, age> |
| Mexican | race_ethnicity | <Mexican, race_ethnicity> |
| veterinarian | occupation | <veterinarian, occupation> |
| Denver | city | <Denver, city> |
| Colorado | state | <Colorado, state> |
| Jefferson High | organization_name | <Jefferson High, organization_name> |
| DVM | degree | <DVM, degree> |
| University of Colorado Boulder | university | <University of Colorado Boulder, university> |
| wildlife health | field_of_study | <wildlife health, field_of_study> |
| English | language | <English, language> |
| VCA Animal Hospital | organization_name | <VCA Animal Hospital, organization_name> |
| Colorado Veterinary Clinic | organization_name | <Colorado Veterinary Clinic, organization_name> |
| Christian Democrat | political_view | <Christian Democrat, political_view> |
| Maya | first_name | <Maya, first_name> |
| Aria | first_name | <Aria, first_name> |
| Leo | first_name | <Leo, first_name> |
| Rockies | place_name | <Rockies, place_name> |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"evaluated = anonymizer.evaluate(result)\n",
"evaluated.display_record(0)"
@@ -664,16 +698,16 @@
},
{
"cell_type": "markdown",
- "id": "6018bb1d",
+ "id": "dea51f72",
"metadata": {},
"source": [
- "## \u23ed\ufe0f Next steps\n",
+ "## ⏭️ Next steps\n",
"\n",
- "- **[\ud83d\udd75\ufe0f Your First Anonymization](../01_your_first_anonymization/)** --\n",
+ "- **[🕵️ Your First Anonymization](../01_your_first_anonymization/)** --\n",
" the simplest end-to-end replace workflow if you haven't run it yet.\n",
- "- **[\ud83c\udfaf Choosing a Replacement Strategy](../03_choosing_a_replacement_strategy/)** --\n",
+ "- **[🎯 Choosing a Replacement Strategy](../03_choosing_a_replacement_strategy/)** --\n",
" compare Redact, Annotate, Hash, and Substitute side-by-side.\n",
- "- **[\u270f\ufe0f Rewriting Biographies](../04_rewriting_biographies/)** --\n",
+ "- **[✏️ Rewriting Biographies](../04_rewriting_biographies/)** --\n",
" generate privacy-safe paraphrases instead of token-level replacements."
]
}
diff --git a/docs/notebooks/03_choosing_a_replacement_strategy.ipynb b/docs/notebooks/03_choosing_a_replacement_strategy.ipynb
index 89df5dc7..e37350c7 100644
--- a/docs/notebooks/03_choosing_a_replacement_strategy.ipynb
+++ b/docs/notebooks/03_choosing_a_replacement_strategy.ipynb
@@ -1,42 +1,15 @@
{
"cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "id": "3223b7d5",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-05-19T20:17:13.470736Z",
- "iopub.status.busy": "2026-05-19T20:17:13.470299Z",
- "iopub.status.idle": "2026-05-19T20:17:13.475322Z",
- "shell.execute_reply": "2026-05-19T20:17:13.474535Z"
- }
- },
- "outputs": [],
- "source": [
- "# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n",
- "# SPDX-License-Identifier: Apache-2.0\n",
- "\n",
- "# ---\n",
- "# jupyter:\n",
- "# jupytext:\n",
- "# text_representation:\n",
- "# extension: .py\n",
- "# format_name: percent\n",
- "# format_version: '1.3'\n",
- "# kernelspec:\n",
- "# display_name: Python 3\n",
- "# language: python\n",
- "# name: python3\n",
- "# ---"
- ]
- },
{
"cell_type": "markdown",
- "id": "dd098e7b",
+ "id": "78c16264",
"metadata": {},
"source": [
- "# \ud83d\udd75\ufe0f Choosing a Replacement Strategy\n",
+ "\n",
+ "# 🕵️ Choosing a Replacement Strategy\n",
"\n",
"Four [replace mode](../../concepts/replace/) strategies compared side-by-side on the same data.\n",
"\n",
@@ -46,7 +19,8 @@
"| **Redact** | Label-based markers (`[REDACTED_FIRST_NAME]`) |\n",
"| **Annotate** | Tags entities but keeps original text |\n",
"| **Hash** | Deterministic hash digest |\n",
- "#### \ud83d\udcda What you'll learn\n",
+ "\n",
+ "#### 📚 What you'll learn\n",
"\n",
"- Compare **Redact**, **Annotate**, **Hash**, and **Substitute** on the same input\n",
"- Customize output formats with `format_template`\n",
@@ -58,10 +32,10 @@
},
{
"cell_type": "markdown",
- "id": "bf4e4388",
+ "id": "bff538f5",
"metadata": {},
"source": [
- "## \u2699\ufe0f Setup\n",
+ "## ⚙️ Setup\n",
"\n",
"- Check if your `NVIDIA_API_KEY` from [build.nvidia.com](https://build.nvidia.com) is registered for model access.\n",
" - The default `build.nvidia.com` (NVIDIA Build) setup is a convenient way to try Anonymizer and iterate on previews. Use of NVIDIA Build is subject to NVIDIA Build's own terms of service and privacy practices, which are separate from and independent of the NeMo Framework library. NVIDIA Build is intended for evaluation and testing purposes only and may not be used in production environments. Do not upload any confidential information or personal data when using NVIDIA Build. Your use of NVIDIA Build is logged for security purposes and to improve NVIDIA products and services.\n",
@@ -74,13 +48,13 @@
{
"cell_type": "code",
"execution_count": 2,
- "id": "2275f768",
+ "id": "869d217a",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:13.478137Z",
- "iopub.status.busy": "2026-05-19T20:17:13.478031Z",
- "iopub.status.idle": "2026-05-19T20:17:13.483368Z",
- "shell.execute_reply": "2026-05-19T20:17:13.482680Z"
+ "iopub.execute_input": "2026-07-13T16:07:15.593075Z",
+ "iopub.status.busy": "2026-07-13T16:07:15.592868Z",
+ "iopub.status.idle": "2026-07-13T16:07:15.595941Z",
+ "shell.execute_reply": "2026-07-13T16:07:15.595538Z"
}
},
"outputs": [],
@@ -97,15 +71,16 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "id": "2edda5c8",
+ "execution_count": 3,
+ "id": "237757ee",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:13.485812Z",
- "iopub.status.busy": "2026-05-19T20:17:13.485593Z",
- "iopub.status.idle": "2026-05-19T20:17:15.506266Z",
- "shell.execute_reply": "2026-05-19T20:17:15.505998Z"
- }
+ "iopub.execute_input": "2026-07-13T16:07:15.597885Z",
+ "iopub.status.busy": "2026-07-13T16:07:15.597739Z",
+ "iopub.status.idle": "2026-07-13T16:07:15.601412Z",
+ "shell.execute_reply": "2026-07-13T16:07:15.600955Z"
+ },
+ "lines_to_next_cell": 0
},
"outputs": [],
"source": [
@@ -127,13 +102,13 @@
{
"cell_type": "code",
"execution_count": 4,
- "id": "0be07202",
+ "id": "4d351c01",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:15.507642Z",
- "iopub.status.busy": "2026-05-19T20:17:15.507501Z",
- "iopub.status.idle": "2026-05-19T20:17:15.513669Z",
- "shell.execute_reply": "2026-05-19T20:17:15.513490Z"
+ "iopub.execute_input": "2026-07-13T16:07:15.603489Z",
+ "iopub.status.busy": "2026-07-13T16:07:15.603344Z",
+ "iopub.status.idle": "2026-07-13T16:07:15.616794Z",
+ "shell.execute_reply": "2026-07-13T16:07:15.616488Z"
}
},
"outputs": [
@@ -141,28 +116,28 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:15] [INFO] \ud83d\udd27 Anonymizer initialized with 3 model configs\n"
+ "[11:07:15] [INFO] 🔧 Anonymizer initialized with 3 model configs\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:15] [INFO] |-- \ud83d\udd0e detector: gliner-pii-detector\n"
+ "[11:07:15] [INFO] |-- 🔎 detector: gliner-pii-detector\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:15] [INFO] |-- \u2705 validator: gpt-oss-120b\n"
+ "[11:07:15] [INFO] |-- ✅ validator: gpt-oss-120b\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:15] [INFO] |-- \ud83e\udde9 augmenter: gpt-oss-120b\n"
+ "[11:07:15] [INFO] |-- 🧩 augmenter: gpt-oss-120b\n"
]
}
],
@@ -172,10 +147,10 @@
},
{
"cell_type": "markdown",
- "id": "d58e76d4",
+ "id": "8104b53a",
"metadata": {},
"source": [
- "## \ud83d\udce6 Input data\n",
+ "## 📦 Input data\n",
"\n",
"- We use the same biographies dataset throughout so each strategy is compared\n",
" on identical input."
@@ -184,13 +159,13 @@
{
"cell_type": "code",
"execution_count": 5,
- "id": "e5959a13",
+ "id": "d3123141",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:15.514698Z",
- "iopub.status.busy": "2026-05-19T20:17:15.514640Z",
- "iopub.status.idle": "2026-05-19T20:17:15.516078Z",
- "shell.execute_reply": "2026-05-19T20:17:15.515890Z"
+ "iopub.execute_input": "2026-07-13T16:07:15.618484Z",
+ "iopub.status.busy": "2026-07-13T16:07:15.618368Z",
+ "iopub.status.idle": "2026-07-13T16:07:15.620362Z",
+ "shell.execute_reply": "2026-07-13T16:07:15.620057Z"
}
},
"outputs": [],
@@ -204,10 +179,10 @@
},
{
"cell_type": "markdown",
- "id": "2fc9be79",
+ "id": "19ce3734",
"metadata": {},
"source": [
- "## \ud83d\udd04 Substitute\n",
+ "## 🔄 Substitute\n",
"\n",
"- Uses an LLM to generate contextually appropriate synthetic replacements.\n",
" - The LLM considers the full document context matching names with emails, cities to states, etc.\n",
@@ -217,13 +192,13 @@
{
"cell_type": "code",
"execution_count": 6,
- "id": "ae6b1561",
+ "id": "35650ff7",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:15.517047Z",
- "iopub.status.busy": "2026-05-19T20:17:15.516992Z",
- "iopub.status.idle": "2026-05-19T20:17:51.025998Z",
- "shell.execute_reply": "2026-05-19T20:17:51.025119Z"
+ "iopub.execute_input": "2026-07-13T16:07:15.621895Z",
+ "iopub.status.busy": "2026-07-13T16:07:15.621813Z",
+ "iopub.status.idle": "2026-07-13T16:08:58.845943Z",
+ "shell.execute_reply": "2026-07-13T16:08:58.845413Z"
}
},
"outputs": [
@@ -231,56 +206,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:15] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:07:16] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:15] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:07:16] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:15] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:07:16] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:36] [INFO] |-- \ud83d\udccb Detection complete \u2014 76 entities found across 3 records (0 failed) [20.6s]\n"
+ "[11:08:17] [INFO] |-- 📋 Detection complete — 79 entities found across 3 records (0 failed) [61.4s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:36] [INFO] |-- labels: first_name=22, state=6, age=5, occupation=5, city=5, company_name=4, last_name=3, race_ethnicity=3, organization_name=3, language=3, political_view=3, education_level=3, field_of_study=2, street_address=2, degree=1, university=1, place_name=1, date_of_birth=1, project_name=1, employment_status=1, religious_belief=1\n"
+ "[11:08:17] [INFO] |-- labels: first_name=22, organization_name=7, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, political_view=3, language=2, religious_belief=2, street_address=2, place_name=1, date_of_birth=1, proprietary_term=1, employment_status=1, company_name=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:36] [INFO] \ud83d\udd04 Running Substitute replacement\n"
+ "[11:08:17] [INFO] 🔄 Running Substitute replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:50] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [14.6s]\n"
+ "[11:08:58] [INFO] |-- 📋 Replacement complete (0 failed) [40.9s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:50] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:08:58] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
}
],
@@ -297,13 +272,13 @@
{
"cell_type": "code",
"execution_count": 7,
- "id": "f3390c2c",
+ "id": "2c795ae9",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:51.030727Z",
- "iopub.status.busy": "2026-05-19T20:17:51.030483Z",
- "iopub.status.idle": "2026-05-19T20:17:51.039489Z",
- "shell.execute_reply": "2026-05-19T20:17:51.038887Z"
+ "iopub.execute_input": "2026-07-13T16:08:58.848097Z",
+ "iopub.status.busy": "2026-07-13T16:08:58.847993Z",
+ "iopub.status.idle": "2026-07-13T16:08:58.852636Z",
+ "shell.execute_reply": "2026-07-13T16:08:58.852264Z"
}
},
"outputs": [
@@ -318,19 +293,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| degree at the
University of Colorado Boulder| university, where he also completed a research stint in
wildlife health| field_of_study. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria and Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
Ethan| first_name Hernandez| last_name, a
52| age\u2011year\u2011old
Filipino| race_ethnicity zoologist| occupation living in
Portland| city,
Oregon| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Lincoln High| organization_name, he earned his
Master of Science| degree at the
University of Washington| university, where he also completed a research stint in
conservation genetics| field_of_study. Fluent in
Spanish| language,
Ethan| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Ethan| first_name Keller| last_name, a 45| age‑year‑old Filipino| race_ethnicity zoologist| occupation living in Portland| city, Oregon| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Willamette High| organization_name, he earned his Doctor of Osteopathic Medicine (DO)| degree at the Oregon State University| university, where he also completed a research stint in conservation genetics| field_of_study. Fluent in Spanish| language, Ethan| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Ethan| first_name has worked at PetCare Veterinary Center| company_name and later at the Cascade Animal Hospital| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a Libertarian| political_view and often volunteers at local shelters, a habit encouraged by his wife, Nina| first_name, and their two teenage children, Sofia and Mateo| first_name. Outside the clinic, Ethan| first_name enjoys hiking the Sierra Nevada| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Ethan| first_name has worked at
Pacific Animal Hospital| organization_name and later at the
Oregon Veterinary Center| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Libertarian| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Sofia| first_name, and their two teenage children,
Nina and Omar| first_name. Outside the clinic,
Ethan| first_name enjoys hiking the
Cascades| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| 40 | age | 52 |
| Aria and Leo | first_name | Sofia and Mateo |
| Bobby | first_name | Ethan |
| Christian Democrat | political_view | Libertarian |
| Colorado | state | Oregon |
| Colorado Veterinary Clinic | company_name | Cascade Animal Hospital |
| DVM | degree | Master of Science |
| Denver | city | Portland |
| English | language | Spanish |
| Jefferson High | organization_name | Lincoln High |
| Maya | first_name | Nina |
| Mexican | race_ethnicity | Filipino |
| Rockies | place_name | Sierra Nevada |
| University of Colorado Boulder | university | University of Washington |
| VCA Animal Hospital | company_name | PetCare Veterinary Center |
| Watford | last_name | Hernandez |
| veterinarian | occupation | zoologist |
| wildlife health | field_of_study | conservation genetics |
\n",
+ "
| Original | Label | Replacement |
|---|
| 40 | age | 45 |
| Aria and Leo | first_name | Nina and Omar |
| Bobby | first_name | Ethan |
| Christian Democrat | political_view | Libertarian |
| Colorado | state | Oregon |
| Colorado Veterinary Clinic | organization_name | Oregon Veterinary Center |
| DVM | degree | Doctor of Osteopathic Medicine (DO) |
| Denver | city | Portland |
| English | language | Spanish |
| Jefferson High | organization_name | Willamette High |
| Maya | first_name | Sofia |
| Mexican | race_ethnicity | Filipino |
| Rockies | place_name | Cascades |
| University of Colorado Boulder | university | Oregon State University |
| VCA Animal Hospital | organization_name | Pacific Animal Hospital |
| Watford | last_name | Keller |
| veterinarian | occupation | zoologist |
| wildlife health | field_of_study | conservation genetics |
\n",
"
\n",
"
\n",
" \n",
@@ -350,7 +329,7 @@
},
{
"cell_type": "markdown",
- "id": "38245f4a",
+ "id": "58d088dc",
"metadata": {},
"source": [
"### Custom instructions\n",
@@ -362,13 +341,13 @@
{
"cell_type": "code",
"execution_count": 8,
- "id": "9ea9414c",
+ "id": "29e8a56f",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:17:51.041513Z",
- "iopub.status.busy": "2026-05-19T20:17:51.041367Z",
- "iopub.status.idle": "2026-05-19T20:18:28.655567Z",
- "shell.execute_reply": "2026-05-19T20:18:28.655000Z"
+ "iopub.execute_input": "2026-07-13T16:08:58.854083Z",
+ "iopub.status.busy": "2026-07-13T16:08:58.854009Z",
+ "iopub.status.idle": "2026-07-13T16:10:03.772185Z",
+ "shell.execute_reply": "2026-07-13T16:10:03.771610Z"
},
"lines_to_next_cell": 0
},
@@ -377,56 +356,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:51] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:08:59] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:51] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:08:59] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:17:51] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:08:59] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:18] [INFO] |-- \ud83d\udccb Detection complete \u2014 78 entities found across 3 records (0 failed) [27.1s]\n"
+ "[11:09:44] [INFO] |-- 📋 Detection complete — 77 entities found across 3 records (0 failed) [45.2s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:18] [INFO] |-- labels: first_name=22, state=6, age=5, occupation=5, city=5, organization_name=5, company_name=4, last_name=3, race_ethnicity=3, language=3, political_view=3, degree=2, field_of_study=2, education_level=2, religious_belief=2, street_address=2, university=1, date_of_birth=1, telescope_array=1, employment_status=1\n"
+ "[11:09:44] [INFO] |-- labels: first_name=22, organization_name=6, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, political_view=3, language=2, religious_belief=2, street_address=2, education_level=1, place_name=1, date_of_birth=1, employment_status=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:18] [INFO] \ud83d\udd04 Running Substitute replacement\n"
+ "[11:09:44] [INFO] 🔄 Running Substitute replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:28] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [10.2s]\n"
+ "[11:10:03] [INFO] |-- 📋 Replacement complete (0 failed) [18.9s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:28] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:10:03] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
},
{
@@ -440,19 +419,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| degree at the
University of Colorado Boulder| university, where he also completed a research stint in
wildlife health| field_of_study. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| education_level, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria and Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
Takumi| first_name Tanaka| last_name, a
45| age\u2011year\u2011old
Japanese| race_ethnicity marine biologist| occupation living in
Sapporo| city,
Hokkaido| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Tokyo Metropolitan Hibiya High School| organization_name, he earned his
Ph.D. in Marine Biology| degree at the
University of Tokyo| university, where he also completed a research stint in
marine ecology| field_of_study. Fluent in
Japanese| language,
Takumi| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Haruto| first_name Tanaka| last_name, a 45| age‑year‑old Japanese| race_ethnicity 動物学者| occupation living in Sapporo| city, Hokkaido| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Sapporo High School| education_level, he earned his 獣医学修士| degree at the Hokkaido University| university, where he also completed a research stint in 海洋生物学| field_of_study. Fluent in Japanese| language, Haruto| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Takumi| first_name has worked at Sakura Animal Clinic| company_name and later at the Nihon Veterinary Center| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a Liberal Democratic Party| political_view and often volunteers at local shelters, a habit encouraged by his wife, Haruka| first_name, and their two teenage children, Sora and Ren| first_name. Outside the clinic, Takumi| first_name enjoys hiking the Rockies with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Haruto| first_name has worked at
Sapporo Animal Clinic| organization_name and later at the
Hokkaido Veterinary Center| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Liberal Democratic Party member| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Sakura| first_name, and their two teenage children,
Kenji and Yui| first_name. Outside the clinic,
Haruto| first_name enjoys hiking the
Japanese Alps| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| 40 | age | 45 |
| Aria and Leo | first_name | Sora and Ren |
| Bobby | first_name | Takumi |
| Christian Democrat | political_view | Liberal Democratic Party |
| Colorado | state | Hokkaido |
| Colorado Veterinary Clinic | company_name | Nihon Veterinary Center |
| DVM | degree | Ph.D. in Marine Biology |
| Denver | city | Sapporo |
| English | language | Japanese |
| Jefferson High | organization_name | Tokyo Metropolitan Hibiya High School |
| Maya | first_name | Haruka |
| Mexican | race_ethnicity | Japanese |
| University of Colorado Boulder | university | University of Tokyo |
| VCA Animal Hospital | company_name | Sakura Animal Clinic |
| Watford | last_name | Tanaka |
| veterinarian | occupation | marine biologist |
| wildlife health | field_of_study | marine ecology |
\n",
+ "
| Original | Label | Replacement |
|---|
| 40 | age | 45 |
| Aria and Leo | first_name | Kenji and Yui |
| Bobby | first_name | Haruto |
| Christian Democrat | political_view | Liberal Democratic Party member |
| Colorado | state | Hokkaido |
| Colorado Veterinary Clinic | organization_name | Hokkaido Veterinary Center |
| DVM | degree | 獣医学修士 |
| Denver | city | Sapporo |
| English | language | Japanese |
| Jefferson High | education_level | Sapporo High School |
| Maya | first_name | Sakura |
| Mexican | race_ethnicity | Japanese |
| Rockies | place_name | Japanese Alps |
| University of Colorado Boulder | university | Hokkaido University |
| VCA Animal Hospital | organization_name | Sapporo Animal Clinic |
| Watford | last_name | Tanaka |
| veterinarian | occupation | 動物学者 |
| wildlife health | field_of_study | 海洋生物学 |
\n",
"
\n",
"
\n",
" \n",
@@ -480,10 +463,10 @@
},
{
"cell_type": "markdown",
- "id": "ccbcd178",
+ "id": "c58beeb7",
"metadata": {},
"source": [
- "## \ud83d\udeab Redact\n",
+ "## 🚫 Redact\n",
"\n",
"- Replaces each entity with a label-based marker. Default: `[REDACTED_FIRST_NAME]`.\n",
"- Customize with `Redact(format_template=...)`."
@@ -492,13 +475,13 @@
{
"cell_type": "code",
"execution_count": 9,
- "id": "08fa07dd",
+ "id": "af8e350e",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:18:28.657333Z",
- "iopub.status.busy": "2026-05-19T20:18:28.657230Z",
- "iopub.status.idle": "2026-05-19T20:18:54.506303Z",
- "shell.execute_reply": "2026-05-19T20:18:54.505876Z"
+ "iopub.execute_input": "2026-07-13T16:10:03.774859Z",
+ "iopub.status.busy": "2026-07-13T16:10:03.774664Z",
+ "iopub.status.idle": "2026-07-13T16:10:34.250698Z",
+ "shell.execute_reply": "2026-07-13T16:10:34.250240Z"
}
},
"outputs": [
@@ -506,56 +489,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:28] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:10:04] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:28] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:10:04] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:28] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:10:04] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:54] [INFO] |-- \ud83d\udccb Detection complete \u2014 75 entities found across 3 records (0 failed) [25.6s]\n"
+ "[11:10:33] [INFO] |-- 📋 Detection complete — 76 entities found across 3 records (0 failed) [29.8s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:54] [INFO] |-- labels: first_name=22, state=6, age=5, occupation=5, city=5, organization_name=4, education_level=4, last_name=3, race_ethnicity=3, language=3, company_name=3, political_view=3, religious_belief=2, street_address=2, university=1, place_name=1, date_of_birth=1, field_of_study=1, employment_status=1\n"
+ "[11:10:33] [INFO] |-- labels: first_name=22, organization_name=7, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, political_view=3, language=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1, religious_belief=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:54] [INFO] \ud83d\udd04 Running Redact replacement\n"
+ "[11:10:33] [INFO] 🔄 Running Redact replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:54] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [0.0s]\n"
+ "[11:10:33] [INFO] |-- 📋 Replacement complete (0 failed) [0.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:54] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:10:33] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
},
{
@@ -569,19 +552,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| education_level at the
University of Colorado Boulder| university, where he also completed a research stint in wildlife health. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria and Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
[REDACTED_FIRST_NAME]| first_name [REDACTED_LAST_NAME]| last_name, a
[REDACTED_AGE]| age\u2011year\u2011old
[REDACTED_RACE_ETHNICITY]| race_ethnicity [REDACTED_OCCUPATION]| occupation living in
[REDACTED_CITY]| city,
[REDACTED_STATE]| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
[REDACTED_ORGANIZATION_NAME]| organization_name, he earned his
[REDACTED_EDUCATION_LEVEL]| education_level at the
[REDACTED_UNIVERSITY]| university, where he also completed a research stint in wildlife health. Fluent in
[REDACTED_LANGUAGE]| language,
[REDACTED_FIRST_NAME]| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
[REDACTED_FIRST_NAME]| first_name [REDACTED_LAST_NAME]| last_name, a [REDACTED_AGE]| age‑year‑old [REDACTED_RACE_ETHNICITY]| race_ethnicity [REDACTED_OCCUPATION]| occupation living in [REDACTED_CITY]| city, [REDACTED_STATE]| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from [REDACTED_ORGANIZATION_NAME]| organization_name, he earned his [REDACTED_DEGREE]| degree at the [REDACTED_UNIVERSITY]| university, where he also completed a research stint in [REDACTED_FIELD_OF_STUDY]| field_of_study. Fluent in [REDACTED_LANGUAGE]| language, [REDACTED_FIRST_NAME]| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, [REDACTED_FIRST_NAME]| first_name has worked at [REDACTED_COMPANY_NAME]| company_name and later at the [REDACTED_ORGANIZATION_NAME]| organization_name, where he now leads a busy mixed\u2011practice team. He identifies as a [REDACTED_POLITICAL_VIEW]| political_view and often volunteers at local shelters, a habit encouraged by his wife, [REDACTED_FIRST_NAME]| first_name, and their two teenage children, [REDACTED_FIRST_NAME]| first_name. Outside the clinic, [REDACTED_FIRST_NAME]| first_name enjoys hiking the [REDACTED_PLACE_NAME]| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
[REDACTED_FIRST_NAME]| first_name has worked at
[REDACTED_ORGANIZATION_NAME]| organization_name and later at the
[REDACTED_ORGANIZATION_NAME]| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
[REDACTED_POLITICAL_VIEW]| political_view and often volunteers at local shelters, a habit encouraged by his wife,
[REDACTED_FIRST_NAME]| first_name, and their two teenage children,
[REDACTED_FIRST_NAME]| first_name. Outside the clinic,
[REDACTED_FIRST_NAME]| first_name enjoys hiking the
[REDACTED_PLACE_NAME]| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| Bobby | first_name | [REDACTED_FIRST_NAME] |
| Watford | last_name | [REDACTED_LAST_NAME] |
| 40 | age | [REDACTED_AGE] |
| Mexican | race_ethnicity | [REDACTED_RACE_ETHNICITY] |
| veterinarian | occupation | [REDACTED_OCCUPATION] |
| Denver | city | [REDACTED_CITY] |
| Colorado | state | [REDACTED_STATE] |
| Jefferson High | organization_name | [REDACTED_ORGANIZATION_NAME] |
| DVM | education_level | [REDACTED_EDUCATION_LEVEL] |
| University of Colorado Boulder | university | [REDACTED_UNIVERSITY] |
| English | language | [REDACTED_LANGUAGE] |
| VCA Animal Hospital | company_name | [REDACTED_COMPANY_NAME] |
| Colorado Veterinary Clinic | organization_name | [REDACTED_ORGANIZATION_NAME] |
| Christian Democrat | political_view | [REDACTED_POLITICAL_VIEW] |
| Maya | first_name | [REDACTED_FIRST_NAME] |
| Aria and Leo | first_name | [REDACTED_FIRST_NAME] |
| Rockies | place_name | [REDACTED_PLACE_NAME] |
\n",
+ "
| Original | Label | Replacement |
|---|
| Bobby | first_name | [REDACTED_FIRST_NAME] |
| Watford | last_name | [REDACTED_LAST_NAME] |
| 40 | age | [REDACTED_AGE] |
| Mexican | race_ethnicity | [REDACTED_RACE_ETHNICITY] |
| veterinarian | occupation | [REDACTED_OCCUPATION] |
| Denver | city | [REDACTED_CITY] |
| Colorado | state | [REDACTED_STATE] |
| Jefferson High | organization_name | [REDACTED_ORGANIZATION_NAME] |
| DVM | degree | [REDACTED_DEGREE] |
| University of Colorado Boulder | university | [REDACTED_UNIVERSITY] |
| wildlife health | field_of_study | [REDACTED_FIELD_OF_STUDY] |
| English | language | [REDACTED_LANGUAGE] |
| VCA Animal Hospital | organization_name | [REDACTED_ORGANIZATION_NAME] |
| Colorado Veterinary Clinic | organization_name | [REDACTED_ORGANIZATION_NAME] |
| Christian Democrat | political_view | [REDACTED_POLITICAL_VIEW] |
| Maya | first_name | [REDACTED_FIRST_NAME] |
| Aria and Leo | first_name | [REDACTED_FIRST_NAME] |
| Rockies | place_name | [REDACTED_PLACE_NAME] |
\n",
"
\n",
"
\n",
" \n",
@@ -609,7 +596,7 @@
},
{
"cell_type": "markdown",
- "id": "6d36813d",
+ "id": "5b741e19",
"metadata": {},
"source": [
"### Custom template\n",
@@ -620,13 +607,13 @@
{
"cell_type": "code",
"execution_count": 10,
- "id": "1a633a8b",
+ "id": "0a5e26af",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:18:54.508623Z",
- "iopub.status.busy": "2026-05-19T20:18:54.508526Z",
- "iopub.status.idle": "2026-05-19T20:19:21.301536Z",
- "shell.execute_reply": "2026-05-19T20:19:21.298970Z"
+ "iopub.execute_input": "2026-07-13T16:10:34.253049Z",
+ "iopub.status.busy": "2026-07-13T16:10:34.252864Z",
+ "iopub.status.idle": "2026-07-13T16:11:07.036613Z",
+ "shell.execute_reply": "2026-07-13T16:11:07.036020Z"
}
},
"outputs": [
@@ -634,56 +621,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:54] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:10:34] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:54] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:10:34] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:18:54] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:10:34] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:21] [INFO] |-- \ud83d\udccb Detection complete \u2014 75 entities found across 3 records (0 failed) [26.5s]\n"
+ "[11:11:06] [INFO] |-- 📋 Detection complete — 77 entities found across 3 records (0 failed) [32.2s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:21] [INFO] |-- labels: first_name=22, state=6, age=5, occupation=5, city=5, organization_name=4, company_name=4, last_name=3, race_ethnicity=3, language=3, political_view=3, degree=2, field_of_study=2, education_level=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1, religious_belief=1\n"
+ "[11:11:06] [INFO] |-- labels: first_name=22, organization_name=7, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, political_view=3, language=2, religious_belief=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:21] [INFO] \ud83d\udd04 Running Redact replacement\n"
+ "[11:11:06] [INFO] 🔄 Running Redact replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:21] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [0.0s]\n"
+ "[11:11:06] [INFO] |-- 📋 Replacement complete (0 failed) [0.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:21] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:11:06] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
},
{
@@ -697,19 +684,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| degree at the
University of Colorado Boulder| organization_name, where he also completed a research stint in
wildlife health| field_of_study. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria and Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
***| first_name ***| last_name, a
***| age\u2011year\u2011old
***| race_ethnicity ***| occupation living in
***| city,
***| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
***| organization_name, he earned his
***| degree at the
***| organization_name, where he also completed a research stint in
***| field_of_study. Fluent in
***| language,
***| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
***| first_name ***| last_name, a ***| age‑year‑old ***| race_ethnicity ***| occupation living in ***| city, ***| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from ***| organization_name, he earned his ***| degree at the ***| university, where he also completed a research stint in ***| field_of_study. Fluent in ***| language, ***| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, ***| first_name has worked at ***| company_name and later at the ***| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a ***| political_view and often volunteers at local shelters, a habit encouraged by his wife, ***| first_name, and their two teenage children, ***| first_name. Outside the clinic, ***| first_name enjoys hiking the ***| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
***| first_name has worked at
***| organization_name and later at the
***| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
***| political_view and often volunteers at local shelters, a habit encouraged by his wife,
***| first_name, and their two teenage children,
***| first_name. Outside the clinic,
***| first_name enjoys hiking the
***| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| Bobby | first_name | *** |
| Watford | last_name | *** |
| 40 | age | *** |
| Mexican | race_ethnicity | *** |
| veterinarian | occupation | *** |
| Denver | city | *** |
| Colorado | state | *** |
| Jefferson High | organization_name | *** |
| DVM | degree | *** |
| University of Colorado Boulder | organization_name | *** |
| wildlife health | field_of_study | *** |
| English | language | *** |
| VCA Animal Hospital | company_name | *** |
| Colorado Veterinary Clinic | company_name | *** |
| Christian Democrat | political_view | *** |
| Maya | first_name | *** |
| Aria and Leo | first_name | *** |
| Rockies | place_name | *** |
\n",
+ "
| Original | Label | Replacement |
|---|
| Bobby | first_name | *** |
| Watford | last_name | *** |
| 40 | age | *** |
| Mexican | race_ethnicity | *** |
| veterinarian | occupation | *** |
| Denver | city | *** |
| Colorado | state | *** |
| Jefferson High | organization_name | *** |
| DVM | degree | *** |
| University of Colorado Boulder | university | *** |
| wildlife health | field_of_study | *** |
| English | language | *** |
| VCA Animal Hospital | organization_name | *** |
| Colorado Veterinary Clinic | organization_name | *** |
| Christian Democrat | political_view | *** |
| Maya | first_name | *** |
| Aria and Leo | first_name | *** |
| Rockies | place_name | *** |
\n",
"
\n",
"
\n",
" \n",
@@ -737,10 +728,10 @@
},
{
"cell_type": "markdown",
- "id": "70a454bf",
+ "id": "f008d81d",
"metadata": {},
"source": [
- "## \ud83c\udff7\ufe0f Annotate\n",
+ "## 🏷️ Annotate\n",
"\n",
"- Tags each entity with its label but keeps the original text visible.\n",
" Default: ``.\n",
@@ -751,13 +742,13 @@
{
"cell_type": "code",
"execution_count": 11,
- "id": "130ad67e",
+ "id": "02317dde",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:19:21.320279Z",
- "iopub.status.busy": "2026-05-19T20:19:21.319774Z",
- "iopub.status.idle": "2026-05-19T20:19:49.516428Z",
- "shell.execute_reply": "2026-05-19T20:19:49.515910Z"
+ "iopub.execute_input": "2026-07-13T16:11:07.039430Z",
+ "iopub.status.busy": "2026-07-13T16:11:07.039229Z",
+ "iopub.status.idle": "2026-07-13T16:11:37.494922Z",
+ "shell.execute_reply": "2026-07-13T16:11:37.494295Z"
}
},
"outputs": [
@@ -765,56 +756,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:21] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:11:07] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:21] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:11:07] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:21] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:11:07] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:49] [INFO] |-- \ud83d\udccb Detection complete \u2014 77 entities found across 3 records (0 failed) [27.8s]\n"
+ "[11:11:37] [INFO] |-- 📋 Detection complete — 78 entities found across 3 records (0 failed) [29.8s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:49] [INFO] |-- labels: first_name=22, state=6, age=5, occupation=5, city=5, organization_name=5, company_name=4, last_name=3, race_ethnicity=3, language=3, political_view=3, degree=2, field_of_study=2, education_level=2, street_address=2, university=1, place_name=1, date_of_birth=1, employment_status=1, religious_belief=1\n"
+ "[11:11:37] [INFO] |-- labels: first_name=22, organization_name=7, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, political_view=3, language=2, religious_belief=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1, company_name=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:49] [INFO] \ud83d\udd04 Running Annotate replacement\n"
+ "[11:11:37] [INFO] 🔄 Running Annotate replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:49] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [0.0s]\n"
+ "[11:11:37] [INFO] |-- 📋 Replacement complete (0 failed) [0.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:49] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:11:37] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
},
{
@@ -828,19 +819,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| degree at the
University of Colorado Boulder| university, where he also completed a research stint in
wildlife health| field_of_study. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater| organization_name.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria and Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
<Bobby, first_name>| first_name <Watford, last_name>| last_name, a
<40, age>| age\u2011year\u2011old
<Mexican, race_ethnicity>| race_ethnicity <veterinarian, occupation>| occupation living in
<Denver, city>| city,
<Colorado, state>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
<Jefferson High, organization_name>| organization_name, he earned his
<DVM, degree>| degree at the
<University of Colorado Boulder, university>| university, where he also completed a research stint in
<wildlife health, field_of_study>| field_of_study. Fluent in
<English, language>| language,
<Bobby, first_name>| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
<Bobby, first_name>| first_name <Watford, last_name>| last_name, a <40, age>| age‑year‑old <Mexican, race_ethnicity>| race_ethnicity <veterinarian, occupation>| occupation living in <Denver, city>| city, <Colorado, state>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from <Jefferson High, organization_name>| organization_name, he earned his <DVM, degree>| degree at the <University of Colorado Boulder, university>| university, where he also completed a research stint in <wildlife health, field_of_study>| field_of_study. Fluent in <English, language>| language, <Bobby, first_name>| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, <Bobby, first_name>| first_name has worked at <VCA Animal Hospital, company_name>| company_name and later at the <Colorado Veterinary Clinic, company_name>| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a <Christian Democrat, political_view>| political_view and often volunteers at local shelters, a habit encouraged by his wife, <Maya, first_name>| first_name, and their two teenage children, <Aria and Leo, first_name>| first_name. Outside the clinic, <Bobby, first_name>| first_name enjoys hiking the <Rockies, place_name>| place_name with his family and mentoring veterinary students from his <alma mater, organization_name>| organization_name.
\n",
+ "Since finishing his training,
<Bobby, first_name>| first_name has worked at
<VCA Animal Hospital, organization_name>| organization_name and later at the
<Colorado Veterinary Clinic, organization_name>| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
<Christian Democrat, political_view>| political_view and often volunteers at local shelters, a habit encouraged by his wife,
<Maya, first_name>| first_name, and their two teenage children,
<Aria and Leo, first_name>| first_name. Outside the clinic,
<Bobby, first_name>| first_name enjoys hiking the
<Rockies, place_name>| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <Bobby, first_name> |
| Watford | last_name | <Watford, last_name> |
| 40 | age | <40, age> |
| Mexican | race_ethnicity | <Mexican, race_ethnicity> |
| veterinarian | occupation | <veterinarian, occupation> |
| Denver | city | <Denver, city> |
| Colorado | state | <Colorado, state> |
| Jefferson High | organization_name | <Jefferson High, organization_name> |
| DVM | degree | <DVM, degree> |
| University of Colorado Boulder | university | <University of Colorado Boulder, university> |
| wildlife health | field_of_study | <wildlife health, field_of_study> |
| English | language | <English, language> |
| VCA Animal Hospital | company_name | <VCA Animal Hospital, company_name> |
| Colorado Veterinary Clinic | company_name | <Colorado Veterinary Clinic, company_name> |
| Christian Democrat | political_view | <Christian Democrat, political_view> |
| Maya | first_name | <Maya, first_name> |
| Aria and Leo | first_name | <Aria and Leo, first_name> |
| Rockies | place_name | <Rockies, place_name> |
| alma mater | organization_name | <alma mater, organization_name> |
\n",
+ "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <Bobby, first_name> |
| Watford | last_name | <Watford, last_name> |
| 40 | age | <40, age> |
| Mexican | race_ethnicity | <Mexican, race_ethnicity> |
| veterinarian | occupation | <veterinarian, occupation> |
| Denver | city | <Denver, city> |
| Colorado | state | <Colorado, state> |
| Jefferson High | organization_name | <Jefferson High, organization_name> |
| DVM | degree | <DVM, degree> |
| University of Colorado Boulder | university | <University of Colorado Boulder, university> |
| wildlife health | field_of_study | <wildlife health, field_of_study> |
| English | language | <English, language> |
| VCA Animal Hospital | organization_name | <VCA Animal Hospital, organization_name> |
| Colorado Veterinary Clinic | organization_name | <Colorado Veterinary Clinic, organization_name> |
| Christian Democrat | political_view | <Christian Democrat, political_view> |
| Maya | first_name | <Maya, first_name> |
| Aria and Leo | first_name | <Aria and Leo, first_name> |
| Rockies | place_name | <Rockies, place_name> |
\n",
"
\n",
"
\n",
" \n",
@@ -868,7 +863,7 @@
},
{
"cell_type": "markdown",
- "id": "bc2f3721",
+ "id": "c5f4c939",
"metadata": {},
"source": [
"### Custom template\n",
@@ -879,13 +874,13 @@
{
"cell_type": "code",
"execution_count": 12,
- "id": "707b6247",
+ "id": "95e89a5e",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:19:49.519460Z",
- "iopub.status.busy": "2026-05-19T20:19:49.519324Z",
- "iopub.status.idle": "2026-05-19T20:20:20.129902Z",
- "shell.execute_reply": "2026-05-19T20:20:20.128846Z"
+ "iopub.execute_input": "2026-07-13T16:11:37.497936Z",
+ "iopub.status.busy": "2026-07-13T16:11:37.497694Z",
+ "iopub.status.idle": "2026-07-13T16:12:13.398132Z",
+ "shell.execute_reply": "2026-07-13T16:12:13.397549Z"
}
},
"outputs": [
@@ -893,56 +888,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:49] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:11:37] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:49] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:11:37] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:19:49] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:11:37] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:20:16] [INFO] |-- \ud83d\udccb Detection complete \u2014 77 entities found across 3 records (0 failed) [26.8s]\n"
+ "[11:12:12] [INFO] |-- 📋 Detection complete — 76 entities found across 3 records (0 failed) [35.3s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:20:16] [INFO] |-- labels: first_name=22, state=6, organization_name=6, age=5, occupation=5, city=5, last_name=3, race_ethnicity=3, language=3, company_name=3, political_view=3, education_level=3, religious_belief=2, street_address=2, degree=1, university=1, place_name=1, date_of_birth=1, field_of_study=1, employment_status=1\n"
+ "[11:12:12] [INFO] |-- labels: first_name=23, organization_name=7, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, language=2, political_view=2, religious_belief=2, street_address=2, place_name=1, date_of_birth=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:20:16] [INFO] \ud83d\udd04 Running Annotate replacement\n"
+ "[11:12:12] [INFO] 🔄 Running Annotate replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:20:16] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [0.0s]\n"
+ "[11:12:12] [INFO] |-- 📋 Replacement complete (0 failed) [0.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:20:16] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:12:12] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
},
{
@@ -956,19 +951,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| degree at the
University of Colorado Boulder| university, where he also completed a research stint in wildlife health. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria| first_name and
Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
<Bobby-|-first_name>| first_name <Watford-|-last_name>| last_name, a
<40-|-age>| age\u2011year\u2011old
<Mexican-|-race_ethnicity>| race_ethnicity <veterinarian-|-occupation>| occupation living in
<Denver-|-city>| city,
<Colorado-|-state>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
<Jefferson High-|-organization_name>| organization_name, he earned his
<DVM-|-degree>| degree at the
<University of Colorado Boulder-|-university>| university, where he also completed a research stint in wildlife health. Fluent in
<English-|-language>| language,
<Bobby-|-first_name>| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
<Bobby-|-first_name>| first_name <Watford-|-last_name>| last_name, a <40-|-age>| age‑year‑old <Mexican-|-race_ethnicity>| race_ethnicity <veterinarian-|-occupation>| occupation living in <Denver-|-city>| city, <Colorado-|-state>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from <Jefferson High-|-organization_name>| organization_name, he earned his <DVM-|-degree>| degree at the <University of Colorado Boulder-|-university>| university, where he also completed a research stint in <wildlife health-|-field_of_study>| field_of_study. Fluent in <English-|-language>| language, <Bobby-|-first_name>| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, <Bobby-|-first_name>| first_name has worked at <VCA Animal Hospital-|-company_name>| company_name and later at the <Colorado Veterinary Clinic-|-organization_name>| organization_name, where he now leads a busy mixed\u2011practice team. He identifies as a <Christian Democrat-|-political_view>| political_view and often volunteers at local shelters, a habit encouraged by his wife, <Maya-|-first_name>| first_name, and their two teenage children, <Aria and Leo-|-first_name>| first_name. Outside the clinic, <Bobby-|-first_name>| first_name enjoys hiking the <Rockies-|-place_name>| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
<Bobby-|-first_name>| first_name has worked at
<VCA Animal Hospital-|-organization_name>| organization_name and later at the
<Colorado Veterinary Clinic-|-organization_name>| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
<Christian Democrat-|-political_view>| political_view and often volunteers at local shelters, a habit encouraged by his wife,
<Maya-|-first_name>| first_name, and their two teenage children,
<Aria-|-first_name>| first_name and
<Leo-|-first_name>| first_name. Outside the clinic,
<Bobby-|-first_name>| first_name enjoys hiking the
<Rockies-|-place_name>| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <Bobby-|-first_name> |
| Watford | last_name | <Watford-|-last_name> |
| 40 | age | <40-|-age> |
| Mexican | race_ethnicity | <Mexican-|-race_ethnicity> |
| veterinarian | occupation | <veterinarian-|-occupation> |
| Denver | city | <Denver-|-city> |
| Colorado | state | <Colorado-|-state> |
| Jefferson High | organization_name | <Jefferson High-|-organization_name> |
| DVM | degree | <DVM-|-degree> |
| University of Colorado Boulder | university | <University of Colorado Boulder-|-university> |
| English | language | <English-|-language> |
| VCA Animal Hospital | company_name | <VCA Animal Hospital-|-company_name> |
| Colorado Veterinary Clinic | organization_name | <Colorado Veterinary Clinic-|-organization_name> |
| Christian Democrat | political_view | <Christian Democrat-|-political_view> |
| Maya | first_name | <Maya-|-first_name> |
| Aria and Leo | first_name | <Aria and Leo-|-first_name> |
| Rockies | place_name | <Rockies-|-place_name> |
\n",
+ "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <Bobby-|-first_name> |
| Watford | last_name | <Watford-|-last_name> |
| 40 | age | <40-|-age> |
| Mexican | race_ethnicity | <Mexican-|-race_ethnicity> |
| veterinarian | occupation | <veterinarian-|-occupation> |
| Denver | city | <Denver-|-city> |
| Colorado | state | <Colorado-|-state> |
| Jefferson High | organization_name | <Jefferson High-|-organization_name> |
| DVM | degree | <DVM-|-degree> |
| University of Colorado Boulder | university | <University of Colorado Boulder-|-university> |
| wildlife health | field_of_study | <wildlife health-|-field_of_study> |
| English | language | <English-|-language> |
| VCA Animal Hospital | organization_name | <VCA Animal Hospital-|-organization_name> |
| Colorado Veterinary Clinic | organization_name | <Colorado Veterinary Clinic-|-organization_name> |
| Christian Democrat | political_view | <Christian Democrat-|-political_view> |
| Maya | first_name | <Maya-|-first_name> |
| Aria | first_name | <Aria-|-first_name> |
| Leo | first_name | <Leo-|-first_name> |
| Rockies | place_name | <Rockies-|-place_name> |
\n",
"
\n",
"
\n",
" \n",
@@ -994,10 +993,10 @@
},
{
"cell_type": "markdown",
- "id": "c3cb3610",
+ "id": "357adc73",
"metadata": {},
"source": [
- "## #\ufe0f\u20e3 Hash\n",
+ "## #️⃣ Hash\n",
"\n",
"- Deterministic -- same input always produces the same hash.\n",
"- Customize with `format_template` (must include `{digest}`),\n",
@@ -1007,13 +1006,13 @@
{
"cell_type": "code",
"execution_count": 13,
- "id": "02f0eee6",
+ "id": "90d57d42",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:20:20.133754Z",
- "iopub.status.busy": "2026-05-19T20:20:20.133531Z",
- "iopub.status.idle": "2026-05-19T20:21:43.418970Z",
- "shell.execute_reply": "2026-05-19T20:21:43.418158Z"
+ "iopub.execute_input": "2026-07-13T16:12:13.400860Z",
+ "iopub.status.busy": "2026-07-13T16:12:13.400663Z",
+ "iopub.status.idle": "2026-07-13T16:12:44.978503Z",
+ "shell.execute_reply": "2026-07-13T16:12:44.977921Z"
}
},
"outputs": [
@@ -1021,56 +1020,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:20:31] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:12:13] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:20:31] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:12:13] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:20:31] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:12:13] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:21:42] [INFO] |-- \ud83d\udccb Detection complete \u2014 78 entities found across 3 records (0 failed) [71.4s]\n"
+ "[11:12:44] [INFO] |-- 📋 Detection complete — 78 entities found across 3 records (0 failed) [30.9s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:21:42] [INFO] |-- labels: first_name=23, state=6, age=5, occupation=5, city=5, organization_name=4, last_name=3, race_ethnicity=3, language=3, company_name=3, political_view=3, education_level=3, religious_belief=2, street_address=2, school_name=1, degree=1, university=1, clinic_name=1, place_name=1, date_of_birth=1, field_of_study=1, employment_status=1\n"
+ "[11:12:44] [INFO] |-- labels: first_name=22, organization_name=8, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, political_view=4, last_name=3, race_ethnicity=3, language=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1, religious_belief=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:21:42] [INFO] \ud83d\udd04 Running Hash replacement\n"
+ "[11:12:44] [INFO] 🔄 Running Hash replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:21:42] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [0.0s]\n"
+ "[11:12:44] [INFO] |-- 📋 Replacement complete (0 failed) [0.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:21:42] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:12:44] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
},
{
@@ -1084,19 +1083,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| school_name, he earned his
DVM| degree at the
University of Colorado Boulder| university, where he also completed a research stint in wildlife health. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| clinic_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria| first_name and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria and Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
<HASH_FIRST_NAME_4a70dab2cb4d>| first_name <HASH_LAST_NAME_e2efa8a62600>| last_name, a
<HASH_AGE_d59eced1ded0>| age\u2011year\u2011old
<HASH_RACE_ETHNICITY_d108dfd1df5c>| race_ethnicity <HASH_OCCUPATION_52a469e4d8e9>| occupation living in
<HASH_CITY_fcdeb8c07d4a>| city,
<HASH_STATE_4ae62bf4e804>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
<HASH_SCHOOL_NAME_39dde416149c>| school_name, he earned his
<HASH_DEGREE_d44ae5e206d1>| degree at the
<HASH_UNIVERSITY_bca201129c41>| university, where he also completed a research stint in wildlife health. Fluent in
<HASH_LANGUAGE_ba118bf7fc9c>| language,
<HASH_FIRST_NAME_4a70dab2cb4d>| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
<HASH_FIRST_NAME_4a70dab2cb4d>| first_name <HASH_LAST_NAME_e2efa8a62600>| last_name, a <HASH_AGE_d59eced1ded0>| age‑year‑old <HASH_RACE_ETHNICITY_d108dfd1df5c>| race_ethnicity <HASH_OCCUPATION_52a469e4d8e9>| occupation living in <HASH_CITY_fcdeb8c07d4a>| city, <HASH_STATE_4ae62bf4e804>| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from <HASH_ORGANIZATION_NAME_39dde416149c>| organization_name, he earned his <HASH_DEGREE_d44ae5e206d1>| degree at the <HASH_UNIVERSITY_bca201129c41>| university, where he also completed a research stint in <HASH_FIELD_OF_STUDY_c27b00db54db>| field_of_study. Fluent in <HASH_LANGUAGE_ba118bf7fc9c>| language, <HASH_FIRST_NAME_4a70dab2cb4d>| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, <HASH_FIRST_NAME_4a70dab2cb4d>| first_name has worked at <HASH_COMPANY_NAME_56e3eb3da5fa>| company_name and later at the <HASH_CLINIC_NAME_b45afd893ae9>| clinic_name, where he now leads a busy mixed\u2011practice team. He identifies as a <HASH_POLITICAL_VIEW_1eba4d0314c9>| political_view and often volunteers at local shelters, a habit encouraged by his wife, <HASH_FIRST_NAME_031e45c699d1>| first_name, and their two teenage children, <HASH_FIRST_NAME_736001faca59>| first_name and <HASH_FIRST_NAME_5bc426e8d81e>| first_name. Outside the clinic, <HASH_FIRST_NAME_4a70dab2cb4d>| first_name enjoys hiking the <HASH_PLACE_NAME_d706f1c04961>| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
<HASH_FIRST_NAME_4a70dab2cb4d>| first_name has worked at
<HASH_ORGANIZATION_NAME_56e3eb3da5fa>| organization_name and later at the
<HASH_ORGANIZATION_NAME_b45afd893ae9>| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
<HASH_POLITICAL_VIEW_1eba4d0314c9>| political_view and often volunteers at local shelters, a habit encouraged by his wife,
<HASH_FIRST_NAME_031e45c699d1>| first_name, and their two teenage children,
<HASH_FIRST_NAME_b4c3f91ad0ce>| first_name. Outside the clinic,
<HASH_FIRST_NAME_4a70dab2cb4d>| first_name enjoys hiking the
<HASH_PLACE_NAME_d706f1c04961>| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <HASH_FIRST_NAME_4a70dab2cb4d> |
| Watford | last_name | <HASH_LAST_NAME_e2efa8a62600> |
| 40 | age | <HASH_AGE_d59eced1ded0> |
| Mexican | race_ethnicity | <HASH_RACE_ETHNICITY_d108dfd1df5c> |
| veterinarian | occupation | <HASH_OCCUPATION_52a469e4d8e9> |
| Denver | city | <HASH_CITY_fcdeb8c07d4a> |
| Colorado | state | <HASH_STATE_4ae62bf4e804> |
| Jefferson High | school_name | <HASH_SCHOOL_NAME_39dde416149c> |
| DVM | degree | <HASH_DEGREE_d44ae5e206d1> |
| University of Colorado Boulder | university | <HASH_UNIVERSITY_bca201129c41> |
| English | language | <HASH_LANGUAGE_ba118bf7fc9c> |
| VCA Animal Hospital | company_name | <HASH_COMPANY_NAME_56e3eb3da5fa> |
| Colorado Veterinary Clinic | clinic_name | <HASH_CLINIC_NAME_b45afd893ae9> |
| Christian Democrat | political_view | <HASH_POLITICAL_VIEW_1eba4d0314c9> |
| Maya | first_name | <HASH_FIRST_NAME_031e45c699d1> |
| Aria | first_name | <HASH_FIRST_NAME_736001faca59> |
| Leo | first_name | <HASH_FIRST_NAME_5bc426e8d81e> |
| Rockies | place_name | <HASH_PLACE_NAME_d706f1c04961> |
\n",
+ "
| Original | Label | Replacement |
|---|
| Bobby | first_name | <HASH_FIRST_NAME_4a70dab2cb4d> |
| Watford | last_name | <HASH_LAST_NAME_e2efa8a62600> |
| 40 | age | <HASH_AGE_d59eced1ded0> |
| Mexican | race_ethnicity | <HASH_RACE_ETHNICITY_d108dfd1df5c> |
| veterinarian | occupation | <HASH_OCCUPATION_52a469e4d8e9> |
| Denver | city | <HASH_CITY_fcdeb8c07d4a> |
| Colorado | state | <HASH_STATE_4ae62bf4e804> |
| Jefferson High | organization_name | <HASH_ORGANIZATION_NAME_39dde416149c> |
| DVM | degree | <HASH_DEGREE_d44ae5e206d1> |
| University of Colorado Boulder | university | <HASH_UNIVERSITY_bca201129c41> |
| wildlife health | field_of_study | <HASH_FIELD_OF_STUDY_c27b00db54db> |
| English | language | <HASH_LANGUAGE_ba118bf7fc9c> |
| VCA Animal Hospital | organization_name | <HASH_ORGANIZATION_NAME_56e3eb3da5fa> |
| Colorado Veterinary Clinic | organization_name | <HASH_ORGANIZATION_NAME_b45afd893ae9> |
| Christian Democrat | political_view | <HASH_POLITICAL_VIEW_1eba4d0314c9> |
| Maya | first_name | <HASH_FIRST_NAME_031e45c699d1> |
| Aria and Leo | first_name | <HASH_FIRST_NAME_b4c3f91ad0ce> |
| Rockies | place_name | <HASH_PLACE_NAME_d706f1c04961> |
\n",
"
\n",
"
\n",
" \n",
@@ -1124,7 +1127,7 @@
},
{
"cell_type": "markdown",
- "id": "454eec25",
+ "id": "e0da05b4",
"metadata": {},
"source": [
"### Custom template\n",
@@ -1135,13 +1138,13 @@
{
"cell_type": "code",
"execution_count": 14,
- "id": "52fa4a1a",
+ "id": "5d261f2f",
"metadata": {
"execution": {
- "iopub.execute_input": "2026-05-19T20:21:43.422880Z",
- "iopub.status.busy": "2026-05-19T20:21:43.422662Z",
- "iopub.status.idle": "2026-05-19T20:22:18.872066Z",
- "shell.execute_reply": "2026-05-19T20:22:18.871209Z"
+ "iopub.execute_input": "2026-07-13T16:12:44.981259Z",
+ "iopub.status.busy": "2026-07-13T16:12:44.981017Z",
+ "iopub.status.idle": "2026-07-13T16:13:21.026645Z",
+ "shell.execute_reply": "2026-07-13T16:13:21.026169Z"
},
"lines_to_next_cell": 2
},
@@ -1150,56 +1153,56 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:21:43] [INFO] \ud83d\udc40 Preview mode: \ud83d\udcc2 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ "[11:12:45] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:21:43] [INFO] \ud83d\udd0d Running entity detection on 3 records\n"
+ "[11:12:45] [INFO] 🔍 Running entity detection on 3 records\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:21:43] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ "[11:12:45] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:22:18] [INFO] |-- \ud83d\udccb Detection complete \u2014 76 entities found across 3 records (0 failed) [34.9s]\n"
+ "[11:13:20] [INFO] |-- 📋 Detection complete — 78 entities found across 3 records (0 failed) [35.4s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:22:18] [INFO] |-- labels: first_name=22, state=6, age=5, occupation=5, city=5, organization_name=4, company_name=4, last_name=3, race_ethnicity=3, language=3, political_view=3, degree=2, field_of_study=2, education_level=2, street_address=2, university=1, place_name=1, date_of_birth=1, employment_status=1, religious_belief=1\n"
+ "[11:13:20] [INFO] |-- labels: first_name=22, organization_name=8, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, political_view=3, language=2, religious_belief=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:22:18] [INFO] \ud83d\udd04 Running Hash replacement\n"
+ "[11:13:20] [INFO] 🔄 Running Hash replacement\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:22:18] [INFO] |-- \ud83d\udccb Replacement complete (0 failed) [0.0s]\n"
+ "[11:13:20] [INFO] |-- 📋 Replacement complete (0 failed) [0.0s]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "[13:22:18] [INFO] \ud83c\udf89 Pipeline complete \u2014 3 records processed, 0 total failures\n"
+ "[11:13:20] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
]
},
{
@@ -1213,19 +1216,23 @@
" \n",
"
\n",
"
Original
\n",
- "
Bobby| first_name Watford| last_name, a
40| age\u2011year\u2011old
Mexican| race_ethnicity veterinarian| occupation living in
Denver| city,
Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
Jefferson High| organization_name, he earned his
DVM| degree at the
University of Colorado Boulder| university, where he also completed a research stint in
wildlife health| field_of_study. Fluent in
English| language,
Bobby| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
Bobby| first_name has worked at
VCA Animal Hospital| organization_name and later at the
Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife,
Maya| first_name, and their two teenage children,
Aria and Leo| first_name. Outside the clinic,
Bobby| first_name enjoys hiking the
Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
"
\n",
"
Replaced
\n",
- "
[657b3da9]| first_name [6e424e2c]| last_name, a
[d645920e]| age\u2011year\u2011old
[a0e769d8]| race_ethnicity [84c99b4a]| occupation living in
[67100af8]| city,
[15e49475]| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from
[27c56955]| organization_name, he earned his
[47211f54]| degree at the
[e2b97348]| university, where he also completed a research stint in
[7b2947bb]| field_of_study. Fluent in
[78463a38]| language,
[657b3da9]| first_name has always described his upbringing as a blend of small\u2011town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "
[657b3da9]| first_name [6e424e2c]| last_name, a [d645920e]| age‑year‑old [a0e769d8]| race_ethnicity [84c99b4a]| occupation living in [67100af8]| city, [15e49475]| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from [27c56955]| organization_name, he earned his [47211f54]| degree at the [e2b97348]| university, where he also completed a research stint in [7b2947bb]| field_of_study. Fluent in [78463a38]| language, [657b3da9]| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
"\n",
- "Since finishing his training, [657b3da9]| first_name has worked at [3541ebe8]| company_name and later at the [cd3abcd1]| company_name, where he now leads a busy mixed\u2011practice team. He identifies as a [408d2599]| political_view and often volunteers at local shelters, a habit encouraged by his wife, [719fe280]| first_name, and their two teenage children, [0efaeae5]| first_name. Outside the clinic, [657b3da9]| first_name enjoys hiking the [661f0bd9]| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "Since finishing his training,
[657b3da9]| first_name has worked at
[3541ebe8]| organization_name and later at the
[cd3abcd1]| organization_name, where he now leads a busy mixed‑practice team. He identifies as a
[408d2599]| political_view and often volunteers at local shelters, a habit encouraged by his wife,
[719fe280]| first_name, and their two teenage children,
[0efaeae5]| first_name. Outside the clinic,
[657b3da9]| first_name enjoys hiking the
[661f0bd9]| place_name with his family and mentoring veterinary students from his alma mater.
\n",
"
\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
"
\n",
"
Replacement Map
\n",
- "
| Original | Label | Replacement |
|---|
| Bobby | first_name | [657b3da9] |
| Watford | last_name | [6e424e2c] |
| 40 | age | [d645920e] |
| Mexican | race_ethnicity | [a0e769d8] |
| veterinarian | occupation | [84c99b4a] |
| Denver | city | [67100af8] |
| Colorado | state | [15e49475] |
| Jefferson High | organization_name | [27c56955] |
| DVM | degree | [47211f54] |
| University of Colorado Boulder | university | [e2b97348] |
| wildlife health | field_of_study | [7b2947bb] |
| English | language | [78463a38] |
| VCA Animal Hospital | company_name | [3541ebe8] |
| Colorado Veterinary Clinic | company_name | [cd3abcd1] |
| Christian Democrat | political_view | [408d2599] |
| Maya | first_name | [719fe280] |
| Aria and Leo | first_name | [0efaeae5] |
| Rockies | place_name | [661f0bd9] |
\n",
+ "
| Original | Label | Replacement |
|---|
| Bobby | first_name | [657b3da9] |
| Watford | last_name | [6e424e2c] |
| 40 | age | [d645920e] |
| Mexican | race_ethnicity | [a0e769d8] |
| veterinarian | occupation | [84c99b4a] |
| Denver | city | [67100af8] |
| Colorado | state | [15e49475] |
| Jefferson High | organization_name | [27c56955] |
| DVM | degree | [47211f54] |
| University of Colorado Boulder | university | [e2b97348] |
| wildlife health | field_of_study | [7b2947bb] |
| English | language | [78463a38] |
| VCA Animal Hospital | organization_name | [3541ebe8] |
| Colorado Veterinary Clinic | organization_name | [cd3abcd1] |
| Christian Democrat | political_view | [408d2599] |
| Maya | first_name | [719fe280] |
| Aria and Leo | first_name | [0efaeae5] |
| Rockies | place_name | [661f0bd9] |
\n",
"
\n",
"
\n",
" \n",
@@ -1251,23 +1258,72 @@
},
{
"cell_type": "markdown",
- "id": "deab7d5d",
+ "id": "8d36bdcc",
"metadata": {},
"source": [
- "## \ud83d\udcca (Optional) Evaluate each strategy\n",
+ "## 📊 (Optional) Evaluate each strategy\n",
"\n",
"- `evaluate()` is a separate, opt-in step that scores the output with LLM-as-judge metrics. Which metrics fire depends on the strategy:\n",
- " - **Substitute** \u2192 4 metrics (Detection Validity + Type Fidelity + Relational Consistency + Attribute Fidelity).\n",
- " - **Redact / Annotate / Hash** \u2192 Detection Validity only (no replacement map to score type/relational/attribute against).\n",
+ " - **Substitute** → 4 metrics (Detection Validity + Type Fidelity + Relational Consistency + Attribute Fidelity).\n",
+ " - **Redact / Annotate / Hash** → Detection Validity only (no replacement map to score type/relational/attribute against).\n",
"- Below shows it on the Substitute preview to surface all four; the same call works on `redact_preview`, `annotate_preview`, or `hash_preview`."
]
},
{
"cell_type": "code",
- "execution_count": null,
- "id": "5a21beab",
- "metadata": {},
- "outputs": [],
+ "execution_count": 15,
+ "id": "7293f969",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:13:21.029098Z",
+ "iopub.status.busy": "2026-07-13T16:13:21.028905Z",
+ "iopub.status.idle": "2026-07-13T16:13:57.528275Z",
+ "shell.execute_reply": "2026-07-13T16:13:57.528071Z"
+ },
+ "lines_to_next_cell": 2
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Preview (record 0)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| organization_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
\n",
+ "
Replaced
\n",
+ "
Ethan| first_name Keller| last_name, a 45| age‑year‑old Filipino| race_ethnicity zoologist| occupation living in Portland| city, Oregon| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Willamette High| organization_name, he earned his Doctor of Osteopathic Medicine (DO)| degree at the Oregon State University| university, where he also completed a research stint in conservation genetics| field_of_study. Fluent in Spanish| language, Ethan| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Ethan| first_name has worked at Pacific Animal Hospital| organization_name and later at the Oregon Veterinary Center| organization_name, where he now leads a busy mixed‑practice team. He identifies as a Libertarian| political_view and often volunteers at local shelters, a habit encouraged by his wife, Sofia| first_name, and their two teenage children, Nina and Omar| first_name. Outside the clinic, Ethan| first_name enjoys hiking the Cascades| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
Detection Judge
Detection Validity: Partially Satisfied (LLM alignment score: 17/18)
LLM alignment score: The level of alignment between the detection and evaluation LLMs across entity classification, attributes, and relationships.
Show 1 flagged entity(ies)
| Value | Label | Reason |
|---|
| Aria and Leo | first_name | wrong_boundary: the span contains two separate first names joined by a conjunction, not a single first name. |
\n",
+ "
Type Fidelity
Type Fidelity: Satisfied (LLM alignment score: 18/18)
\n",
+ "
Attribute Fidelity
Attribute Fidelity: Satisfied (LLM alignment score: 4/4)
Show 4 evaluated entity(ies)
| Original | Label | Synthetic | Attributes | Status | Reason |
|---|
| 40 | age | 45 | age_bucket | Pass | The synthetic age stays in an adjacent bucket (adult→middle‑aged), so the age bucket is preserved. |
| Aria and Leo | first_name | Nina and Omar | gender | Pass | Both original names (female Aria, male Leo) keep their genders in the synthetic names (female Nina, male Omar). |
| Bobby | first_name | Ethan | gender | Pass | The original male name Bobby is replaced with another male name Ethan, preserving gender. |
| Maya | first_name | Sofia | gender | Pass | The original female name Maya is replaced with another female name Sofia, preserving gender. |
\n",
+ "
Relational Consistency
Relational Consistency: Partially Satisfied (LLM alignment score: 7/8)
Show 8 checked relation(s)
| Relation | Entities | Status | Reason |
|---|
| city <-> state | Denver (city) -> Portland, Colorado (state) -> Oregon | Pass | Portland is a city located in the state of Oregon. |
| first_name <-> pronouns | Bobby (first_name) -> Ethan | Pass | The pronouns "he/his" in the text match the male name Ethan. |
| occupation <-> degree | veterinarian (occupation) -> zoologist, DVM (degree) -> Doctor of Osteopathic Medicine (DO) | Fail | A zoologist would not typically hold a Doctor of Osteopathic Medicine (DO) degree, creating a clear mismatch. |
| occupation <-> field_of_study | veterinarian (occupation) -> zoologist, wildlife health (field_of_study) -> conservation genetics | Pass | Conservation genetics is a relevant field of study for a zoologist. |
| occupation <-> organization_name (Pacific Animal Hospital) | veterinarian (occupation) -> zoologist, VCA Animal Hospital (organization_name) -> Pacific Animal Hospital | Pass | A zoologist could plausibly work at an animal hospital. |
| occupation <-> organization_name (Oregon Veterinary Center) | veterinarian (occupation) -> zoologist, Colorado Veterinary Clinic (organization_name) -> Oregon Veterinary Center | Pass | A zoologist could plausibly work at a veterinary center. |
| age <-> occupation | 40 (age) -> 45, veterinarian (occupation) -> zoologist | Pass | A 45‑year‑old individual can reasonably be a zoologist. |
| age <-> degree | 40 (age) -> 45, DVM (degree) -> Doctor of Osteopathic Medicine (DO) | Pass | A 45‑year‑old person can plausibly hold a DO medical degree. |
\n",
+ "
\n",
+ "
Replacement Map
\n",
+ "
| Original | Label | Replacement |
|---|
| 40 | age | 45 |
| Aria and Leo | first_name | Nina and Omar |
| Bobby | first_name | Ethan |
| Christian Democrat | political_view | Libertarian |
| Colorado | state | Oregon |
| Colorado Veterinary Clinic | organization_name | Oregon Veterinary Center |
| DVM | degree | Doctor of Osteopathic Medicine (DO) |
| Denver | city | Portland |
| English | language | Spanish |
| Jefferson High | organization_name | Willamette High |
| Maya | first_name | Sofia |
| Mexican | race_ethnicity | Filipino |
| Rockies | place_name | Cascades |
| University of Colorado Boulder | university | Oregon State University |
| VCA Animal Hospital | organization_name | Pacific Animal Hospital |
| Watford | last_name | Keller |
| veterinarian | occupation | zoologist |
| wildlife health | field_of_study | conservation genetics |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"substitute_evaluated = anonymizer.evaluate(substitute_preview)\n",
"substitute_evaluated.display_record(0)"
@@ -1275,16 +1331,16 @@
},
{
"cell_type": "markdown",
- "id": "eeb153ba",
+ "id": "38201a9b",
"metadata": {},
"source": [
- "## \u23ed\ufe0f Next steps\n",
+ "## ⏭️ Next steps\n",
"\n",
- "- **[\ud83d\udd75\ufe0f Inspecting Detected Entities](../02_inspecting_detected_entities/)** --\n",
+ "- **[🕵️ Inspecting Detected Entities](../02_inspecting_detected_entities/)** --\n",
" dig into what the detection pipeline found and debug quality.\n",
- "- **[\u270f\ufe0f Rewriting Biographies](../04_rewriting_biographies/)** --\n",
+ "- **[✏️ Rewriting Biographies](../04_rewriting_biographies/)** --\n",
" generate privacy-safe paraphrases instead of token-level replacements.\n",
- "- **[\u2696\ufe0f Rewriting Legal Documents](../05_rewriting_legal_documents/)** --\n",
+ "- **[⚖️ Rewriting Legal Documents](../05_rewriting_legal_documents/)** --\n",
" rewrite legal text with domain-specific privacy goals."
]
}
diff --git a/docs/notebooks/04_rewriting_biographies.ipynb b/docs/notebooks/04_rewriting_biographies.ipynb
index 67fd1532..aad8be15 100644
--- a/docs/notebooks/04_rewriting_biographies.ipynb
+++ b/docs/notebooks/04_rewriting_biographies.ipynb
@@ -1,830 +1,1015 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "77da6ea6",
- "metadata": {},
- "source": [
- "# 🕵️ Rewriting Biographies\n",
- "\n",
- "Instead of replacing entities with tokens, rewrite mode generates a\n",
- "privacy-safe transformation of the entire text. The pipeline:\n",
- "\n",
- "1. Detects entities (same as replace mode, plus latent entity detection)\n",
- "2. Classifies the domain and assigns sensitivity dispositions\n",
- "3. Generates a rewritten version that obscures sensitive entities\n",
- "4. Evaluates quality (utility) and privacy (leakage) with an automated repair loop\n",
- "\n",
- "After `run()`, call `Anonymizer.evaluate()` for optional LLM-as-judge scoring.\n",
- "\n",
- "#### 📚 What you'll learn\n",
- "\n",
- "- Configure rewrite mode with `PrivacyGoal` to specify what to protect and what to preserve\n",
- "- Set evaluation criteria and risk tolerance for automated quality checks\n",
- "- Preview rewritten text and inspect utility / leakage scores\n",
- "- Triage flagged records with `needs_human_review`\n",
- "- Run `evaluate()` for detection validity and holistic judge scores (privacy, quality, style)\n",
- "\n",
- "> **Tip:** First time running notebooks? Start with\n",
- "> [setup instructions](https://nvidia-nemo.github.io/Anonymizer/latest/tutorials/)."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "d3035c6c",
- "metadata": {
- "lines_to_next_cell": 0
- },
- "source": [
- "## ⚙️ Setup\n",
- "\n",
- "- Check if your `NVIDIA_API_KEY` from [build.nvidia.com](https://build.nvidia.com) is registered for model access.\n",
- " - The default `build.nvidia.com` (NVIDIA Build) setup is a convenient way to try Anonymizer and iterate on previews. Use of NVIDIA Build is subject to NVIDIA Build's own terms of service and privacy practices, which are separate from and independent of the NeMo Framework library. NVIDIA Build is intended for evaluation and testing purposes only and may not be used in production environments. Do not upload any confidential information or personal data when using NVIDIA Build. Your use of NVIDIA Build is logged for security purposes and to improve NVIDIA products and services.\n",
- " - Request and token rate limits on `build.nvidia.com` vary by account and model access, and lower-volume development access can be slow for full-dataset runs. Start with `preview()` on a small sample, then move to your own endpoint for production data and usage.\n",
- "- Import `Rewrite` and `PrivacyGoal`.\n",
- "- `Anonymizer()` initializes with the default model provider -- no extra config needed.\n",
- "- `configure_logging(LoggingConfig.default())` keeps logs at INFO. Switch to `LoggingConfig.debug()` when troubleshooting.\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "id": "4f1bc6fa",
- "metadata": {},
- "outputs": [],
- "source": [
- "import getpass\n",
- "import os\n",
- "\n",
- "if not os.getenv(\"NVIDIA_API_KEY\"):\n",
- " key = getpass.getpass(\"Enter NVIDIA_API_KEY from build.nvidia.com: \").strip()\n",
- " if not key:\n",
- " raise RuntimeError(\"NVIDIA_API_KEY is required to run these notebooks.\")\n",
- " os.environ[\"NVIDIA_API_KEY\"] = key"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "d90c1cab",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T20:46:41.243043Z",
- "iopub.status.busy": "2026-04-03T20:46:41.242973Z",
- "iopub.status.idle": "2026-04-03T20:46:53.000855Z",
- "shell.execute_reply": "2026-04-03T20:46:53.000061Z"
- }
- },
- "outputs": [],
- "source": [
- "from anonymizer import (\n",
- " Anonymizer,\n",
- " AnonymizerConfig,\n",
- " AnonymizerInput,\n",
- " LoggingConfig,\n",
- " PrivacyGoal,\n",
- " Rewrite,\n",
- " configure_logging,\n",
- ")\n",
- "\n",
- "configure_logging(LoggingConfig.default())"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "id": "818ee820",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T20:46:53.004480Z",
- "iopub.status.busy": "2026-04-03T20:46:53.003891Z",
- "iopub.status.idle": "2026-04-03T20:46:53.046029Z",
- "shell.execute_reply": "2026-04-03T20:46:53.045508Z"
- }
- },
- "outputs": [
+ "cells": [
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "[16:06:37] [INFO] 🔧 Anonymizer initialized with 3 model configs\n",
- "[16:06:37] [INFO] |-- 🔎 detector: gliner-pii-detector\n",
- "[16:06:37] [INFO] |-- ✅ validator: gpt-oss-120b\n",
- "[16:06:37] [INFO] |-- 🧩 augmenter: gpt-oss-120b\n"
- ]
- }
- ],
- "source": [
- "anonymizer = Anonymizer()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "0506e3ae",
- "metadata": {},
- "source": [
- "## 📦 Input data\n",
- "\n",
- "- Same biographies dataset used in earlier notebooks -- familiar data makes it\n",
- " easy to compare rewrite output against replace output."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "id": "f340b90c",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T20:46:53.048813Z",
- "iopub.status.busy": "2026-04-03T20:46:53.048634Z",
- "iopub.status.idle": "2026-04-03T20:46:53.051600Z",
- "shell.execute_reply": "2026-04-03T20:46:53.051217Z"
- }
- },
- "outputs": [],
- "source": [
- "input_data = AnonymizerInput(\n",
- " source=\"https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv\",\n",
- " text_column=\"biography\",\n",
- " data_summary=\"Biographical profiles\",\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "a54f59db",
- "metadata": {},
- "source": [
- "## 🎛️ Configure\n",
- "\n",
- "- `PrivacyGoal` spells out what to **protect** and what to **preserve** --\n",
- " this gives the rewriter clear, domain-specific guidance.\n",
- "- `risk_tolerance` (default `\"low\"`) and `max_repair_iterations` (default `3`)\n",
- " control the automated quality gate --\n",
- " see [Risk tolerance](../../concepts/rewrite/#risk-tolerance) for presets."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "id": "48052047",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T20:46:53.053443Z",
- "iopub.status.busy": "2026-04-03T20:46:53.053293Z",
- "iopub.status.idle": "2026-04-03T20:46:53.055578Z",
- "shell.execute_reply": "2026-04-03T20:46:53.055274Z"
- }
- },
- "outputs": [],
- "source": [
- "config = AnonymizerConfig(\n",
- " rewrite=Rewrite(\n",
- " privacy_goal=PrivacyGoal(\n",
- " protect=\"All direct identifiers and quasi-identifier combinations (names, locations, employers, dates)\",\n",
- " preserve=\"Career trajectory, educational background, and professional accomplishments\",\n",
- " ),\n",
- " ),\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "cb1b413f",
- "metadata": {},
- "source": [
- "## 👁️ Preview\n",
- "\n",
- "- `preview()` runs on a small sample so you can iterate on privacy goals\n",
- " and evaluation criteria before committing to a full run."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "id": "151d4872",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T20:46:53.057242Z",
- "iopub.status.busy": "2026-04-03T20:46:53.057110Z",
- "iopub.status.idle": "2026-04-03T20:52:04.705109Z",
- "shell.execute_reply": "2026-04-03T20:52:04.704823Z"
- }
- },
- "outputs": [
+ "cell_type": "markdown",
+ "id": "b895b80d",
+ "metadata": {},
+ "source": [
+ "\n",
+ "# 🕵️ Rewriting Biographies\n",
+ "\n",
+ "Instead of replacing entities with tokens, rewrite mode generates a\n",
+ "privacy-safe transformation of the entire text. The `run()` / `preview()` pipeline:\n",
+ "\n",
+ "1. Detects entities (same as replace mode, plus latent entity detection)\n",
+ "2. Classifies the domain and assigns sensitivity dispositions\n",
+ "3. Generates a rewritten version that obscures sensitive entities\n",
+ "4. Evaluates quality (utility) and privacy (leakage) with an automated repair loop\n",
+ "\n",
+ "Afterward, a separate optional `evaluate()` call runs LLM judges for\n",
+ "detection validity and holistic privacy, quality, and style scores.\n",
+ "\n",
+ "\n",
+ "#### 📚 What you'll learn\n",
+ "\n",
+ "- Configure rewrite mode with `PrivacyGoal` to specify what to protect and what to preserve\n",
+ "- Set evaluation criteria and risk tolerance for automated quality checks\n",
+ "- Preview rewritten text and inspect utility / leakage scores\n",
+ "- Triage flagged records with `needs_human_review`\n",
+ "- Run `evaluate()` for detection validity and holistic judge scores (privacy, quality, style)\n",
+ "\n",
+ "> **Tip:** First time running notebooks? Start with\n",
+ "> [setup instructions](https://nvidia-nemo.github.io/Anonymizer/latest/tutorials/)."
+ ]
+ },
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "[16:06:46] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n",
- "[16:06:46] [INFO] 🔍 Running entity detection on 3 records\n",
- "[16:07:58] [INFO] |-- 📋 Detection complete — 78 entities found across 3 records (0 failed) [72.5s]\n",
- "[16:07:58] [INFO] |-- labels: first_name=22, state=6, organization_name=6, age=5, occupation=5, city=5, political_view=4, last_name=3, race_ethnicity=3, language=3, company_name=3, degree=2, field_of_study=2, education_level=2, street_address=2, place_name=1, date_of_birth=1, project_name=1, employment_status=1, religious_belief=1\n",
- "[16:07:58] [INFO] ✏️ Running rewrite pipeline\n",
- "[16:10:14] [INFO] Evaluate-repair loop: all rows pass at iteration 0\n",
- "[16:10:32] [INFO] |-- 📋 Rewrite complete (0 failed) [154.1s]\n",
- "[16:10:32] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
- ]
+ "cell_type": "markdown",
+ "id": "50d3acc9",
+ "metadata": {},
+ "source": [
+ "## ⚙️ Setup\n",
+ "\n",
+ "- Check if your `NVIDIA_API_KEY` from [build.nvidia.com](https://build.nvidia.com) is registered for model access.\n",
+ " - The default `build.nvidia.com` (NVIDIA Build) setup is a convenient way to try Anonymizer and iterate on previews. Use of NVIDIA Build is subject to NVIDIA Build's own terms of service and privacy practices, which are separate from and independent of the NeMo Framework library. NVIDIA Build is intended for evaluation and testing purposes only and may not be used in production environments. Do not upload any confidential information or personal data when using NVIDIA Build. Your use of NVIDIA Build is logged for security purposes and to improve NVIDIA products and services.\n",
+ " - Request and token rate limits on `build.nvidia.com` vary by account and model access, and lower-volume development access can be slow for full-dataset runs. Start with `preview()` on a small sample, then move to your own endpoint for production data and usage.\n",
+ "- Import `Rewrite` and `PrivacyGoal`.\n",
+ "- `Anonymizer()` initializes with the default model provider -- no extra config needed.\n",
+ "- `configure_logging(LoggingConfig.default())` keeps logs at INFO. Switch to `LoggingConfig.debug()` when troubleshooting."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "0b54dc89",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:14:00.282142Z",
+ "iopub.status.busy": "2026-07-13T16:14:00.281822Z",
+ "iopub.status.idle": "2026-07-13T16:14:00.286017Z",
+ "shell.execute_reply": "2026-07-13T16:14:00.285339Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "import getpass\n",
+ "import os\n",
+ "\n",
+ "if not os.getenv(\"NVIDIA_API_KEY\"):\n",
+ " key = getpass.getpass(\"Enter NVIDIA_API_KEY from build.nvidia.com: \").strip()\n",
+ " if not key:\n",
+ " raise RuntimeError(\"NVIDIA_API_KEY is required to run these notebooks.\")\n",
+ " os.environ[\"NVIDIA_API_KEY\"] = key"
+ ]
},
{
- "data": {
- "text/html": [
- "\n",
- "
\n",
- "
\n",
- " Anonymizer Rewrite Preview (record 0)\n",
- "
\n",
- "
\n",
- "
\n",
- "
Original
\n",
- "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| organization_name, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
- "\n",
- "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| company_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
- "
\n",
- "
\n",
- "
Rewritten
\n",
- "
Ethan Hawthorne, a 40‑year‑old Latinx veterinarian living in a city in Colorado, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High, he earned his DVM at a state university, where he also completed a research stint in wildlife health. Fluent in English, Ethan has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
- "\n",
- "Since finishing his training, Ethan has worked at a veterinary practice and later at a regional veterinary clinic, where he now leads a busy mixed‑practice team. He identifies as having a moderate political view and often volunteers at local shelters, a habit encouraged by his wife, Leah, and their two teenage children, Sofia and Mateo. Outside the clinic, Ethan enjoys hiking the Rockies with his family and mentoring veterinary students from his alma mater.
\n",
- "
\n",
- "
\n",
- "
Scores
\n",
- "
Utility: 0.96Leakage: 0.00Weighted Leakage Rate: 0.00Needs Review: NoJudge: privacy: 8/10, quality: 9/10, naturalness: 9/10
\n",
- "
\n",
- "
\n",
- "
Entity Disposition
\n",
- "
| Entity | Label | Sensitivity | Protection |
|---|
| Bobby | first_name | high | replace |
| Watford | last_name | high | replace |
| Maya | first_name | high | replace |
| Aria and Leo | first_name | high | replace |
| Mexican | race_ethnicity | high | generalize |
| Denver | city | medium | generalize |
| University of Colorado Boulder | organization_name | medium | generalize |
| Colorado Veterinary Clinic | organization_name | medium | generalize |
| VCA Animal Hospital | company_name | medium | generalize |
| Christian Democrat | political_view | medium | generalize |
| 40 | age | medium | leave_as_is |
| Jefferson High | organization_name | medium | leave_as_is |
| DVM | degree | medium | leave_as_is |
| wildlife health | field_of_study | low | leave_as_is |
| English | language | low | leave_as_is |
| Rockies | place_name | low | leave_as_is |
| veterinarian | occupation | low | leave_as_is |
| Colorado | state | low | leave_as_is |
| married | marital_status | high | leave_as_is |
| doctoral | education_level | low | leave_as_is |
\n",
- "
\n",
- "
\n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "1f0bd3a0",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:14:00.288332Z",
+ "iopub.status.busy": "2026-07-13T16:14:00.288174Z",
+ "iopub.status.idle": "2026-07-13T16:14:00.290947Z",
+ "shell.execute_reply": "2026-07-13T16:14:00.290741Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "from anonymizer import (\n",
+ " Anonymizer,\n",
+ " AnonymizerConfig,\n",
+ " AnonymizerInput,\n",
+ " LoggingConfig,\n",
+ " PrivacyGoal,\n",
+ " Rewrite,\n",
+ " configure_logging,\n",
+ ")\n",
+ "\n",
+ "configure_logging(LoggingConfig.default())"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "2819b834",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:14:00.291935Z",
+ "iopub.status.busy": "2026-07-13T16:14:00.291878Z",
+ "iopub.status.idle": "2026-07-13T16:14:00.322110Z",
+ "shell.execute_reply": "2026-07-13T16:14:00.321969Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:14:00] [INFO] 🔧 Anonymizer initialized with 3 model configs\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:14:00] [INFO] |-- 🔎 detector: gliner-pii-detector\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:14:00] [INFO] |-- ✅ validator: gpt-oss-120b\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:14:00] [INFO] |-- 🧩 augmenter: gpt-oss-120b\n"
+ ]
+ }
],
- "text/plain": [
- ""
+ "source": [
+ "anonymizer = Anonymizer()"
]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "preview = anonymizer.preview(\n",
- " config=config,\n",
- " data=input_data,\n",
- " num_records=3,\n",
- ")\n",
- "\n",
- "preview.display_record(0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "id": "919d1149",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T20:52:04.706776Z",
- "iopub.status.busy": "2026-04-03T20:52:04.706685Z",
- "iopub.status.idle": "2026-04-03T20:52:04.709327Z",
- "shell.execute_reply": "2026-04-03T20:52:04.709116Z"
- }
- },
- "outputs": [
+ },
+ {
+ "cell_type": "markdown",
+ "id": "db25cb4e",
+ "metadata": {},
+ "source": [
+ "## 📦 Input data\n",
+ "\n",
+ "- Same biographies dataset used in earlier notebooks -- familiar data makes it\n",
+ " easy to compare rewrite output against replace output."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "6970b389",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:14:00.323775Z",
+ "iopub.status.busy": "2026-07-13T16:14:00.323703Z",
+ "iopub.status.idle": "2026-07-13T16:14:00.325235Z",
+ "shell.execute_reply": "2026-07-13T16:14:00.325043Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "input_data = AnonymizerInput(\n",
+ " source=\"https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv\",\n",
+ " text_column=\"biography\",\n",
+ " data_summary=\"Biographical profiles\",\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "98130e93",
+ "metadata": {},
+ "source": [
+ "## 🎛️ Configure\n",
+ "\n",
+ "- `PrivacyGoal` spells out what to **protect** and what to **preserve** --\n",
+ " this gives the rewriter clear, domain-specific guidance.\n",
+ "- `risk_tolerance` (default `\"low\"`) and `max_repair_iterations` (default `3`)\n",
+ " control the automated quality gate --\n",
+ " see [Risk tolerance](../../concepts/rewrite/#risk-tolerance) for presets."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "aa3d40bf",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:14:00.326192Z",
+ "iopub.status.busy": "2026-07-13T16:14:00.326140Z",
+ "iopub.status.idle": "2026-07-13T16:14:00.327642Z",
+ "shell.execute_reply": "2026-07-13T16:14:00.327454Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "config = AnonymizerConfig(\n",
+ " rewrite=Rewrite(\n",
+ " privacy_goal=PrivacyGoal(\n",
+ " protect=\"All direct identifiers and quasi-identifier combinations (names, locations, employers, dates)\",\n",
+ " preserve=\"Career trajectory, educational background, and professional accomplishments\",\n",
+ " ),\n",
+ " risk_tolerance=\"low\",\n",
+ " max_repair_iterations=3,\n",
+ " ),\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "af2de051",
+ "metadata": {},
+ "source": [
+ "## 👁️ Preview\n",
+ "\n",
+ "- `preview()` runs on a small sample so you can iterate on privacy goals\n",
+ " and evaluation criteria before committing to a full run."
+ ]
+ },
{
- "data": {
- "text/html": [
- "\n",
- "
\n",
- "
\n",
- " Anonymizer Rewrite Preview (record 1)\n",
- "
\n",
- "
\n",
- "
\n",
- "
Original
\n",
- "
Jodi| first_name Allison| last_name, 36| age, lives at 204 Bluegrass| street_address in Clayton| city, North Carolina| state. A Caucasian| race_ethnicity editor| occupation with a lifelong love of words, she earned her BA| education_level in English| language from the University of North Carolina| state at Chapel Hill and cut her teeth on the newsroom of the Raleigh| city Times. After a stint as copy chief| occupation at Venture Media| company_name, Jodi| first_name moved to Southern Publishing| company_name, where she now leads the feature‑section team. She describes herself as a moderate Democrat| political_view and a Methodist| religious_belief who finds comfort in the rhythm of Sunday worship. \n",
- "\n",
- "Outside the office Jodi| first_name shares a busy home with her husband, Alex| first_name, a school counselor| occupation, and their two children, Ethan| first_name, 7| age, and Maya| first_name, 4| age. The family often spends weekends gardening in the yard behind their house or volunteering at the local library’s reading program, a tradition Jodi| first_name started as a teenager. Her friends say she balances deadlines with devotion to community, always keeping a notebook handy for the next story that matters.
\n",
- "
\n",
- "
\n",
- "
Rewritten
\n",
- "
Leah Bennett, in her mid‑30s, lives at an address in a small town. She is a media professional with a lifelong love of words. She earned a BA in English from a state university and began her career at a local newspaper. After serving as a senior copy manager at a media firm, she transitioned to a publishing organization where she now oversees a major department. She describes herself as a moderate Democrat and follows a faith tradition that includes weekly gatherings.\n",
- "\n",
- "Outside work, Leah shares a busy home with her spouse, who works in education, and their children. Weekends are often spent tending to a garden or volunteering at a community library program, a habit she started as a teenager. Friends say she balances professional deadlines with community involvement, always keeping a notebook handy for the next story that matters.
\n",
- "
\n",
- "
\n",
- "
Scores
\n",
- "
Utility: 0.84Leakage: 0.00Weighted Leakage Rate: 0.00Needs Review: NoJudge: privacy: 10/10, quality: 9/10, naturalness: 9/10
\n",
- "
\n",
- "
\n",
- "
Entity Disposition
\n",
- "
| Entity | Label | Sensitivity | Protection |
|---|
| 204 Bluegrass | street_address | high | replace |
| Jodi | first_name | high | replace |
| Allison | last_name | high | replace |
| 36 | age | high | generalize |
| 4 | age | high | remove |
| 7 | age | high | remove |
| Alex | first_name | high | replace |
| BA | education_level | low | leave_as_is |
| Caucasian | race_ethnicity | low | leave_as_is |
| Clayton | city | high | generalize |
| English | language | low | leave_as_is |
| Ethan | first_name | high | remove |
| Maya | first_name | high | remove |
| Methodist | religious_belief | low | leave_as_is |
| North Carolina | state | high | generalize |
| Raleigh | city | high | generalize |
| Southern Publishing | company_name | high | generalize |
| Venture Media | company_name | high | generalize |
| copy chief | occupation | high | generalize |
| editor | occupation | high | generalize |
| moderate Democrat | political_view | low | leave_as_is |
| school counselor | occupation | low | leave_as_is |
| married | marital_status | medium | leave_as_is |
| 2 | num_children | medium | leave_as_is |
| feature_section_lead | position | medium | leave_as_is |
| publishing | sector | medium | leave_as_is |
| 30s | age_bracket | medium | leave_as_is |
| protestant | religious_affiliation | medium | leave_as_is |
| democrat | political_orientation | medium | leave_as_is |
| suburban | home_neighborhood_type | medium | leave_as_is |
\n",
- "
\n",
- "
\n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "6c42a033",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:14:00.329072Z",
+ "iopub.status.busy": "2026-07-13T16:14:00.329012Z",
+ "iopub.status.idle": "2026-07-13T16:19:15.467654Z",
+ "shell.execute_reply": "2026-07-13T16:19:15.466851Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:14:00] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:14:00] [INFO] 🔍 Running entity detection on 3 records\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:14:00] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:15:03] [INFO] |-- 📋 Detection complete — 79 entities found across 3 records (0 failed) [62.6s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:15:03] [INFO] |-- labels: first_name=23, organization_name=8, age=5, occupation=5, city=4, state=4, degree=4, university=4, field_of_study=4, last_name=3, race_ethnicity=3, political_view=3, language=2, religious_belief=2, street_address=2, place_name=1, date_of_birth=1, employment_status=1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:15:03] [INFO] ✏️ Running rewrite pipeline\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:19:15] [INFO] Evaluate-repair loop: all rows pass at iteration 0\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:19:15] [INFO] |-- 📋 Rewrite complete (0 failed) [251.7s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:19:15] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Rewrite Preview (record 0)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| organization_name, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| organization_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria| first_name and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
\n",
+ "
Rewritten
\n",
+ "
Ethan Hawthorne, a veterinarian in his 40s of Mexican heritage living in a city in Colorado, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High, he earned his DVM at a Colorado university, where he also completed a research stint in wildlife health. Fluent in English, Ethan has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Ethan has worked at a regional veterinary hospital chain and later at a local veterinary clinic, where he now leads a busy mixed‑practice team. He identifies as a Christian Democrat and often volunteers at local shelters, a habit encouraged by his partner, Nina, and their two teenage children, Sofia and Jasper. Outside the clinic, Ethan enjoys hiking the Rockies with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
\n",
+ "
Scores
\n",
+ "
Utility: 1.00Leakage: 0.00Weighted Leakage Rate: 0.00Rewrite Needs Review: No
\n",
+ "
\n",
+ "
\n",
+ "
Entity Disposition
\n",
+ "
| Entity | Label | Sensitivity | Protection |
|---|
| Bobby | first_name | high | replace |
| Watford | last_name | high | replace |
| 40 | age | high | generalize |
| Mexican | race_ethnicity | medium | leave_as_is |
| veterinarian | occupation | low | leave_as_is |
| Denver | city | high | generalize |
| Colorado | state | low | leave_as_is |
| Jefferson High | organization_name | low | leave_as_is |
| DVM | degree | medium | leave_as_is |
| University of Colorado Boulder | university | high | generalize |
| wildlife health | field_of_study | low | leave_as_is |
| English | language | low | leave_as_is |
| Christian Democrat | political_view | low | leave_as_is |
| Rockies | place_name | low | leave_as_is |
| VCA Animal Hospital | organization_name | high | generalize |
| Colorado Veterinary Clinic | organization_name | high | generalize |
| Maya | first_name | high | replace |
| Aria | first_name | high | replace |
| Leo | first_name | high | replace |
| large veterinary hospital chain | employer | medium | leave_as_is |
| married | marital_status | medium | suppress_inference |
| doctorate degree | education_level | low | leave_as_is |
| male | gender | low | leave_as_is |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
],
- "text/plain": [
- ""
+ "source": [
+ "preview = anonymizer.preview(\n",
+ " config=config,\n",
+ " data=input_data,\n",
+ " num_records=3,\n",
+ ")\n",
+ "\n",
+ "preview.display_record(0)"
]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "preview.display_record(1)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "b54ec902",
- "metadata": {},
- "source": [
- "## 🚀 Full run\n",
- "\n",
- "- `result.dataframe` has user-facing columns: rewritten text, scores, and the review flag.\n",
- "- `result.trace_dataframe` has every intermediate column for debugging."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "id": "89ec3704",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T20:52:04.710490Z",
- "iopub.status.busy": "2026-04-03T20:52:04.710407Z",
- "iopub.status.idle": "2026-04-03T21:20:17.172230Z",
- "shell.execute_reply": "2026-04-03T21:20:17.171990Z"
- }
- },
- "outputs": [
+ },
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "[14:51:45] [INFO] 📂 Loaded 25 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n",
- "[14:51:45] [INFO] 🔍 Running entity detection on 25 records\n"
- ]
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "b4b8b747",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:19:15.472137Z",
+ "iopub.status.busy": "2026-07-13T16:19:15.471834Z",
+ "iopub.status.idle": "2026-07-13T16:19:15.477437Z",
+ "shell.execute_reply": "2026-07-13T16:19:15.476984Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Rewrite Preview (record 1)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
Idilio| first_name Bell| last_name is a 37| age‑year‑old astronomer| occupation living in Edison| city, New Jersey| state. Born on November 21, 1988| date_of_birth, he grew up in a bilingual Italian| race_ethnicity household and speaks English| language at home and work. He earned his bachelor’s degree| degree in physics| field_of_study from the University of New Jersey| university and later completed a PhD| degree in astrophysics| field_of_study at Princeton| university, where his dissertation focused on exoplanet atmospheres. After graduation he spent three years at NASA’s Goddard Space Flight Center| organization_name before joining SpaceX| organization_name’s research division, where he now leads a team analyzing data from the Starlink telescope array| organization_name. Idilio| first_name describes himself as secular| religious_belief and leans progressive| political_view on most political issues, often volunteering for science outreach programs in his community.\n",
+ "\n",
+ "Outside the lab, Idilio| first_name shares a modest house on West Roberts Drive| street_address with his wife, Maya| first_name, and their two young daughters, Lina| first_name and Zara| first_name. His mother, Elena| first_name, lives nearby and still cooks the family’s favorite pasta on Sundays, while his father, Marco| first_name, retired| employment_status from an engineering firm in New York| state. Family gatherings are a mix of lively conversation and stargazing sessions on the backyard deck, where Idilio| first_name points out constellations and tells stories of the cosmos that inspire his children’s curiosity.
\n",
+ "
\n",
+ "
\n",
+ "
Rewritten
\n",
+ "
Dario Kumar is an astronomer in his late 30s living in a city in New Jersey. He grew up in a bilingual Italian household and speaks English at home and work. He earned his bachelor's degree in physics from the University of New Jersey and later completed a PhD in astrophysics at Princeton, where his dissertation focused on exoplanet atmospheres. After graduation he spent three years at NASA’s Goddard Space Flight Center before joining SpaceX’s research division, where he now leads a team analyzing data from the Starlink telescope array. Dario describes himself as secular and leans progressive on most political issues, often volunteering for science outreach programs in his community. Outside the lab, Dario shares a modest house on Maple Hill Lane with his wife, Aisha, and their two young daughters, Nina and Mila. His mother, Sofia, lives nearby and still cooks the family’s favorite pasta on Sundays, while his father, Luis, retired from an engineering firm in New York. Family gatherings are a mix of lively conversation and stargazing sessions on the backyard deck, where Dario points out constellations and tells stories of the cosmos that inspire his children’s curiosity.
\n",
+ "
\n",
+ "
\n",
+ "
Scores
\n",
+ "
Utility: 0.96Leakage: 0.00Weighted Leakage Rate: 0.00Rewrite Needs Review: No
\n",
+ "
\n",
+ "
\n",
+ "
Entity Disposition
\n",
+ "
| Entity | Label | Sensitivity | Protection |
|---|
| Idilio | first_name | high | replace |
| Bell | last_name | high | replace |
| 37 | age | high | generalize |
| Edison | city | high | generalize |
| Elena | first_name | high | replace |
| English | language | low | leave_as_is |
| Italian | race_ethnicity | medium | leave_as_is |
| Lina | first_name | high | replace |
| Marco | first_name | high | replace |
| Maya | first_name | high | replace |
| NASA’s Goddard Space Flight Center | organization_name | high | leave_as_is |
| New Jersey | state | medium | leave_as_is |
| New York | state | medium | leave_as_is |
| November 21, 1988 | date_of_birth | high | replace |
| PhD | degree | medium | leave_as_is |
| Princeton | university | high | leave_as_is |
| SpaceX | organization_name | high | leave_as_is |
| Starlink telescope array | organization_name | high | leave_as_is |
| University of New Jersey | university | high | leave_as_is |
| West Roberts Drive | street_address | high | replace |
| Zara | first_name | high | replace |
| astronomer | occupation | medium | leave_as_is |
| bachelor’s degree | degree | medium | leave_as_is |
| in astrophysics | field_of_study | medium | leave_as_is |
| in physics | field_of_study | medium | leave_as_is |
| progressive | political_view | low | leave_as_is |
| retired | employment_status | low | leave_as_is |
| secular | religious_belief | low | leave_as_is |
| married | marital_status | medium | leave_as_is |
| 2 | number_of_children | medium | leave_as_is |
| male | gender | low | leave_as_is |
| aerospace | industry | high | leave_as_is |
| doctorate | highest_education | high | leave_as_is |
| research team lead | current_role | medium | leave_as_is |
| Italian-American | cultural_background | medium | leave_as_is |
| single-family home | housing_type | low | leave_as_is |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "preview.display_record(1)"
+ ]
},
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "[14:54:03] [INFO] |-- 📋 Detection complete — 645 entities found across 25 records (0 failed) [137.9s]\n",
- "[14:54:03] [INFO] |-- labels: first_name=152, occupation=47, city=44, company_name=43, organization_name=31, race_ethnicity=30, state=30, education_level=30, last_name=26, age=26, religious_belief=26, political_view=25, street_address=23, university=22, language=21, field_of_study=14, place_name=10, county=10, date_of_birth=9, employment_status=9, degree=7, date=5, project_name=1, full_name=1, country=1, gender=1, postcode=1\n",
- "[14:54:03] [INFO] ✏️ Running rewrite pipeline\n",
- "[15:12:06] [INFO] Evaluate-repair loop iteration 0: 7/25 rows need repair\n",
- "[15:12:53] [INFO] Evaluate-repair loop: all rows pass at iteration 1\n",
- "[15:13:39] [INFO] |-- 📋 Rewrite complete (0 failed) [1076.7s]\n",
- "[15:13:39] [INFO] 🎉 Pipeline complete — 25 records processed, 0 total failures\n"
- ]
+ "cell_type": "markdown",
+ "id": "f77edf8a",
+ "metadata": {},
+ "source": [
+ "> **How to interpret leakage:** Leakage is measured against the sensitivity\n",
+ "> disposition. Details marked `leave_as_is` may remain without increasing\n",
+ "> `leakage_mass`. If an output retains something you expected the privacy goal\n",
+ "> to protect, inspect the Entity Disposition table.\n",
+ "\n",
+ "## 🚀 Full run\n",
+ "\n",
+ "- `result.dataframe` has user-facing columns: rewritten text, scores, and the review flag.\n",
+ "- `result.trace_dataframe` has every intermediate column for debugging."
+ ]
},
{
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " biography | \n",
- " biography_rewritten | \n",
- " utility_score | \n",
- " leakage_mass | \n",
- " weighted_leakage_rate | \n",
- " any_high_leaked | \n",
- " needs_human_review | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " | 0 | \n",
- " Bobby Watford, a 40‑year‑old Mexican veterinar... | \n",
- " Ethan Hawkins, a 40‑year‑old Mexican veterinar... | \n",
- " 1.0 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 1 | \n",
- " Idilio Bell is a 37‑year‑old astronomer living... | \n",
- " Rafael Kline is a 37‑year‑old astronomer livin... | \n",
- " 0.808333 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 2 | \n",
- " Jodi Allison, 36, lives at 204 Bluegrass in Cl... | \n",
- " Tara Kendall, 36, lives at a street address in... | \n",
- " 0.877778 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 3 | \n",
- " James Mills is a 69‑year‑old paramedic who liv... | \n",
- " Victor Hawthorne is a 69‑year‑old paramedic wh... | \n",
- " 0.909091 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 4 | \n",
- " Nancy Burton is a 21‑year‑old cashier who live... | \n",
- " Maya Hawthorne is a 21‑year‑old cashier who li... | \n",
- " 0.957692 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 9,
+ "id": "93638827",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:19:15.479408Z",
+ "iopub.status.busy": "2026-07-13T16:19:15.479277Z",
+ "iopub.status.idle": "2026-07-13T16:34:45.970646Z",
+ "shell.execute_reply": "2026-07-13T16:34:45.970035Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:19:15] [INFO] 📂 Loaded 25 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/NVIDIA_synthetic_biographies.csv (column: 'biography')\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:19:15] [INFO] 🔍 Running entity detection on 25 records\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:19:15] [INFO] detection labels in scope: (default: 65 labels; see anonymizer.DEFAULT_ENTITY_LABELS for list)\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:22:42] [INFO] |-- 📋 Detection complete — 672 entities found across 25 records (0 failed) [207.0s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:22:42] [INFO] |-- labels: first_name=154, organization_name=63, occupation=47, city=41, field_of_study=38, university=36, race_ethnicity=30, last_name=27, age=27, degree=27, state=25, political_view=25, religious_belief=24, street_address=23, language=19, place_name=17, employment_status=11, county=10, date_of_birth=9, company_name=5, date=5, education_level=4, time=1, landmark=1, country=1, gender=1, postcode=1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:22:42] [INFO] ✏️ Running rewrite pipeline\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:34:02] [INFO] Evaluate-repair loop iteration 0: 4/25 rows need repair\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:34:44] [INFO] Evaluate-repair loop: all rows pass at iteration 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:34:44] [INFO] |-- 📋 Rewrite complete (0 failed) [721.6s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:34:44] [INFO] 🎉 Pipeline complete — 25 records processed, 0 total failures\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " biography | \n",
+ " biography_rewritten | \n",
+ " utility_score | \n",
+ " leakage_mass | \n",
+ " weighted_leakage_rate | \n",
+ " any_high_leaked | \n",
+ " needs_human_review | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " Bobby Watford, a 40‑year‑old Mexican veterinar... | \n",
+ " Ethan Kline, a 40‑year‑old Mexican veterinaria... | \n",
+ " 0.918182 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " Jodi Allison, 36, lives at 204 Bluegrass in Cl... | \n",
+ " Claire Harper, in her mid‑30s, lives at 317 Ma... | \n",
+ " 0.99375 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " James Mills is a 69‑year‑old paramedic who liv... | \n",
+ " Victor Harper is a man in his late 60s who wor... | \n",
+ " 0.966667 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " Nancy Burton is a 21‑year‑old cashier who live... | \n",
+ " Emily Hawkins is in her early twenties and wor... | \n",
+ " 0.98 | \n",
+ " 0.297 | \n",
+ " 0.026757 | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " Cheryl Gray is a 33‑year‑old historian living ... | \n",
+ " Denise Bennett is a historian in her late 30s,... | \n",
+ " 0.933333 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " biography ... needs_human_review\n",
+ "0 Bobby Watford, a 40‑year‑old Mexican veterinar... ... False\n",
+ "1 Jodi Allison, 36, lives at 204 Bluegrass in Cl... ... False\n",
+ "2 James Mills is a 69‑year‑old paramedic who liv... ... False\n",
+ "3 Nancy Burton is a 21‑year‑old cashier who live... ... False\n",
+ "4 Cheryl Gray is a 33‑year‑old historian living ... ... False\n",
+ "\n",
+ "[5 rows x 7 columns]"
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
],
- "text/plain": [
- " biography \\\n",
- "0 Bobby Watford, a 40‑year‑old Mexican veterinar... \n",
- "1 Idilio Bell is a 37‑year‑old astronomer living... \n",
- "2 Jodi Allison, 36, lives at 204 Bluegrass in Cl... \n",
- "3 James Mills is a 69‑year‑old paramedic who liv... \n",
- "4 Nancy Burton is a 21‑year‑old cashier who live... \n",
- "\n",
- " biography_rewritten utility_score \\\n",
- "0 Ethan Hawkins, a 40‑year‑old Mexican veterinar... 1.0 \n",
- "1 Rafael Kline is a 37‑year‑old astronomer livin... 0.808333 \n",
- "2 Tara Kendall, 36, lives at a street address in... 0.877778 \n",
- "3 Victor Hawthorne is a 69‑year‑old paramedic wh... 0.909091 \n",
- "4 Maya Hawthorne is a 21‑year‑old cashier who li... 0.957692 \n",
- "\n",
- " leakage_mass weighted_leakage_rate any_high_leaked needs_human_review \n",
- "0 0.0 0.0 False False \n",
- "1 0.0 0.0 False False \n",
- "2 0.0 0.0 False False \n",
- "3 0.0 0.0 False False \n",
- "4 0.0 0.0 False False "
+ "source": [
+ "result = anonymizer.run(config=config, data=input_data)\n",
+ "\n",
+ "result.dataframe.head()"
]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "result = anonymizer.run(config=config, data=input_data)\n",
- "\n",
- "result.dataframe.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "id": "810b4598",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:20:17.173631Z",
- "iopub.status.busy": "2026-04-03T21:20:17.173566Z",
- "iopub.status.idle": "2026-04-03T21:20:17.176525Z",
- "shell.execute_reply": "2026-04-03T21:20:17.176356Z"
- }
- },
- "outputs": [
+ },
{
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " biography_rewritten | \n",
- " utility_score | \n",
- " leakage_mass | \n",
- " needs_human_review | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " | 0 | \n",
- " Ethan Hawkins, a 40‑year‑old Mexican veterinar... | \n",
- " 1.0 | \n",
- " 0.0 | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 1 | \n",
- " Rafael Kline is a 37‑year‑old astronomer livin... | \n",
- " 0.808333 | \n",
- " 0.0 | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 2 | \n",
- " Tara Kendall, 36, lives at a street address in... | \n",
- " 0.877778 | \n",
- " 0.0 | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 3 | \n",
- " Victor Hawthorne is a 69‑year‑old paramedic wh... | \n",
- " 0.909091 | \n",
- " 0.0 | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 4 | \n",
- " Maya Hawthorne is a 21‑year‑old cashier who li... | \n",
- " 0.957692 | \n",
- " 0.0 | \n",
- " False | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "1de6991b",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:34:45.973670Z",
+ "iopub.status.busy": "2026-07-13T16:34:45.973482Z",
+ "iopub.status.idle": "2026-07-13T16:34:45.982323Z",
+ "shell.execute_reply": "2026-07-13T16:34:45.981932Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " biography_rewritten | \n",
+ " utility_score | \n",
+ " leakage_mass | \n",
+ " needs_human_review | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " Ethan Kline, a 40‑year‑old Mexican veterinaria... | \n",
+ " 0.918182 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " Claire Harper, in her mid‑30s, lives at 317 Ma... | \n",
+ " 0.99375 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " Victor Harper is a man in his late 60s who wor... | \n",
+ " 0.966667 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " Emily Hawkins is in her early twenties and wor... | \n",
+ " 0.98 | \n",
+ " 0.297 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " Denise Bennett is a historian in her late 30s,... | \n",
+ " 0.933333 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " biography_rewritten ... needs_human_review\n",
+ "0 Ethan Kline, a 40‑year‑old Mexican veterinaria... ... False\n",
+ "1 Claire Harper, in her mid‑30s, lives at 317 Ma... ... False\n",
+ "2 Victor Harper is a man in his late 60s who wor... ... False\n",
+ "3 Emily Hawkins is in her early twenties and wor... ... False\n",
+ "4 Denise Bennett is a historian in her late 30s,... ... False\n",
+ "\n",
+ "[5 rows x 4 columns]"
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
],
- "text/plain": [
- " biography_rewritten utility_score \\\n",
- "0 Ethan Hawkins, a 40‑year‑old Mexican veterinar... 1.0 \n",
- "1 Rafael Kline is a 37‑year‑old astronomer livin... 0.808333 \n",
- "2 Tara Kendall, 36, lives at a street address in... 0.877778 \n",
- "3 Victor Hawthorne is a 69‑year‑old paramedic wh... 0.909091 \n",
- "4 Maya Hawthorne is a 21‑year‑old cashier who li... 0.957692 \n",
- "\n",
- " leakage_mass needs_human_review \n",
- "0 0.0 False \n",
- "1 0.0 False \n",
- "2 0.0 False \n",
- "3 0.0 False \n",
- "4 0.0 False "
+ "source": [
+ "result.dataframe[[\"biography_rewritten\", \"utility_score\", \"leakage_mass\", \"needs_human_review\"]].head()"
]
- },
- "execution_count": 9,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "result.dataframe[[\"biography_rewritten\", \"utility_score\", \"leakage_mass\", \"needs_human_review\"]].head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "id": "6efb03d3",
- "metadata": {},
- "outputs": [
+ },
{
- "data": {
- "text/plain": [
- "['biography',\n",
- " '_anonymizer_record_id',\n",
- " '_raw_detected_entities',\n",
- " '_seed_entities',\n",
- " '_tag_notation',\n",
- " '_seed_validation_candidates',\n",
- " '_seed_tagged_text',\n",
- " '_validated_entities',\n",
- " '_seed_entities_json',\n",
- " '_initial_tagged_text',\n",
- " '_validated_seed_entities',\n",
- " '_augmented_entities',\n",
- " '_merged_entities',\n",
- " '_merged_tagged_text',\n",
- " '_validation_candidates',\n",
- " '_detected_entities',\n",
- " 'biography_with_spans',\n",
- " '_latent_entities',\n",
- " 'final_entities',\n",
- " '_entities_by_value',\n",
- " '_replacement_map',\n",
- " '_domain',\n",
- " '_domain_supplement',\n",
- " '_domain_supplement_privacy',\n",
- " '_sensitivity_disposition',\n",
- " '_privacy_qa',\n",
- " '_sensitivity_disposition_block',\n",
- " '_rewrite_disposition_block',\n",
- " '_replacement_map_for_prompt',\n",
- " '_full_rewrite',\n",
- " 'biography_rewritten',\n",
- " '_meaning_units',\n",
- " '_meaning_units_serialized',\n",
- " '_quality_qa',\n",
- " '_repair_iterations',\n",
- " '_quality_qa_reanswer',\n",
- " '_quality_qa_compare',\n",
- " '_privacy_qa_reanswer',\n",
- " 'utility_score',\n",
- " 'leakage_mass',\n",
- " 'weighted_leakage_rate',\n",
- " 'any_high_leaked',\n",
- " '_needs_repair',\n",
- " '_leaked_privacy_items',\n",
- " '_rewritten_text__next',\n",
- " 'needs_human_review',\n",
- " '_judge_evaluation']"
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "ca8fd9dd",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:34:45.983968Z",
+ "iopub.status.busy": "2026-07-13T16:34:45.983854Z",
+ "iopub.status.idle": "2026-07-13T16:34:45.986566Z",
+ "shell.execute_reply": "2026-07-13T16:34:45.986158Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "['biography',\n",
+ " '_anonymizer_record_id',\n",
+ " '_raw_detected_entities',\n",
+ " '_seed_entities',\n",
+ " '_tag_notation',\n",
+ " '_seed_validation_candidates',\n",
+ " '_seed_tagged_text',\n",
+ " '_validated_entities',\n",
+ " '_seed_entities_json',\n",
+ " '_initial_tagged_text',\n",
+ " '_validated_seed_entities',\n",
+ " '_augmented_entities',\n",
+ " '_merged_entities',\n",
+ " '_merged_tagged_text',\n",
+ " '_validation_candidates',\n",
+ " '_detected_entities',\n",
+ " 'biography_with_spans',\n",
+ " '_latent_entities',\n",
+ " 'final_entities',\n",
+ " '_entities_by_value',\n",
+ " '_replacement_map',\n",
+ " '_replacement_map_source',\n",
+ " '_domain',\n",
+ " '_domain_supplement',\n",
+ " '_domain_supplement_privacy',\n",
+ " '_sensitivity_disposition',\n",
+ " '_privacy_qa',\n",
+ " '_rewrite_disposition_block',\n",
+ " '_sensitivity_disposition_block',\n",
+ " '_replacement_map_for_prompt',\n",
+ " '_full_rewrite',\n",
+ " 'biography_rewritten',\n",
+ " '_meaning_units',\n",
+ " '_meaning_units_serialized',\n",
+ " '_quality_qa',\n",
+ " '_repair_iterations',\n",
+ " '_privacy_qa_reanswer',\n",
+ " '_quality_qa_reanswer',\n",
+ " '_quality_qa_compare',\n",
+ " 'utility_score',\n",
+ " 'leakage_mass',\n",
+ " 'weighted_leakage_rate',\n",
+ " 'any_high_leaked',\n",
+ " '_needs_repair',\n",
+ " '_leaked_privacy_items',\n",
+ " '_rewritten_text__next',\n",
+ " 'needs_human_review']"
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "result.trace_dataframe.columns.tolist()"
]
- },
- "execution_count": 10,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "result.trace_dataframe.columns.tolist()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "55798fd4",
- "metadata": {},
- "source": [
- "## 🚩 Filter by review flag\n",
- "\n",
- "- Records where automated metrics exceed thresholds are flagged for manual review.\n",
- "- Use this to prioritize human attention on the records that need it most.\n",
- "- See [Working with flagged records](../../concepts/rewrite/#working-with-flagged-records)\n",
- " for guidance on diagnosing and resolving flagged records."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "id": "f5b4c953",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:20:17.180368Z",
- "iopub.status.busy": "2026-04-03T21:20:17.180309Z",
- "iopub.status.idle": "2026-04-03T21:20:17.184301Z",
- "shell.execute_reply": "2026-04-03T21:20:17.184127Z"
- }
- },
- "outputs": [
+ },
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "0 of 25 records flagged for human review\n"
- ]
+ "cell_type": "markdown",
+ "id": "d14e3a16",
+ "metadata": {},
+ "source": [
+ "## 🚩 Filter by review flag\n",
+ "\n",
+ "- Records where automated metrics exceed thresholds are flagged for manual review.\n",
+ "- `needs_human_review` is threshold-based, so a record can have small nonzero\n",
+ " leakage without being flagged.\n",
+ "- Use this to prioritize human attention on the records that need it most.\n",
+ "- See [Working with flagged records](../../concepts/rewrite/#working-with-flagged-records)\n",
+ " for guidance on diagnosing and resolving flagged records."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "id": "b34e5296",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:34:45.987981Z",
+ "iopub.status.busy": "2026-07-13T16:34:45.987860Z",
+ "iopub.status.idle": "2026-07-13T16:34:45.992325Z",
+ "shell.execute_reply": "2026-07-13T16:34:45.992077Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0 of 25 records flagged for human review\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " biography | \n",
+ " biography_rewritten | \n",
+ " utility_score | \n",
+ " leakage_mass | \n",
+ " weighted_leakage_rate | \n",
+ " any_high_leaked | \n",
+ " needs_human_review | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ "Empty DataFrame\n",
+ "Columns: [biography, biography_rewritten, utility_score, leakage_mass, weighted_leakage_rate, any_high_leaked, needs_human_review]\n",
+ "Index: []"
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df = result.dataframe\n",
+ "flagged = df[df[\"needs_human_review\"] == True] # noqa: E712\n",
+ "print(f\"{len(flagged)} of {len(df)} records flagged for human review\")\n",
+ "flagged.head()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "372ed54c",
+ "metadata": {},
+ "source": [
+ "## 🔬 Evaluate (optional)\n",
+ "\n",
+ "Call `evaluate()` to run LLM-as-judge scoring on the rewrite result — detection validity and three quality rubrics (privacy, quality, style).\n",
+ "Evaluation makes additional LLM calls per record. For larger datasets, evaluate\n",
+ "a preview first; this tutorial evaluates all 25 rows to demonstrate the complete workflow.\n",
+ "This holistic judge is independent of pipeline leakage scoring, so their assessments may differ.\n",
+ "See [Evaluation](../../concepts/evaluation/#rewrite-evaluation) for details."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "f0db152f",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:34:45.993599Z",
+ "iopub.status.busy": "2026-07-13T16:34:45.993514Z",
+ "iopub.status.idle": "2026-07-13T16:36:02.065380Z",
+ "shell.execute_reply": "2026-07-13T16:36:02.065061Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "evaluated = anonymizer.evaluate(result)"
+ ]
},
{
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " biography | \n",
- " biography_rewritten | \n",
- " utility_score | \n",
- " leakage_mass | \n",
- " weighted_leakage_rate | \n",
- " any_high_leaked | \n",
- " needs_human_review | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 14,
+ "id": "0b4aa6c1",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:36:02.066788Z",
+ "iopub.status.busy": "2026-07-13T16:36:02.066712Z",
+ "iopub.status.idle": "2026-07-13T16:36:02.070354Z",
+ "shell.execute_reply": "2026-07-13T16:36:02.070150Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Rewrite Preview (record 0)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
Bobby| first_name Watford| last_name, a 40| age‑year‑old Mexican| race_ethnicity veterinarian| occupation living in Denver| city, Colorado| state, grew up on the outskirts of the city and developed a love for animals early on. After graduating from Jefferson High| university, he earned his DVM| degree at the University of Colorado Boulder| university, where he also completed a research stint in wildlife health| field_of_study. Fluent in English| language, Bobby| first_name has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Bobby| first_name has worked at VCA Animal Hospital| organization_name and later at the Colorado Veterinary Clinic| organization_name, where he now leads a busy mixed‑practice team. He identifies as a Christian Democrat| political_view and often volunteers at local shelters, a habit encouraged by his wife, Maya| first_name, and their two teenage children, Aria| first_name and Leo| first_name. Outside the clinic, Bobby| first_name enjoys hiking the Rockies| place_name with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
\n",
+ "
Rewritten
\n",
+ "
Ethan Kline, a 40‑year‑old Mexican veterinarian living in Colorado, grew up in a suburban area and developed a love for animals early on. After graduating from a local high school, he earned his DVM at a state university, where he also completed a research stint in wildlife health. Fluent in English, Ethan has always described his upbringing as a blend of small‑town curiosity and the vibrant culture of his community, values that continue to shape his compassionate approach to animal care.\n",
+ "\n",
+ "Since finishing his training, Ethan has worked at a local veterinary practice and later at a local veterinary practice, where he now leads a busy mixed‑practice team. He identifies as a Christian Democrat and often volunteers at local shelters, a habit encouraged by his wife, Sofia, and their two teenage children, Nina and Jasper. Outside the clinic, Ethan enjoys hiking the Rockies with his family and mentoring veterinary students from his alma mater.
\n",
+ "
\n",
+ "
\n",
+ "
Scores
\n",
+ "
Utility: 0.92Leakage: 0.00Weighted Leakage Rate: 0.00Rewrite Needs Review: No
Detection Validity: 0.95Show 1 flagged detection(s)
| Value | Label | Reason |
|---|
| Jefferson High | university | wrong_label: Jefferson High is a high school, not a university. |
Judge
privacy: mediumquality: highstyle: high
\n",
+ "
\n",
+ "
\n",
+ "
Entity Disposition
\n",
+ "
| Entity | Label | Sensitivity | Protection |
|---|
| Bobby | first_name | high | replace |
| Watford | last_name | high | replace |
| Maya | first_name | high | replace |
| Aria | first_name | high | replace |
| Leo | first_name | high | replace |
| 40 | age | low | leave_as_is |
| Mexican | race_ethnicity | low | leave_as_is |
| veterinarian | occupation | low | leave_as_is |
| Denver | city | high | remove |
| Colorado | state | low | leave_as_is |
| Jefferson High | university | high | generalize |
| University of Colorado Boulder | university | high | generalize |
| DVM | degree | low | leave_as_is |
| wildlife health | field_of_study | low | leave_as_is |
| English | language | low | leave_as_is |
| VCA Animal Hospital | organization_name | high | generalize |
| Colorado Veterinary Clinic | organization_name | high | generalize |
| Christian Democrat | political_view | low | leave_as_is |
| Rockies | place_name | low | leave_as_is |
| married | marital_status | low | leave_as_is |
| 2 | number_of_children | low | leave_as_is |
| male | gender | low | leave_as_is |
| outskirts of Denver | home_location | high | suppress_inference |
| mixed practice team lead | current_position | low | leave_as_is |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
],
- "text/plain": [
- "Empty DataFrame\n",
- "Columns: [biography, biography_rewritten, utility_score, leakage_mass, weighted_leakage_rate, any_high_leaked, needs_human_review]\n",
- "Index: []"
+ "source": [
+ "evaluated.display_record(0)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "b8e5cd5f",
+ "metadata": {},
+ "source": [
+ "## ⏭️ Next steps\n",
+ "\n",
+ "- **[⚖️ Rewriting Legal Documents](../05_rewriting_legal_documents/)** --\n",
+ " rewrite legal text with custom entity labels and domain-specific privacy goals.\n",
+ "- **[📊 Evaluation](../../concepts/evaluation/#rewrite-evaluation)** --\n",
+ " learn about the detection validity and rewrite quality judges in detail.\n",
+ "- **[🎯 Choosing a Replacement Strategy](../03_choosing_a_replacement_strategy/)** --\n",
+ " compare Redact, Annotate, Hash, and Substitute if you prefer token-level replacement.\n",
+ "- **[🔍 Inspecting Detected Entities](../02_inspecting_detected_entities/)** --\n",
+ " debug what the detection pipeline found before rewriting."
]
- },
- "execution_count": 11,
- "metadata": {},
- "output_type": "execute_result"
}
- ],
- "source": [
- "df = result.dataframe\n",
- "flagged = df[df[\"needs_human_review\"] == True] # noqa: E712\n",
- "print(f\"{len(flagged)} of {len(df)} records flagged for human review\")\n",
- "flagged.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "e1ad0026",
- "metadata": {},
- "source": [
- "## 🔬 Evaluate (optional)\n",
- "\n",
- "Call `evaluate()` to run LLM-as-judge scoring on the rewrite result — detection validity and three quality rubrics (privacy, quality, style).\n",
- "See [Evaluation](../../concepts/evaluation/#rewrite-evaluation) for details."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "a36d3c26",
- "metadata": {},
- "outputs": [],
- "source": [
- "evaluated = anonymizer.evaluate(result)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13126cd1",
- "metadata": {},
- "outputs": [],
- "source": [
- "evaluated.display_record(0)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "e601cc9d",
- "metadata": {},
- "source": [
- "## ⏭️ Next steps\n",
- "\n",
- "- **[⚖️ Rewriting Legal Documents](../05_rewriting_legal_documents/)** --\n",
- " rewrite legal text with custom entity labels and domain-specific privacy goals.\n",
- "- **[📊 Evaluation](../../concepts/evaluation/#rewrite-evaluation)** --\n",
- " learn about the detection validity and rewrite quality judges in detail.\n",
- "- **[🎯 Choosing a Replacement Strategy](../03_choosing_a_replacement_strategy/)** --\n",
- " compare Redact, Annotate, Hash, and Substitute if you prefer token-level replacement.\n",
- "- **[🔍 Inspecting Detected Entities](../02_inspecting_detected_entities/)** --\n",
- " debug what the detection pipeline found before rewriting."
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": ".venv (3.11.13)",
- "language": "python",
- "name": "python3"
+ ],
+ "metadata": {
+ "jupytext": {
+ "cell_metadata_filter": "-all"
+ },
+ "kernelspec": {
+ "display_name": ".venv",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.9"
+ }
},
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.13"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
+ "nbformat": 4,
+ "nbformat_minor": 5
}
diff --git a/docs/notebooks/05_rewriting_legal_documents.ipynb b/docs/notebooks/05_rewriting_legal_documents.ipynb
index aa249767..ad423f63 100644
--- a/docs/notebooks/05_rewriting_legal_documents.ipynb
+++ b/docs/notebooks/05_rewriting_legal_documents.ipynb
@@ -1,1080 +1,1310 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "1f41c65c",
- "metadata": {},
- "source": [
- "# 🕵️ Rewriting Legal Documents\n",
- "\n",
- "Rewriting legal text (TAB dataset) with a domain-specific privacy goal\n",
- "and custom entity labels tailored for legal proceedings.\n",
- "\n",
- "#### 📚 What you'll learn\n",
- "\n",
- "- Define domain-specific entity labels for legal text (case numbers, court names, etc.)\n",
- "- Configure rewrite mode with legal-specific privacy goals\n",
- "- Preview and run on court decision documents\n",
- "- Triage flagged records with `needs_human_review`\n",
- "\n",
- "> **Tip:** First time running notebooks? Start with\n",
- "> [setup instructions](https://nvidia-nemo.github.io/Anonymizer/latest/tutorials/)."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "817a7a24",
- "metadata": {},
- "source": [
- "## ⚙️ Setup\n",
- "\n",
- "- Check if your `NVIDIA_API_KEY` from [build.nvidia.com](https://build.nvidia.com) is registered for model access.\n",
- " - The default `build.nvidia.com` (NVIDIA Build) setup is a convenient way to try Anonymizer and iterate on previews. Use of NVIDIA Build is subject to NVIDIA Build's own terms of service and privacy practices, which are separate from and independent of the NeMo Framework library. NVIDIA Build is intended for evaluation and testing purposes only and may not be used in production environments. Do not upload any confidential information or personal data when using NVIDIA Build. Your use of NVIDIA Build is logged for security purposes and to improve NVIDIA products and services.\n",
- " - Request and token rate limits on `build.nvidia.com` vary by account and model access, and lower-volume development access can be slow for full-dataset runs. Start with `preview()` on a small sample, then move to your own endpoint for production data and usage.\n",
- "- Import `Detect` (for custom entity labels), `Rewrite`, and its config classes.\n",
- "- `Anonymizer()` initializes with the default model provider -- no extra config needed.\n",
- "- `configure_logging(LoggingConfig.default())` keeps logs at INFO. Switch to `LoggingConfig.debug()` when troubleshooting."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "id": "793e653d",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:20:21.055638Z",
- "iopub.status.busy": "2026-04-03T21:20:21.055501Z",
- "iopub.status.idle": "2026-04-03T21:20:21.059549Z",
- "shell.execute_reply": "2026-04-03T21:20:21.059020Z"
- }
- },
- "outputs": [],
- "source": [
- "import getpass\n",
- "import os\n",
- "\n",
- "if not os.getenv(\"NVIDIA_API_KEY\"):\n",
- " key = getpass.getpass(\"Enter NVIDIA_API_KEY from build.nvidia.com: \").strip()\n",
- " if not key:\n",
- " raise RuntimeError(\"NVIDIA_API_KEY is required to run these notebooks.\")\n",
- " os.environ[\"NVIDIA_API_KEY\"] = key"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14b32183",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:20:21.062154Z",
- "iopub.status.busy": "2026-04-03T21:20:21.061853Z",
- "iopub.status.idle": "2026-04-03T21:20:38.272324Z",
- "shell.execute_reply": "2026-04-03T21:20:38.271979Z"
- }
- },
- "outputs": [],
- "source": [
- "from anonymizer import (\n",
- " Anonymizer,\n",
- " AnonymizerConfig,\n",
- " AnonymizerInput,\n",
- " Detect,\n",
- " LoggingConfig,\n",
- " PrivacyGoal,\n",
- " Rewrite,\n",
- " configure_logging,\n",
- ")\n",
- "\n",
- "configure_logging(LoggingConfig.default())"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "id": "b98cf6d9",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:20:38.274388Z",
- "iopub.status.busy": "2026-04-03T21:20:38.274183Z",
- "iopub.status.idle": "2026-04-03T21:20:38.306987Z",
- "shell.execute_reply": "2026-04-03T21:20:38.306750Z"
- }
- },
- "outputs": [
+ "cells": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[16:41:39] [INFO] 🔧 Anonymizer initialized with 3 model configs\n",
- "[16:41:39] [INFO] |-- 🔎 detector: gliner-pii-detector\n",
- "[16:41:39] [INFO] |-- ✅ validator: gpt-oss-120b\n",
- "[16:41:39] [INFO] |-- 🧩 augmenter: gpt-oss-120b\n"
- ]
- }
- ],
- "source": [
- "anonymizer = Anonymizer()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "0b18d6f8",
- "metadata": {},
- "source": [
- "## 📦 Input data\n",
- "\n",
- "- [TAB (Text Anonymization Benchmark)](https://github.com/NorskRegnesentral/text-anonymization-benchmark)\n",
- " legal documents -- court decisions containing names, dates, case numbers, and other legal identifiers.\n",
- "- `LEGAL_ENTITY_LABELS` defines the domain-specific entity types to detect.\n",
- " This replaces the default label set with one tailored to legal text."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "id": "315bca05",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:20:38.308283Z",
- "iopub.status.busy": "2026-04-03T21:20:38.308207Z",
- "iopub.status.idle": "2026-04-03T21:20:38.310648Z",
- "shell.execute_reply": "2026-04-03T21:20:38.310357Z"
- }
- },
- "outputs": [],
- "source": [
- "LEGAL_ENTITY_LABELS = [\n",
- " \"first_name\",\n",
- " \"last_name\",\n",
- " \"court_name\",\n",
- " \"organization_name\",\n",
- " \"company_name\",\n",
- " \"prison_detention_facility\",\n",
- " \"street_address\",\n",
- " \"city\",\n",
- " \"state\",\n",
- " \"country\",\n",
- " \"date\",\n",
- " \"date_time\",\n",
- " \"time\",\n",
- " \"date_of_birth\",\n",
- " \"age\",\n",
- " \"email\",\n",
- " \"phone_number\",\n",
- " \"ssn\",\n",
- " \"unique_id\",\n",
- " \"legal_role\",\n",
- " \"case_number\",\n",
- " \"application_number\",\n",
- " \"monetary_amount\",\n",
- " \"sentence_duration\",\n",
- " \"nationality\",\n",
- "]\n",
- "\n",
- "input_data = AnonymizerInput(\n",
- " source=\"https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/TAB_legal_sample25.csv\",\n",
- " text_column=\"text\",\n",
- " data_summary=\"Legal court decisions containing personal identifiers, case numbers, and institutional references\",\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "08cfa358",
- "metadata": {},
- "source": [
- "## 🎛️ Configure\n",
- "\n",
- "- `Detect(entity_labels=...)` overrides the default entity set with legal-specific labels.\n",
- "- `PrivacyGoal` tells the rewriter what to **protect** (identifiers, case numbers,\n",
- " institutional references) and what to **preserve** (legal reasoning, statutory references,\n",
- " ruling structure)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "id": "9a38c30b",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:20:38.311740Z",
- "iopub.status.busy": "2026-04-03T21:20:38.311679Z",
- "iopub.status.idle": "2026-04-03T21:20:38.313508Z",
- "shell.execute_reply": "2026-04-03T21:20:38.313292Z"
- }
- },
- "outputs": [],
- "source": [
- "config = AnonymizerConfig(\n",
- " detect=Detect(\n",
- " entity_labels=LEGAL_ENTITY_LABELS,\n",
- " ),\n",
- " rewrite=Rewrite(\n",
- " privacy_goal=PrivacyGoal(\n",
- " protect=\"All personal identifiers, case numbers, court names, and institutional references that could identify parties\",\n",
- " preserve=\"Legal reasoning, procedural facts, statutory references, and the structure of the ruling\",\n",
- " ),\n",
- " risk_tolerance=\"minimal\",\n",
- " max_repair_iterations=3,\n",
- " ),\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "767d9254",
- "metadata": {},
- "source": [
- "## 👁️ Preview\n",
- "\n",
- "- Preview on a few records to check that legal entities are detected\n",
- " and the rewrite preserves the ruling's structure."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "id": "55e1c86a",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:20:38.314571Z",
- "iopub.status.busy": "2026-04-03T21:20:38.314498Z",
- "iopub.status.idle": "2026-04-03T21:33:42.622618Z",
- "shell.execute_reply": "2026-04-03T21:33:42.622355Z"
- }
- },
- "outputs": [
+ "cell_type": "markdown",
+ "id": "3adcecbe",
+ "metadata": {},
+ "source": [
+ "\n",
+ "# 🕵️ Rewriting Legal Documents\n",
+ "\n",
+ "Rewriting legal text (TAB dataset) with a domain-specific privacy goal\n",
+ "and custom entity labels tailored for legal proceedings.\n",
+ "\n",
+ "#### 📚 What you'll learn\n",
+ "\n",
+ "- Define domain-specific entity labels for legal text (case numbers, court names, etc.)\n",
+ "- Configure rewrite mode with legal-specific privacy goals\n",
+ "- Preview and run on court decision documents\n",
+ "- Triage flagged records with `needs_human_review`\n",
+ "\n",
+ "> **Tip:** First time running notebooks? Start with\n",
+ "> [setup instructions](https://nvidia-nemo.github.io/Anonymizer/latest/tutorials/)."
+ ]
+ },
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[16:41:39] [INFO] 📂 Loaded 25 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/TAB_legal_sample25.csv (column: 'text')\n",
- "[16:41:39] [INFO] detection labels in scope: ['age', 'application_number', 'case_number', 'city', 'company_name', 'country', 'court_name', 'date', 'date_of_birth', 'date_time', 'email', 'first_name', 'last_name', 'legal_role', 'monetary_amount', 'nationality', 'organization_name', 'phone_number', 'prison_detention_facility', 'sentence_duration', 'ssn', 'state', 'street_address', 'time', 'unique_id']\n",
- "[16:41:39] [INFO] 🔍 Running entity detection on 3 records\n",
- "[16:42:17] [INFO] |-- 📋 Detection complete — 141 entities found across 3 records (0 failed) [37.8s]\n",
- "[16:42:17] [INFO] |-- labels: date=51, court_name=35, legal_role=10, nationality=7, last_name=7, organization_name=6, country=5, first_name=5, city=5, application_number=3, date_of_birth=3, monetary_amount=2, case_number=1, sentence_duration=1\n",
- "[16:42:17] [INFO] ✏️ Running rewrite pipeline\n",
- "[16:45:15] [INFO] Evaluate-repair loop iteration 0: 2/3 rows need repair\n",
- "[16:46:10] [INFO] Evaluate-repair loop iteration 1: 1/3 rows need repair\n",
- "[16:46:56] [INFO] Evaluate-repair loop: all rows pass at iteration 2\n",
- "[16:47:13] [INFO] |-- 📋 Rewrite complete (0 failed) [296.2s]\n",
- "[16:47:13] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
- ]
+ "cell_type": "markdown",
+ "id": "6a99ae94",
+ "metadata": {
+ "lines_to_next_cell": 2
+ },
+ "source": [
+ "## ⚙️ Setup\n",
+ "\n",
+ "- Check if your `NVIDIA_API_KEY` from [build.nvidia.com](https://build.nvidia.com) is registered for model access.\n",
+ " - The default `build.nvidia.com` (NVIDIA Build) setup is a convenient way to try Anonymizer and iterate on previews. Use of NVIDIA Build is subject to NVIDIA Build's own terms of service and privacy practices, which are separate from and independent of the NeMo Framework library. NVIDIA Build is intended for evaluation and testing purposes only and may not be used in production environments. Do not upload any confidential information or personal data when using NVIDIA Build. Your use of NVIDIA Build is logged for security purposes and to improve NVIDIA products and services.\n",
+ " - Request and token rate limits on `build.nvidia.com` vary by account and model access, and lower-volume development access can be slow for full-dataset runs. Start with `preview()` on a small sample, then move to your own endpoint for production data and usage.\n",
+ "- Import `Detect` (for custom entity labels), `Rewrite`, and its config classes.\n",
+ "- `Anonymizer()` initializes with the default model provider -- no extra config needed.\n",
+ "- `configure_logging(LoggingConfig.default())` keeps logs at INFO. Switch to `LoggingConfig.debug()` when troubleshooting."
+ ]
},
{
- "data": {
- "text/html": [
- "\n",
- "
\n",
- "
\n",
- " Anonymizer Rewrite Preview (record 0)\n",
- "
\n",
- "
\n",
- "
\n",
- "
Original
\n",
- "
PROCEDURE\n",
- "\n",
- "The case originated in an application (no. 74463/01| application_number) against the Republic of Turkey| country lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Turkish| nationality national, Ms Feriştah| first_name Bahçeyaka| last_name, on 8 June 2001| date.\n",
- "\n",
- "The applicant was represented by Mr E. Kuloğlu| last_name, a lawyer| legal_role practising in Aydın| city. The Turkish Government| organization_name (“the Government”) did not designate an Agent for the purposes of the proceedings before the Court.\n",
- "\n",
- "On 14 June 2005| date the Court decided to communicate the application. Applying Article 29 § 3 of the Convention, it decided to rule on the admissibility and merits of the applications at the same time.\n",
- "\n",
- "The applicant and the Government each filed observations on the admissibility and the merits.\n",
- "\n",
- "THE FACTS\n",
- "\n",
- "The applicant was born in 1958| date and lives in Wesel| city, Germany| country.\n",
- "\n",
- "On 12 February 1980| date the applicant and her husband established a joint bank account with a German| nationality bank.\n",
- "\n",
- "On an unspecified date, the applicant’s husband withdrew all of the money from their joint account without the applicant’s consent and placed it into another account in a Turkish| nationality bank.\n",
- "\n",
- "On 23 October 1992| date_of_birth the applicant filed an action with the Aydın Civil Court of first-instance| court_name to recover half the money that her husband had withdrawn from their joint bank account.\n",
- "\n",
- "On 14 September 1999| date the Aydın Civil Court of first-instance| court_name dismissed the applicant’s case on the ground that she had failed to substantiate her claims. The court reasoned that the applicant had not furnished any bank document, such as receipts indicating withdrawal of money, capable of supporting her allegations. It also noted that the documents kept by the bank had been destroyed at the end of six years’ retention period and that therefore there was no document available on which to conclude that the applicant was right in her assertions.\n",
- "\n",
- "On 27 December 1999| date the applicant appealed.\n",
- "\n",
- "On 5 April 2000| date the Court of Cassation| court_name dismissed the applicant’s request for appeal. It opined that the applicant had failed to prove that her husband had withdrawn all the money from their joint bank account and placed it into another bank account.\n",
- "\n",
- "On 16 November 2000| date the Court of Cassation| court_name dismissed the applicant’s request for rectification.\n",
- "\n",
- "On 15 December 2000| date the Court of Cassation| court_name’s decision was served on the applicant.
\n",
- "
\n",
- "
\n",
- "
Rewritten
\n",
- "
PROCEDURE\n",
- "\n",
- "The case originated in an application (no. 86214/02) against the Republic of Turkey lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Turkish national, Ms Isabel García, in June 2001.\n",
- "\n",
- "The applicant was represented by Mr E. Martínez, a lawyer practising in a Turkish city. The national government (“the Government”) did not designate an Agent for the purposes of the proceedings before the Court.\n",
- "\n",
- "In June 2005 the Court decided to communicate the application. Applying Article 29 § 3 of the Convention, it decided to rule on the admissibility and merits of the applications at the same time.\n",
- "\n",
- "The applicant and the Government each filed observations on the admissibility and the merits.\n",
- "\n",
- "THE FACTS\n",
- "\n",
- "The applicant was born in the 1950s and lives in a city in Germany.\n",
- "\n",
- "In February 1980 the applicant and the other account holder established a joint bank account with a German bank.\n",
- "\n",
- "On an unspecified date, the other account holder withdrew all of the money from their joint account without the applicant’s consent and placed it into another account in a Turkish bank.\n",
- "\n",
- "In 1992 the applicant filed an action with a civil court of first instance in Turkey to recover half the money that the other account holder had withdrawn from their joint bank account.\n",
- "\n",
- "In September 1999 the civil court of first instance in Turkey dismissed the applicant’s case on the ground that she had failed to substantiate her claims. The court reasoned that the applicant had not furnished any bank document, such as receipts indicating withdrawal of money, capable of supporting her allegations. It also noted that the documents kept by the bank had been destroyed after the retention period and that therefore there was no document available on which to conclude that the applicant was right in her assertions.\n",
- "\n",
- "In December 1999 the applicant appealed.\n",
- "\n",
- "In April 2000 the highest appellate court dismissed the applicant’s request for appeal. It opined that the applicant had failed to prove that the other account holder had withdrawn all the money from their joint bank account and placed it into another bank account.\n",
- "\n",
- "In November 2000 the highest appellate court dismissed the applicant’s request for rectification.\n",
- "\n",
- "In December 2000 the highest appellate court’s decision was served on the applicant.
\n",
- "
\n",
- "
\n",
- "
Scores
\n",
- "
Utility: 0.86Leakage: 0.54Weighted Leakage Rate: 0.04Needs Review: NoJudge: privacy: 9/10, quality: 9/10, naturalness: 9/10
\n",
- "
\n",
- "
\n",
- "
Entity Disposition
\n",
- "
| Entity | Label | Sensitivity | Protection |
|---|
| 12 February 1980 | date | medium | generalize |
| 14 June 2005 | date | medium | generalize |
| 14 September 1999 | date | medium | generalize |
| 15 December 2000 | date | medium | generalize |
| 16 November 2000 | date | medium | generalize |
| 1958 | date | medium | generalize |
| 23 October 1992 | date_of_birth | medium | generalize |
| 27 December 1999 | date | medium | generalize |
| 5 April 2000 | date | medium | generalize |
| 74463/01 | application_number | high | replace |
| 8 June 2001 | date | medium | generalize |
| Aydın | city | low | generalize |
| Aydın Civil Court of first-instance | court_name | medium | generalize |
| Bahçeyaka | last_name | high | replace |
| Court of Cassation | court_name | medium | generalize |
| Feriştah | first_name | high | replace |
| German | nationality | low | leave_as_is |
| Germany | country | low | leave_as_is |
| Kuloğlu | last_name | high | replace |
| Republic of Turkey | country | low | leave_as_is |
| Turkish | nationality | low | leave_as_is |
| Turkish Government | organization_name | medium | generalize |
| Wesel | city | low | generalize |
| lawyer | legal_role | low | leave_as_is |
| married | marital_status | medium | suppress_inference |
| victim | financial_abuse_victim | high | suppress_inference |
\n",
- "
\n",
- "
\n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "5c18461e",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:36:11.820541Z",
+ "iopub.status.busy": "2026-07-13T16:36:11.820477Z",
+ "iopub.status.idle": "2026-07-13T16:36:11.822137Z",
+ "shell.execute_reply": "2026-07-13T16:36:11.821918Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "import getpass\n",
+ "import os\n",
+ "\n",
+ "if not os.getenv(\"NVIDIA_API_KEY\"):\n",
+ " key = getpass.getpass(\"Enter NVIDIA_API_KEY from build.nvidia.com: \").strip()\n",
+ " if not key:\n",
+ " raise RuntimeError(\"NVIDIA_API_KEY is required to run these notebooks.\")\n",
+ " os.environ[\"NVIDIA_API_KEY\"] = key"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "b7b49bec",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:36:11.823059Z",
+ "iopub.status.busy": "2026-07-13T16:36:11.823003Z",
+ "iopub.status.idle": "2026-07-13T16:36:11.825125Z",
+ "shell.execute_reply": "2026-07-13T16:36:11.824830Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "from anonymizer import (\n",
+ " Anonymizer,\n",
+ " AnonymizerConfig,\n",
+ " AnonymizerInput,\n",
+ " Detect,\n",
+ " LoggingConfig,\n",
+ " PrivacyGoal,\n",
+ " Rewrite,\n",
+ " configure_logging,\n",
+ ")\n",
+ "\n",
+ "configure_logging(LoggingConfig.default())"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "81db0800",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:36:11.826001Z",
+ "iopub.status.busy": "2026-07-13T16:36:11.825949Z",
+ "iopub.status.idle": "2026-07-13T16:36:11.843262Z",
+ "shell.execute_reply": "2026-07-13T16:36:11.843058Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:36:11] [INFO] 🔧 Anonymizer initialized with 3 model configs\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:36:11] [INFO] |-- 🔎 detector: gliner-pii-detector\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:36:11] [INFO] |-- ✅ validator: gpt-oss-120b\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:36:11] [INFO] |-- 🧩 augmenter: gpt-oss-120b\n"
+ ]
+ }
],
- "text/plain": [
- ""
+ "source": [
+ "anonymizer = Anonymizer()"
]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "preview = anonymizer.preview(\n",
- " config=config,\n",
- " data=input_data,\n",
- " num_records=3,\n",
- ")\n",
- "\n",
- "preview.display_record(0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "id": "ce1514da",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:33:42.624465Z",
- "iopub.status.busy": "2026-04-03T21:33:42.624377Z",
- "iopub.status.idle": "2026-04-03T21:33:42.627117Z",
- "shell.execute_reply": "2026-04-03T21:33:42.626916Z"
- }
- },
- "outputs": [
+ },
+ {
+ "cell_type": "markdown",
+ "id": "22de3c94",
+ "metadata": {},
+ "source": [
+ "## 📦 Input data\n",
+ "\n",
+ "- [TAB (Text Anonymization Benchmark)](https://github.com/NorskRegnesentral/text-anonymization-benchmark)\n",
+ " legal documents -- court decisions containing names, dates, case numbers, and other legal identifiers.\n",
+ "- `LEGAL_ENTITY_LABELS` defines the domain-specific entity types to detect.\n",
+ " This replaces the default label set with one tailored to legal text."
+ ]
+ },
{
- "data": {
- "text/html": [
- "\n",
- "
\n",
- "
\n",
- " Anonymizer Rewrite Preview (record 1)\n",
- "
\n",
- "
\n",
- "
\n",
- "
Original
\n",
- "
PROCEDURE\n",
- "\n",
- "The case originated in an application (no. 29360/06| application_number) against the Republic of Poland| country lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Polish| nationality national, Ms Teresa| first_name Jerzak| last_name (“the applicant”), on 3 July 2006| date.\n",
- "\n",
- "The Polish| nationality Government (“the Government”) were represented by their Agent| legal_role, Mr J. Wołąsiewicz| last_name of the Ministry of Foreign Affairs| organization_name.\n",
- "\n",
- "On 25 September 2007| date the President of the Fourth Section| legal_role decided to give notice of the application to the Government. Applying Article 29 § 3 of the Convention, it was decided to rule on the admissibility and merits of the application at the same time.\n",
- "\n",
- "THE FACTS\n",
- "\n",
- "I. THE CIRCUMSTANCES OF THE CASE\n",
- "\n",
- "The applicant was born in 1940| date_of_birth and lives in Sulejówek| city.\n",
- "\n",
- "A. Civil proceedings for division of inheritance\n",
- "\n",
- "On 8 March 1994| date the applicant lodged an application for division of an inheritance with the Warsaw District Court (Sąd Rejonowy)| court_name.\n",
- "\n",
- "On 7 November 1997| date the Warsaw District Court| court_name stayed the proceedings. It referred to the fact that related criminal proceedings concerning fraudulent acquisition of land, which could affect the outcome of the case, had first to be terminated.\n",
- "\n",
- "On 9 February 1998| date the applicant asked for the proceedings to be resumed.\n",
- "\n",
- "On 3 July 1998| date the court refused that request.\n",
- "\n",
- "On 3 July 1998| date the applicant complained to the Warsaw District Court| court_name about the delays in the proceedings. On 14 July 1998| date the court informed her that the proceedings would be resumed after the criminal proceedings had been terminated.\n",
- "\n",
- "On 3 August 2000| date the court refused to resume the proceedings. The applicant lodged an interlocutory appeal against that decision. The applicant referred to the fact that the prosecution had discontinued the investigation.\n",
- "\n",
- "On 15 January 2001| date the applicant asked once more for the proceedings to be resumed, to no avail.\n",
- "\n",
- "The proceedings were resumed on 14 February 2002| date.\n",
- "\n",
- "On 30 June 2004| date the Warsaw District Court| court_name ruled that some of the issues raised in the application, concerning the acquisition of property, should be examined in separate proceedings. Consequently, part of the claim, concerning the expropriation of property, was referred to the Warsaw District Court| court_name as a separate case. The applicant appealed. On 26 July 2004| date the Warsaw Regional Court (Sąd Okręgowy)| court_name dismissed the appeal.\n",
- "\n",
- "On 25 October 2004| date the court stayed the proceedings pending the outcome of the parallel proceedings for the expropriation of property. The applicant appealed.\n",
- "\n",
- "On 24 October 2006| date the Regional Court| court_name quashed that decision and resumed the examination of the case. It referred to the fact that the District Court| court_name had erroneously referred part of the claim to other proceedings. It relied on the need to examine both cases simultaneously within the scope of the same proceedings.\n",
- "\n",
- "On 9 May 2007| date the court stayed the proceedings because the parallel proceedings for the expropriation of property were pending before the appellate court.\n",
- "\n",
- "The case is still pending before the District Court| court_name.\n",
- "\n",
- "B. Proceedings under the 2004| date Act\n",
- "\n",
- "On 2 January 2006| date the applicant lodged a complaint with the Warsaw Regional Court| court_name, alleging a breach of her right to a hearing within a reasonable time. She relied on section 2 of the Act of 17 June 2004| date on complaints about a breach of the right to a trial within a reasonable time (Ustawa o skardze na naruszenie prawa strony do rozpoznania sprawy w postępowaniu sądowym bez nieuzasadnionej zwłoki) (“the 2004| date Act”), which entered into force on 17 September 2004| date.\n",
- "\n",
- "On 9 May 2006| date the Warsaw Regional Court| court_name acknowledged the excessive length of the proceedings before the Warsaw District Court| court_name. It awarded the applicant 200 Polish zlotys| monetary_amount (PLN – approximately 50 euros| monetary_amount (EUR)) by way of just satisfaction. The court referred to the resolution of the Supreme Court| organization_name (Sąd Najwyższy| court_name) of 18 January 2005| date (no. III SPP 113/04| case_number) in which it ruled that while the 2004| date Act produced legal effects as from the date of its date of entry into force, its provisions applied retroactively to all proceedings in which delays had occurred before that date and had not yet been remedied. The Regional Court| court_name held that the overall length of the proceedings before the District Court| court_name had been excessive, there had been long periods of inactivity and the hearings had not been held on a regular basis. These delays had taken place before the date of entry into force the 2004| date Act and had not been remedied afterwards. Referring to the amount of just satisfaction, the court held that having analysed all the circumstances of the case it found this amount to be sufficient for the applicant.
\n",
- "
\n",
- "
\n",
- "
Rewritten
\n",
- "
PROCEDURE\n",
- "\n",
- "The case originated in an application (no. 48712/09) against the Republic of Poland lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Polish national, the applicant, in mid‑2006.\n",
- "\n",
- "The Polish Government (“the Government”) was represented by its Agent, Mr J. Kovács of the Department of International Relations.\n",
- "\n",
- "In late 2007 the President of the Fourth Section decided to give notice of the application to the Government. Applying Article 29 § 3 of the Convention, it was decided to rule on the admissibility and merits of the application at the same time.\n",
- "\n",
- "THE FACTS\n",
- "\n",
- "I. THE CIRCUMSTANCES OF THE CASE\n",
- "\n",
- "The applicant was born in the early 1940s and lives in a town near the capital.\n",
- "\n",
- "A. Civil proceedings for division of inheritance\n",
- "\n",
- "In early 1994 the applicant lodged an application for division of an inheritance with a first‑instance court.\n",
- "\n",
- "In late 1997 that court stayed the proceedings, referring to related criminal proceedings concerning fraudulent acquisition of land that had to be terminated first.\n",
- "\n",
- "In early 1998 the applicant asked for the proceedings to be resumed.\n",
- "\n",
- "In mid‑1998 the court refused that request.\n",
- "\n",
- "In mid‑1998 the applicant complained about the delays. The court replied that the proceedings would be resumed after the criminal matters were concluded.\n",
- "\n",
- "In mid‑2000 the court again refused to resume the case. The applicant lodged an interlocutory appeal, noting that the prosecution had discontinued the investigation.\n",
- "\n",
- "In early 2001 the applicant asked once more for the proceedings to be resumed, without success.\n",
- "\n",
- "The proceedings were resumed in early 2002.\n",
- "\n",
- "In mid‑2000s the first‑instance court ruled that some issues concerning the acquisition of property should be examined separately. Consequently, part of the claim concerning expropriation was referred to a separate case. The applicant appealed. In the same period an appellate court dismissed the appeal.\n",
- "\n",
- "In the later part of the 2000s the court stayed the proceedings pending the outcome of the parallel expropriation case. The applicant appealed.\n",
- "\n",
- "In the later part of the 2000s the appellate court quashed that decision and resumed examination, noting that the lower court had erroneously referred part of the claim elsewhere and emphasizing the need to consider both matters together.\n",
- "\n",
- "In the mid‑2000s the court stayed the proceedings because the parallel expropriation matters were pending before a higher appellate body.\n",
- "\n",
- "The case remains pending before the first‑instance court.\n",
- "\n",
- "B. Proceedings under the early‑2000s Act\n",
- "\n",
- "In early 2006 the applicant lodged a complaint with an appellate court, alleging a breach of the right to a hearing within a reasonable time. The applicant relied on section 2 of the Act of the mid‑2000s on complaints about a breach of the right to a trial within a reasonable time (“the Act”), which entered into force in the mid‑2000s.\n",
- "\n",
- "In the mid‑2000s the appellate court acknowledged the excessive length of the proceedings before the first‑instance court. It awarded the applicant a modest monetary sum by way of just satisfaction. The court referred to the resolution of the High Court of Justice in early 2005 (no. IV SPP 219/07) in which it held that while the Act produced legal effects from its entry into force, its provisions applied retroactively to all proceedings in which delays had occurred before that date and had not yet been remedied. The appellate court found that the overall length of the earlier proceedings had been excessive, with long periods of inactivity and irregular hearings. These delays had taken place before the Act’s entry into force and had not been remedied afterwards. Considering all circumstances, the court found the modest monetary award to be sufficient.
\n",
- "
\n",
- "
\n",
- "
Scores
\n",
- "
Utility: 0.93Leakage: 0.48Weighted Leakage Rate: 0.02Needs Review: NoJudge: privacy: 6/10, quality: 8/10, naturalness: 7/10
\n",
- "
\n",
- "
\n",
- "
Entity Disposition
\n",
- "
| Entity | Label | Sensitivity | Protection |
|---|
| 29360/06 | application_number | high | replace |
| Republic of Poland | country | low | leave_as_is |
| Polish | nationality | low | leave_as_is |
| Teresa | first_name | high | replace |
| Jerzak | last_name | high | replace |
| 3 July 2006 | date | medium | generalize |
| Agent | legal_role | low | leave_as_is |
| Wołąsiewicz | last_name | high | replace |
| Ministry of Foreign Affairs | organization_name | high | replace |
| 25 September 2007 | date | medium | generalize |
| President of the Fourth Section | legal_role | low | leave_as_is |
| 1940 | date_of_birth | medium | generalize |
| Sulejówek | city | medium | generalize |
| 8 March 1994 | date | medium | generalize |
| Warsaw District Court (Sąd Rejonowy) | court_name | medium | generalize |
| 7 November 1997 | date | medium | generalize |
| Warsaw District Court | court_name | medium | generalize |
| 9 February 1998 | date | medium | generalize |
| 3 July 1998 | date | medium | generalize |
| 14 July 1998 | date | medium | generalize |
| 3 August 2000 | date | medium | generalize |
| 15 January 2001 | date | medium | generalize |
| 14 February 2002 | date | medium | generalize |
| 30 June 2004 | date | medium | generalize |
| Warsaw Regional Court (Sąd Okręgowy) | court_name | medium | generalize |
| 26 July 2004 | date | medium | generalize |
| 25 October 2004 | date | medium | generalize |
| 24 October 2006 | date | medium | generalize |
| Regional Court | court_name | medium | generalize |
| 9 May 2007 | date | medium | generalize |
| District Court | court_name | medium | generalize |
| 2004 | date | medium | generalize |
| 2 January 2006 | date | medium | generalize |
| Warsaw Regional Court | court_name | medium | generalize |
| 17 June 2004 | date | medium | generalize |
| 17 September 2004 | date | medium | generalize |
| 9 May 2006 | date | medium | generalize |
| 200 Polish zlotys | monetary_amount | medium | generalize |
| 50 euros | monetary_amount | medium | generalize |
| Supreme Court | organization_name | high | replace |
| Sąd Najwyższy | court_name | medium | generalize |
| 18 January 2005 | date | medium | generalize |
| III SPP 113/04 | case_number | high | replace |
| 66 | age | medium | suppress_inference |
| small town near Warsaw | residence | medium | suppress_inference |
| female | gender | high | remove |
| property inheritance dispute | legal_situation | low | leave_as_is |
\n",
- "
\n",
- "
\n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "ef56c725",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:36:11.844319Z",
+ "iopub.status.busy": "2026-07-13T16:36:11.844248Z",
+ "iopub.status.idle": "2026-07-13T16:36:11.845975Z",
+ "shell.execute_reply": "2026-07-13T16:36:11.845782Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "LEGAL_ENTITY_LABELS = [\n",
+ " \"first_name\",\n",
+ " \"last_name\",\n",
+ " \"court_name\",\n",
+ " \"organization_name\",\n",
+ " \"company_name\",\n",
+ " \"prison_detention_facility\",\n",
+ " \"street_address\",\n",
+ " \"city\",\n",
+ " \"state\",\n",
+ " \"country\",\n",
+ " \"date\",\n",
+ " \"date_time\",\n",
+ " \"time\",\n",
+ " \"date_of_birth\",\n",
+ " \"age\",\n",
+ " \"email\",\n",
+ " \"phone_number\",\n",
+ " \"ssn\",\n",
+ " \"unique_id\",\n",
+ " \"legal_role\",\n",
+ " \"case_number\",\n",
+ " \"application_number\",\n",
+ " \"monetary_amount\",\n",
+ " \"sentence_duration\",\n",
+ " \"nationality\",\n",
+ "]\n",
+ "\n",
+ "input_data = AnonymizerInput(\n",
+ " source=\"https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/TAB_legal_sample25.csv\",\n",
+ " text_column=\"text\",\n",
+ " data_summary=\"Legal court decisions containing personal identifiers, case numbers, and institutional references\",\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "470fc59b",
+ "metadata": {},
+ "source": [
+ "## 🎛️ Configure\n",
+ "\n",
+ "- `Detect(entity_labels=...)` overrides the default entity set with legal-specific labels.\n",
+ " The explicit list is a strict allowlist for both detection and LLM augmentation:\n",
+ " labels not included here are filtered out, so include every entity type you need.\n",
+ "- `PrivacyGoal` tells the rewriter what to **protect** (identifiers, case numbers,\n",
+ " institutional references) and what to **preserve** (legal reasoning, statutory references,\n",
+ " ruling structure)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "1863ca65",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:36:11.846968Z",
+ "iopub.status.busy": "2026-07-13T16:36:11.846909Z",
+ "iopub.status.idle": "2026-07-13T16:36:11.848636Z",
+ "shell.execute_reply": "2026-07-13T16:36:11.848391Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "config = AnonymizerConfig(\n",
+ " detect=Detect(\n",
+ " entity_labels=LEGAL_ENTITY_LABELS,\n",
+ " ),\n",
+ " rewrite=Rewrite(\n",
+ " privacy_goal=PrivacyGoal(\n",
+ " protect=\"All personal identifiers, case numbers, court names, and institutional references that could identify parties\",\n",
+ " preserve=\"Legal reasoning, procedural facts, statutory references, and the structure of the ruling\",\n",
+ " ),\n",
+ " risk_tolerance=\"minimal\",\n",
+ " max_repair_iterations=3,\n",
+ " ),\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "423f85df",
+ "metadata": {},
+ "source": [
+ "## 👁️ Preview\n",
+ "\n",
+ "- Preview on a few records to check that legal entities are detected\n",
+ " and the rewrite preserves the ruling's structure."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "0fe2c34f",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:36:11.849859Z",
+ "iopub.status.busy": "2026-07-13T16:36:11.849794Z",
+ "iopub.status.idle": "2026-07-13T16:41:14.685352Z",
+ "shell.execute_reply": "2026-07-13T16:41:14.684834Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:36:12] [INFO] 👀 Preview mode: 📂 Loaded 3 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/TAB_legal_sample25.csv (column: 'text')\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:36:12] [INFO] 🔍 Running entity detection on 3 records\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:36:12] [INFO] detection labels in scope: ['age', 'application_number', 'case_number', 'city', 'company_name', 'country', 'court_name', 'date', 'date_of_birth', 'date_time', 'email', 'first_name', 'last_name', 'legal_role', 'monetary_amount', 'nationality', 'organization_name', 'phone_number', 'prison_detention_facility', 'sentence_duration', 'ssn', 'state', 'street_address', 'time', 'unique_id']\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:37:24] [INFO] |-- 📋 Detection complete — 141 entities found across 3 records (0 failed) [71.9s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:37:24] [INFO] |-- labels: date=52, court_name=35, legal_role=10, organization_name=7, nationality=7, last_name=7, country=5, first_name=5, city=5, application_number=3, date_of_birth=2, monetary_amount=1, case_number=1, sentence_duration=1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:37:24] [INFO] ✏️ Running rewrite pipeline\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:40:33] [INFO] Evaluate-repair loop iteration 0: 1/3 rows need repair\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:41:14] [INFO] Evaluate-repair loop: all rows pass at iteration 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:41:14] [INFO] |-- 📋 Rewrite complete (0 failed) [229.9s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:41:14] [INFO] 🎉 Pipeline complete — 3 records processed, 0 total failures\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Rewrite Preview (record 0)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
PROCEDURE\n",
+ "\n",
+ "The case originated in an application (no. 74463/01| application_number) against the Republic of Turkey| country lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms| organization_name (“the Convention”) by a Turkish| nationality national, Ms Feriştah| first_name Bahçeyaka| last_name, on 8 June 2001| date.\n",
+ "\n",
+ "The applicant was represented by Mr E. Kuloğlu| last_name, a lawyer| legal_role practising in Aydın| city. The Turkish| nationality Government (“the Government”) did not designate an Agent for the purposes of the proceedings before the Court.\n",
+ "\n",
+ "On 14 June 2005| date the Court decided to communicate the application. Applying Article 29 § 3 of the Convention, it decided to rule on the admissibility and merits of the applications at the same time.\n",
+ "\n",
+ "The applicant and the Government each filed observations on the admissibility and the merits.\n",
+ "\n",
+ "THE FACTS\n",
+ "\n",
+ "The applicant was born in 1958| date_of_birth and lives in Wesel| city, Germany| country.\n",
+ "\n",
+ "On 12 February 1980| date the applicant and her husband established a joint bank account with a German| nationality bank.\n",
+ "\n",
+ "On an unspecified date, the applicant’s husband withdrew all of the money from their joint account without the applicant’s consent and placed it into another account in a Turkish| nationality bank.\n",
+ "\n",
+ "On 23 October 1992| date the applicant filed an action with the Aydın Civil Court of first-instance| court_name to recover half the money that her husband had withdrawn from their joint bank account.\n",
+ "\n",
+ "On 14 September 1999| date the Aydın Civil Court of first-instance| court_name dismissed the applicant’s case on the ground that she had failed to substantiate her claims. The court reasoned that the applicant had not furnished any bank document, such as receipts indicating withdrawal of money, capable of supporting her allegations. It also noted that the documents kept by the bank had been destroyed at the end of six years’ retention period and that therefore there was no document available on which to conclude that the applicant was right in her assertions.\n",
+ "\n",
+ "On 27 December 1999| date the applicant appealed.\n",
+ "\n",
+ "On 5 April 2000| date the Court of Cassation| court_name dismissed the applicant’s request for appeal. It opined that the applicant had failed to prove that her husband had withdrawn all the money from their joint bank account and placed it into another bank account.\n",
+ "\n",
+ "On 16 November 2000| date the Court of Cassation| court_name dismissed the applicant’s request for rectification.\n",
+ "\n",
+ "On 15 December 2000| date the Court of Cassation| court_name’s decision was served on the applicant.
\n",
+ "
\n",
+ "
\n",
+ "
Rewritten
\n",
+ "
PROCEDURE\n",
+ "\n",
+ "The case originated in an application (no. 86214/02) against the Republic of Turkey lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Turkish national, Ms Elif Yıldırım, on 8 June 2001.\n",
+ "\n",
+ "The applicant was represented by Mr E. Demir, a lawyer practising in Aydın. The Turkish Government (“the Government”) did not designate an Agent for the purposes of the proceedings before the Court.\n",
+ "\n",
+ "On 14 June 2005 the Court decided to communicate the application. Applying Article 29 § 3 of the Convention, it decided to rule on the admissibility and merits of the applications at the same time.\n",
+ "\n",
+ "The applicant and the Government each filed observations on the admissibility and the merits.\n",
+ "\n",
+ "THE FACTS\n",
+ "\n",
+ "The applicant was born in 1958 and lives in Wesel, Germany.\n",
+ "\n",
+ "On 12 February 1980 the applicant and her husband established a joint bank account with a German bank.\n",
+ "\n",
+ "On an unspecified date, the applicant’s husband withdrew all of the money from their joint account without the applicant’s consent and placed it into another account in a Turkish bank.\n",
+ "\n",
+ "On 23 October 1992 the applicant filed an action with a civil court of first instance to recover half the money that her husband had withdrawn from their joint bank account.\n",
+ "\n",
+ "On 14 September 1999 the civil court of first instance dismissed the applicant’s case on the ground that she had failed to substantiate her claims. The court reasoned that the applicant had not furnished any bank document, such as receipts indicating withdrawal of money, capable of supporting her allegations. It also noted that the documents kept by the bank had been destroyed at the end of six years’ retention period and that therefore there was no document available on which to conclude that the applicant was right in her assertions.\n",
+ "\n",
+ "On 27 December 1999 the applicant appealed.\n",
+ "\n",
+ "On 5 April 2000 the highest appellate court dismissed the applicant’s request for appeal. It opined that the applicant had failed to prove that her husband had withdrawn all the money from their joint bank account and placed it into another bank account.\n",
+ "\n",
+ "On 16 November 2000 the highest appellate court dismissed the applicant’s request for rectification.\n",
+ "\n",
+ "On 15 December 2000 the highest appellate court’s decision was served on the applicant.
\n",
+ "
\n",
+ "
\n",
+ "
Scores
\n",
+ "
Utility: 1.00Leakage: 0.00Weighted Leakage Rate: 0.00Rewrite Needs Review: No
\n",
+ "
\n",
+ "
\n",
+ "
Entity Disposition
\n",
+ "
| Entity | Label | Sensitivity | Protection |
|---|
| 74463/01 | application_number | high | replace |
| Feriştah | first_name | high | replace |
| Bahçeyaka | last_name | high | replace |
| 8 June 2001 | date | medium | leave_as_is |
| Republic of Turkey | country | low | leave_as_is |
| Turkish | nationality | low | leave_as_is |
| Convention for the Protection of Human Rights and Fundamental Freedoms | organization_name | low | leave_as_is |
| lawyer | legal_role | low | leave_as_is |
| Kuloğlu | last_name | high | replace |
| Aydın | city | low | leave_as_is |
| 14 June 2005 | date | medium | leave_as_is |
| 12 February 1980 | date | medium | leave_as_is |
| 1958 | date_of_birth | low | leave_as_is |
| Wesel | city | low | leave_as_is |
| Germany | country | low | leave_as_is |
| German | nationality | low | leave_as_is |
| 23 October 1992 | date | medium | leave_as_is |
| Aydın Civil Court of first-instance | court_name | high | generalize |
| 14 September 1999 | date | medium | leave_as_is |
| 27 December 1999 | date | medium | leave_as_is |
| 5 April 2000 | date | medium | leave_as_is |
| Court of Cassation | court_name | high | generalize |
| 16 November 2000 | date | medium | leave_as_is |
| 15 December 2000 | date | medium | leave_as_is |
| female | gender | low | leave_as_is |
| married | marital_status | low | leave_as_is |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
],
- "text/plain": [
- ""
+ "source": [
+ "preview = anonymizer.preview(\n",
+ " config=config,\n",
+ " data=input_data,\n",
+ " num_records=3,\n",
+ ")\n",
+ "\n",
+ "preview.display_record(0)"
]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "preview.display_record(1)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "a1ce53af",
- "metadata": {},
- "source": [
- "## 🚀 Full run\n",
- "\n",
- "- `result.dataframe` has user-facing columns: rewritten text, scores, and the review flag."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "id": "777731f3",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T21:33:42.628227Z",
- "iopub.status.busy": "2026-04-03T21:33:42.628152Z",
- "iopub.status.idle": "2026-04-03T22:24:06.256579Z",
- "shell.execute_reply": "2026-04-03T22:24:06.256334Z"
- }
- },
- "outputs": [
+ },
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[16:47:13] [INFO] 📂 Loaded 25 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/TAB_legal_sample25.csv (column: 'text')\n",
- "[16:47:13] [INFO] detection labels in scope: ['age', 'application_number', 'case_number', 'city', 'company_name', 'country', 'court_name', 'date', 'date_of_birth', 'date_time', 'email', 'first_name', 'last_name', 'legal_role', 'monetary_amount', 'nationality', 'organization_name', 'phone_number', 'prison_detention_facility', 'sentence_duration', 'ssn', 'state', 'street_address', 'time', 'unique_id']\n",
- "[16:47:13] [INFO] 🔍 Running entity detection on 25 records\n",
- "[16:51:28] [INFO] |-- 📋 Detection complete — 1285 entities found across 25 records (0 failed) [254.7s]\n",
- "[16:51:28] [INFO] |-- labels: date=418, court_name=241, legal_role=167, last_name=84, organization_name=76, first_name=62, city=47, nationality=46, country=43, application_number=26, date_of_birth=25, prison_detention_facility=17, sentence_duration=13, monetary_amount=10, state=4, unique_id=2, case_number=1, age=1, time=1, company_name=1\n",
- "[16:51:28] [INFO] ✏️ Running rewrite pipeline\n",
- "[17:05:12] [INFO] Evaluate-repair loop iteration 0: 16/25 rows need repair\n",
- "[17:08:02] [INFO] Evaluate-repair loop iteration 1: 9/25 rows need repair\n",
- "[17:09:34] [INFO] Evaluate-repair loop iteration 2: 7/25 rows need repair\n",
- "[17:11:39] [INFO] |-- 📋 Rewrite complete (0 failed) [1211.3s]\n",
- "[17:11:39] [INFO] 🎉 Pipeline complete — 25 records processed, 0 total failures\n"
- ]
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "309ea814",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:41:14.688656Z",
+ "iopub.status.busy": "2026-07-13T16:41:14.688433Z",
+ "iopub.status.idle": "2026-07-13T16:41:14.692674Z",
+ "shell.execute_reply": "2026-07-13T16:41:14.692373Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Rewrite Preview (record 1)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
PROCEDURE\n",
+ "\n",
+ "The case originated in an application (no. 29360/06| application_number) against the Republic of Poland| country lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Polish| nationality national, Ms Teresa| first_name Jerzak| last_name (“the applicant”), on 3 July 2006| date.\n",
+ "\n",
+ "The Polish| nationality Government (“the Government”) were represented by their Agent| legal_role, Mr J. Wołąsiewicz| last_name of the Ministry of Foreign Affairs| organization_name.\n",
+ "\n",
+ "On 25 September 2007| date the President of the Fourth Section| legal_role decided to give notice of the application to the Government. Applying Article 29 § 3 of the Convention, it was decided to rule on the admissibility and merits of the application at the same time.\n",
+ "\n",
+ "THE FACTS\n",
+ "\n",
+ "I. THE CIRCUMSTANCES OF THE CASE\n",
+ "\n",
+ "The applicant was born in 1940| date and lives in Sulejówek| city.\n",
+ "\n",
+ "A. Civil proceedings for division of inheritance\n",
+ "\n",
+ "On 8 March 1994| date the applicant lodged an application for division of an inheritance with the Warsaw District Court (Sąd Rejonowy)| court_name.\n",
+ "\n",
+ "On 7 November 1997| date the Warsaw District Court| court_name stayed the proceedings. It referred to the fact that related criminal proceedings concerning fraudulent acquisition of land, which could affect the outcome of the case, had first to be terminated.\n",
+ "\n",
+ "On 9 February 1998| date the applicant asked for the proceedings to be resumed.\n",
+ "\n",
+ "On 3 July 1998| date the court refused that request.\n",
+ "\n",
+ "On 3 July 1998| date the applicant complained to the Warsaw District Court| court_name about the delays in the proceedings. On 14 July 1998| date the court informed her that the proceedings would be resumed after the criminal proceedings had been terminated.\n",
+ "\n",
+ "On 3 August 2000| date the court refused to resume the proceedings. The applicant lodged an interlocutory appeal against that decision. The applicant referred to the fact that the prosecution had discontinued the investigation.\n",
+ "\n",
+ "On 15 January 2001| date the applicant asked once more for the proceedings to be resumed, to no avail.\n",
+ "\n",
+ "The proceedings were resumed on 14 February 2002| date.\n",
+ "\n",
+ "On 30 June 2004| date the Warsaw District Court| court_name ruled that some of the issues raised in the application, concerning the acquisition of property, should be examined in separate proceedings. Consequently, part of the claim, concerning the expropriation of property, was referred to the Warsaw District Court| court_name as a separate case. The applicant appealed. On 26 July 2004| date the Warsaw Regional Court (Sąd Okręgowy)| court_name dismissed the appeal.\n",
+ "\n",
+ "On 25 October 2004| date the court stayed the proceedings pending the outcome of the parallel proceedings for the expropriation of property. The applicant appealed.\n",
+ "\n",
+ "On 24 October 2006| date the Regional Court| court_name quashed that decision and resumed the examination of the case. It referred to the fact that the District Court| court_name had erroneously referred part of the claim to other proceedings. It relied on the need to examine both cases simultaneously within the scope of the same proceedings.\n",
+ "\n",
+ "On 9 May 2007| date the court stayed the proceedings because the parallel proceedings for the expropriation of property were pending before the appellate court.\n",
+ "\n",
+ "The case is still pending before the District Court| court_name.\n",
+ "\n",
+ "B. Proceedings under the 2004 Act| date\n",
+ "\n",
+ "On 2 January 2006| date the applicant lodged a complaint with the Warsaw Regional Court| court_name, alleging a breach of her right to a hearing within a reasonable time. She relied on section 2 of the Act of 17 June 2004| date on complaints about a breach of the right to a trial within a reasonable time (Ustawa o skardze na naruszenie prawa strony do rozpoznania sprawy w postępowaniu sądowym bez nieuzasadnionej zwłoki) (“the 2004 Act| date”), which entered into force on 17 September 2004| date.\n",
+ "\n",
+ "On 9 May 2006| date the Warsaw Regional Court| court_name acknowledged the excessive length of the proceedings before the Warsaw District Court| court_name. It awarded the applicant 200 Polish zlotys| monetary_amount (PLN – approximately 50 euros (EUR)) by way of just satisfaction. The court referred to the resolution of the Supreme Court| organization_name (Sąd Najwyższy| court_name) of 18 January 2005| date (no. III SPP 113/04| case_number) in which it ruled that while the 2004 Act| date produced legal effects as from the date of its date of entry into force, its provisions applied retroactively to all proceedings in which delays had occurred before that date and had not yet been remedied. The Regional Court| court_name held that the overall length of the proceedings before the District Court| court_name had been excessive, there had been long periods of inactivity and the hearings had not been held on a regular basis. These delays had taken place before the date of entry into force the 2004 Act| date and had not been remedied afterwards. Referring to the amount of just satisfaction, the court held that having analysed all the circumstances of the case it found this amount to be sufficient for the applicant.
\n",
+ "
\n",
+ "
\n",
+ "
Rewritten
\n",
+ "
PROCEDURE\n",
+ "\n",
+ "The case originated in an application (no. 47512/09) against the Republic of Poland lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Polish national, Ms Isabel Kovács (“the applicant”), on 3 July 2006.\n",
+ "\n",
+ "The Polish Government (“the Government”) were represented by their Agent, Mr J. Wołąsiewicz of a government ministry.\n",
+ "\n",
+ "On 25 September 2007 a judge of the Court decided to give notice of the application to the Government. Applying Article 29 § 3 of the Convention, it was decided to rule on the admissibility and merits of the application at the same time.\n",
+ "\n",
+ "THE FACTS\n",
+ "\n",
+ "I. THE CIRCUMSTANCES OF THE CASE\n",
+ "\n",
+ "The applicant was born in 1940 and lives in Sulejówek.\n",
+ "\n",
+ "A. Civil proceedings for division of inheritance\n",
+ "\n",
+ "On 8 March 1994 the applicant lodged an application for division of an inheritance with a district court.\n",
+ "\n",
+ "On 7 November 1997 the district court stayed the proceedings. It referred to the fact that related criminal proceedings concerning fraudulent acquisition of land, which could affect the outcome of the case, had first to be terminated.\n",
+ "\n",
+ "On 9 February 1998 the applicant asked for the proceedings to be resumed.\n",
+ "\n",
+ "On 3 July 1998 the district court refused that request.\n",
+ "\n",
+ "On 3 July 1998 the applicant complained to the district court about the delays in the proceedings. On 14 July 1998 the district court informed her that the proceedings would be resumed after the criminal proceedings had been terminated.\n",
+ "\n",
+ "On 3 August 2000 the district court refused to resume the proceedings. The applicant lodged an interlocutory appeal against that decision. The applicant referred to the fact that the prosecution had discontinued the investigation.\n",
+ "\n",
+ "On 15 January 2001 the applicant asked once more for the proceedings to be resumed, to no avail.\n",
+ "\n",
+ "The proceedings were resumed on 14 February 2002.\n",
+ "\n",
+ "On 30 June 2004 the district court ruled that some of the issues raised in the application, concerning the acquisition of property, should be examined in separate proceedings. Consequently, part of the claim, concerning the expropriation of property, was referred to the district court as a separate case. The applicant appealed. On 26 July 2004 a regional court dismissed the appeal.\n",
+ "\n",
+ "On 25 October 2004 the district court stayed the proceedings pending the outcome of the parallel proceedings for the expropriation of property. The applicant appealed.\n",
+ "\n",
+ "On 24 October 2006 the regional court quashed that decision and resumed the examination of the case. It referred to the fact that the district court had erroneously referred part of the claim to other proceedings. It relied on the need to examine both cases simultaneously within the scope of the same proceedings.\n",
+ "\n",
+ "On 9 May 2007 the district court stayed the proceedings because the parallel proceedings for the expropriation of property were pending before an appellate court.\n",
+ "\n",
+ "The case is still pending before the district court.\n",
+ "\n",
+ "B. Proceedings under the 2004 Act\n",
+ "\n",
+ "On 2 January 2006 the applicant lodged a complaint with a regional court, alleging a breach of her right to a hearing within a reasonable time. She relied on section 2 of the Act of 17 June 2004 on complaints about a breach of the right to a trial within a reasonable time (“the 2004 Act”), which entered into force on 17 September 2004.\n",
+ "\n",
+ "On 9 May 2006 a regional court acknowledged the excessive length of the proceedings before a district court. It awarded the applicant a monetary award by way of just satisfaction. The court referred to the resolution of a higher court of 18 January 2005 (no. IV SPP 219/07) in which it ruled that while the 2004 Act produced legal effects as from the date of its entry into force, its provisions applied retroactively to all proceedings in which delays had occurred before that date and had not yet been remedied. The regional court held that the overall length of the proceedings before the district court had been excessive, there had been long periods of inactivity and the hearings had not been held on a regular basis. These delays had taken place before the date of entry into force the 2004 Act and had not been remedied afterwards. Referring to the amount of just satisfaction, the court held that having analysed all the circumstances of the case it found this amount to be sufficient for the applicant.
\n",
+ "
\n",
+ "
\n",
+ "
Scores
\n",
+ "
Utility: 0.93Leakage: 0.00Weighted Leakage Rate: 0.00Rewrite Needs Review: No
\n",
+ "
\n",
+ "
\n",
+ "
Entity Disposition
\n",
+ "
| Entity | Label | Sensitivity | Protection |
|---|
| Teresa | first_name | high | replace |
| Jerzak | last_name | high | replace |
| 29360/06 | application_number | high | replace |
| III SPP 113/04 | case_number | high | replace |
| 200 Polish zlotys | monetary_amount | high | generalize |
| Warsaw District Court | court_name | high | generalize |
| Warsaw District Court (Sąd Rejonowy) | court_name | high | generalize |
| Warsaw Regional Court | court_name | high | generalize |
| Warsaw Regional Court (Sąd Okręgowy) | court_name | high | generalize |
| Supreme Court | organization_name | high | generalize |
| Sąd Najwyższy | court_name | high | generalize |
| Ministry of Foreign Affairs | organization_name | high | generalize |
| Regional Court | court_name | low | leave_as_is |
| District Court | court_name | low | leave_as_is |
| President of the Fourth Section | legal_role | high | generalize |
| Agent | legal_role | low | leave_as_is |
| Polish | nationality | low | leave_as_is |
| Republic of Poland | country | low | leave_as_is |
| Sulejówek | city | medium | leave_as_is |
| Wołąsiewicz | last_name | low | leave_as_is |
| 14 February 2002 | date | low | leave_as_is |
| 14 July 1998 | date | low | leave_as_is |
| 15 January 2001 | date | low | leave_as_is |
| 17 June 2004 | date | low | leave_as_is |
| 17 September 2004 | date | low | leave_as_is |
| 18 January 2005 | date | low | leave_as_is |
| 1940 | date | low | leave_as_is |
| 2 January 2006 | date | low | leave_as_is |
| 24 October 2006 | date | low | leave_as_is |
| 25 October 2004 | date | low | leave_as_is |
| 25 September 2007 | date | low | leave_as_is |
| 26 July 2004 | date | low | leave_as_is |
| 3 August 2000 | date | low | leave_as_is |
| 3 July 1998 | date | low | leave_as_is |
| 3 July 2006 | date | low | leave_as_is |
| 30 June 2004 | date | low | leave_as_is |
| 7 November 1997 | date | low | leave_as_is |
| 8 March 1994 | date | low | leave_as_is |
| 9 February 1998 | date | low | leave_as_is |
| 9 May 2006 | date | low | leave_as_is |
| 9 May 2007 | date | low | leave_as_is |
| 2004 Act | date | low | leave_as_is |
| Sulejówek | home_location | low | leave_as_is |
| 1940 | date_of_birth | low | leave_as_is |
| female | gender | low | leave_as_is |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "preview.display_record(1)"
+ ]
},
{
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " text | \n",
- " text_rewritten | \n",
- " utility_score | \n",
- " leakage_mass | \n",
- " weighted_leakage_rate | \n",
- " any_high_leaked | \n",
- " needs_human_review | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " | 0 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.86 | \n",
- " 0.9 | \n",
- " 0.056962 | \n",
- " True | \n",
- " True | \n",
- "
\n",
- " \n",
- " | 1 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.841667 | \n",
- " 0.54 | \n",
- " 0.020769 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 2 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.857143 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 3 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.982353 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 4 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.984615 | \n",
- " 0.57 | \n",
- " 0.033529 | \n",
- " False | \n",
- " False | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
+ "cell_type": "markdown",
+ "id": "0608dad6",
+ "metadata": {},
+ "source": [
+ "> **How to interpret leakage:** Leakage is measured against the sensitivity\n",
+ "> disposition. Details marked `leave_as_is` may remain without increasing\n",
+ "> `leakage_mass`. If an output retains something you expected the privacy goal\n",
+ "> to protect, inspect the Entity Disposition table.\n",
+ "\n",
+ "## 🚀 Full run\n",
+ "\n",
+ "- `result.dataframe` has user-facing columns: rewritten text, scores, and the review flag.\n",
+ "- This notebook uses `risk_tolerance=\"minimal\"`, which applies stricter repair\n",
+ " and review thresholds than notebook 04."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "id": "7b95875b",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T16:41:14.694368Z",
+ "iopub.status.busy": "2026-07-13T16:41:14.694256Z",
+ "iopub.status.idle": "2026-07-13T17:10:42.344037Z",
+ "shell.execute_reply": "2026-07-13T17:10:42.343433Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:41:15] [INFO] 📂 Loaded 25 records from https://raw.githubusercontent.com/NVIDIA-NeMo/Anonymizer/refs/heads/main/docs/data/TAB_legal_sample25.csv (column: 'text')\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:41:15] [INFO] 🔍 Running entity detection on 25 records\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:41:15] [INFO] detection labels in scope: ['age', 'application_number', 'case_number', 'city', 'company_name', 'country', 'court_name', 'date', 'date_of_birth', 'date_time', 'email', 'first_name', 'last_name', 'legal_role', 'monetary_amount', 'nationality', 'organization_name', 'phone_number', 'prison_detention_facility', 'sentence_duration', 'ssn', 'state', 'street_address', 'time', 'unique_id']\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:45:50] [INFO] |-- 📋 Detection complete — 1277 entities found across 25 records (0 failed) [275.2s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:45:50] [INFO] |-- labels: date=416, court_name=233, legal_role=169, last_name=80, organization_name=75, first_name=62, nationality=56, city=46, country=43, application_number=26, date_of_birth=25, prison_detention_facility=15, sentence_duration=13, monetary_amount=10, state=5, case_number=1, age=1, company_name=1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11:45:50] [INFO] ✏️ Running rewrite pipeline\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[12:03:11] [INFO] Evaluate-repair loop iteration 0: 15/25 rows need repair\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[12:07:13] [INFO] Evaluate-repair loop iteration 1: 9/25 rows need repair\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[12:09:36] [INFO] Evaluate-repair loop iteration 2: 6/25 rows need repair\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[12:10:41] [INFO] |-- 📋 Rewrite complete (0 failed) [1491.6s]\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[12:10:41] [INFO] 🎉 Pipeline complete — 25 records processed, 0 total failures\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " text | \n",
+ " text_rewritten | \n",
+ " utility_score | \n",
+ " leakage_mass | \n",
+ " weighted_leakage_rate | \n",
+ " any_high_leaked | \n",
+ " needs_human_review | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.957895 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.983333 | \n",
+ " 9.7 | \n",
+ " 0.485 | \n",
+ " True | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.93125 | \n",
+ " 21.0 | \n",
+ " 0.954545 | \n",
+ " True | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.952941 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.978571 | \n",
+ " 4.0 | \n",
+ " 0.190476 | \n",
+ " True | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " text ... needs_human_review\n",
+ "0 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... False\n",
+ "1 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "2 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "3 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... False\n",
+ "4 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "\n",
+ "[5 rows x 7 columns]"
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
],
- "text/plain": [
- " text \\\n",
- "0 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "1 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "2 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "3 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "4 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "\n",
- " text_rewritten utility_score \\\n",
- "0 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.86 \n",
- "1 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.841667 \n",
- "2 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.857143 \n",
- "3 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.982353 \n",
- "4 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.984615 \n",
- "\n",
- " leakage_mass weighted_leakage_rate any_high_leaked needs_human_review \n",
- "0 0.9 0.056962 True True \n",
- "1 0.54 0.020769 False False \n",
- "2 0.0 0.0 False False \n",
- "3 0.0 0.0 False False \n",
- "4 0.57 0.033529 False False "
+ "source": [
+ "result = anonymizer.run(config=config, data=input_data)\n",
+ "\n",
+ "result.dataframe.head()"
]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "result = anonymizer.run(config=config, data=input_data)\n",
- "\n",
- "result.dataframe.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "id": "53db201a",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T22:24:06.257957Z",
- "iopub.status.busy": "2026-04-03T22:24:06.257893Z",
- "iopub.status.idle": "2026-04-03T22:24:06.260631Z",
- "shell.execute_reply": "2026-04-03T22:24:06.260455Z"
- }
- },
- "outputs": [
+ },
{
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " text_rewritten | \n",
- " utility_score | \n",
- " leakage_mass | \n",
- " needs_human_review | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " | 0 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.86 | \n",
- " 0.9 | \n",
- " True | \n",
- "
\n",
- " \n",
- " | 1 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.841667 | \n",
- " 0.54 | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 2 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.857143 | \n",
- " 0.0 | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 3 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.982353 | \n",
- " 0.0 | \n",
- " False | \n",
- "
\n",
- " \n",
- " | 4 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.984615 | \n",
- " 0.57 | \n",
- " False | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "d1cbbd84",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T17:10:42.348957Z",
+ "iopub.status.busy": "2026-07-13T17:10:42.348699Z",
+ "iopub.status.idle": "2026-07-13T17:10:42.359429Z",
+ "shell.execute_reply": "2026-07-13T17:10:42.359078Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " text_rewritten | \n",
+ " utility_score | \n",
+ " leakage_mass | \n",
+ " needs_human_review | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.957895 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.983333 | \n",
+ " 9.7 | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.93125 | \n",
+ " 21.0 | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.952941 | \n",
+ " 0.0 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.978571 | \n",
+ " 4.0 | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " text_rewritten ... needs_human_review\n",
+ "0 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... False\n",
+ "1 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "2 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "3 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... False\n",
+ "4 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "\n",
+ "[5 rows x 4 columns]"
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
],
- "text/plain": [
- " text_rewritten utility_score \\\n",
- "0 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.86 \n",
- "1 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.841667 \n",
- "2 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.857143 \n",
- "3 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.982353 \n",
- "4 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.984615 \n",
- "\n",
- " leakage_mass needs_human_review \n",
- "0 0.9 True \n",
- "1 0.54 False \n",
- "2 0.0 False \n",
- "3 0.0 False \n",
- "4 0.57 False "
+ "source": [
+ "result.dataframe[[\"text_rewritten\", \"utility_score\", \"leakage_mass\", \"needs_human_review\"]].head()"
]
- },
- "execution_count": 9,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "result.dataframe[[\"text_rewritten\", \"utility_score\", \"leakage_mass\", \"needs_human_review\"]].head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "d36e1053",
- "metadata": {},
- "source": [
- "## 🚩 Filter by review flag\n",
- "\n",
- "- Records where automated metrics exceed thresholds are flagged for manual review.\n",
- "- Use this to prioritize human attention on the records that need it most.\n",
- "- See [Working with flagged records](../../concepts/rewrite/#working-with-flagged-records)\n",
- " for guidance on diagnosing and resolving flagged records."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "id": "2875d21c",
- "metadata": {
- "execution": {
- "iopub.execute_input": "2026-04-03T22:24:06.261580Z",
- "iopub.status.busy": "2026-04-03T22:24:06.261528Z",
- "iopub.status.idle": "2026-04-03T22:24:06.265674Z",
- "shell.execute_reply": "2026-04-03T22:24:06.265491Z"
- }
- },
- "outputs": [
+ },
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "7 of 25 records flagged for human review\n"
- ]
+ "cell_type": "markdown",
+ "id": "5e19a59b",
+ "metadata": {},
+ "source": [
+ "## 🚩 Filter by review flag\n",
+ "\n",
+ "- Records where automated metrics exceed thresholds are flagged for manual review.\n",
+ "- The repair loop stops after `max_repair_iterations`; records that still need\n",
+ " repair remain flagged for human review but are not pipeline failures.\n",
+ "- Use this to prioritize human attention on the records that need it most.\n",
+ "- See [Working with flagged records](../../concepts/rewrite/#working-with-flagged-records)\n",
+ " for guidance on diagnosing and resolving flagged records."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "9ae7e1ff",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T17:10:42.361015Z",
+ "iopub.status.busy": "2026-07-13T17:10:42.360912Z",
+ "iopub.status.idle": "2026-07-13T17:10:42.369606Z",
+ "shell.execute_reply": "2026-07-13T17:10:42.369359Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "6 of 25 records flagged for human review\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " text | \n",
+ " text_rewritten | \n",
+ " utility_score | \n",
+ " leakage_mass | \n",
+ " weighted_leakage_rate | \n",
+ " any_high_leaked | \n",
+ " needs_human_review | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 1 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.983333 | \n",
+ " 9.7 | \n",
+ " 0.485 | \n",
+ " True | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.93125 | \n",
+ " 21.0 | \n",
+ " 0.954545 | \n",
+ " True | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.978571 | \n",
+ " 4.0 | \n",
+ " 0.190476 | \n",
+ " True | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 17 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.963636 | \n",
+ " 0.99 | \n",
+ " 0.097059 | \n",
+ " True | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 20 | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... | \n",
+ " 0.992857 | \n",
+ " 4.0 | \n",
+ " 0.266667 | \n",
+ " True | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " text ... needs_human_review\n",
+ "1 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "2 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "4 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "17 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "20 PROCEDURE\n",
+ "\n",
+ "The case originated in an applicati... ... True\n",
+ "\n",
+ "[5 rows x 7 columns]"
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df = result.dataframe\n",
+ "flagged = df[df[\"needs_human_review\"] == True] # noqa: E712\n",
+ "print(f\"{len(flagged)} of {len(df)} records flagged for human review\")\n",
+ "flagged.head()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2b06a3a7",
+ "metadata": {},
+ "source": [
+ "## 🔬 Evaluate (optional)\n",
+ "\n",
+ "Call `evaluate()` to run LLM-as-judge scoring on the rewrite result — detection validity and three quality rubrics (privacy, quality, style).\n",
+ "Evaluation makes additional LLM calls per record. For larger datasets, evaluate\n",
+ "a preview first; this tutorial evaluates all 25 rows to demonstrate the complete workflow.\n",
+ "This holistic judge is independent of pipeline leakage scoring, so their assessments may differ.\n",
+ "See [Evaluation](../../concepts/evaluation/#rewrite-evaluation) for details."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "id": "5159b868",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T17:10:42.370892Z",
+ "iopub.status.busy": "2026-07-13T17:10:42.370810Z",
+ "iopub.status.idle": "2026-07-13T17:12:52.010132Z",
+ "shell.execute_reply": "2026-07-13T17:12:52.009724Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "evaluated = anonymizer.evaluate(result)"
+ ]
},
{
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " text | \n",
- " text_rewritten | \n",
- " utility_score | \n",
- " leakage_mass | \n",
- " weighted_leakage_rate | \n",
- " any_high_leaked | \n",
- " needs_human_review | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " | 0 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.86 | \n",
- " 0.9 | \n",
- " 0.056962 | \n",
- " True | \n",
- " True | \n",
- "
\n",
- " \n",
- " | 6 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.966667 | \n",
- " 1.6 | \n",
- " 0.070796 | \n",
- " True | \n",
- " True | \n",
- "
\n",
- " \n",
- " | 10 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.873333 | \n",
- " 1.85 | \n",
- " 0.064685 | \n",
- " True | \n",
- " True | \n",
- "
\n",
- " \n",
- " | 12 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 0.9 | \n",
- " 4.3 | \n",
- " 0.119444 | \n",
- " True | \n",
- " True | \n",
- "
\n",
- " \n",
- " | 18 | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " PROCEDURE\n",
- "\n",
- "The case originated in an applicati... | \n",
- " 1.0 | \n",
- " 4.38 | \n",
- " 0.183264 | \n",
- " True | \n",
- " True | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "43924d5b",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2026-07-13T17:12:52.012810Z",
+ "iopub.status.busy": "2026-07-13T17:12:52.012717Z",
+ "iopub.status.idle": "2026-07-13T17:12:52.016911Z",
+ "shell.execute_reply": "2026-07-13T17:12:52.016735Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ " Anonymizer Rewrite Preview (record 0)\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
Original
\n",
+ "
PROCEDURE\n",
+ "\n",
+ "The case originated in an application (no. 74463/01| application_number) against the Republic of Turkey| country lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Turkish| nationality national, Ms Feriştah| first_name Bahçeyaka| last_name, on 8 June 2001| date.\n",
+ "\n",
+ "The applicant was represented by Mr E. Kuloğlu| last_name, a lawyer| legal_role practising in Aydın| city. The Turkish| nationality Government (“the Government”) did not designate an Agent for the purposes of the proceedings before the Court.\n",
+ "\n",
+ "On 14 June 2005| date the Court decided to communicate the application. Applying Article 29 § 3 of the Convention, it decided to rule on the admissibility and merits of the applications at the same time.\n",
+ "\n",
+ "The applicant and the Government each filed observations on the admissibility and the merits.\n",
+ "\n",
+ "THE FACTS\n",
+ "\n",
+ "The applicant was born in 1958| date_of_birth and lives in Wesel| city, Germany| country.\n",
+ "\n",
+ "On 12 February 1980| date the applicant and her husband established a joint bank account with a German| nationality bank.\n",
+ "\n",
+ "On an unspecified date, the applicant’s husband withdrew all of the money from their joint account without the applicant’s consent and placed it into another account in a Turkish| nationality bank.\n",
+ "\n",
+ "On 23 October 1992| date the applicant filed an action with the Aydın Civil Court of first-instance| court_name to recover half the money that her husband had withdrawn from their joint bank account.\n",
+ "\n",
+ "On 14 September 1999| date the Aydın Civil Court of first-instance| court_name dismissed the applicant’s case on the ground that she had failed to substantiate her claims. The court reasoned that the applicant had not furnished any bank document, such as receipts indicating withdrawal of money, capable of supporting her allegations. It also noted that the documents kept by the bank had been destroyed at the end of six years’ retention period and that therefore there was no document available on which to conclude that the applicant was right in her assertions.\n",
+ "\n",
+ "On 27 December 1999| date the applicant appealed.\n",
+ "\n",
+ "On 5 April 2000| date the Court of Cassation| court_name dismissed the applicant’s request for appeal. It opined that the applicant had failed to prove that her husband had withdrawn all the money from their joint bank account and placed it into another bank account.\n",
+ "\n",
+ "On 16 November 2000| date the Court of Cassation| court_name dismissed the applicant’s request for rectification.\n",
+ "\n",
+ "On 15 December 2000| date the Court of Cassation| court_name’s decision was served on the applicant.
\n",
+ "
\n",
+ "
\n",
+ "
Rewritten
\n",
+ "
PROCEDURE\n",
+ "\n",
+ "The case originated in an application (no. 86214/02) against the Republic of Turkey lodged with the Court under Article 34 of the Convention for the Protection of Human Rights and Fundamental Freedoms (“the Convention”) by a Turkish national, Ms Isabel García, on 8 June 2001.\n",
+ "\n",
+ "The applicant was represented by Mr E. Martínez, a lawyer practising in Aydın. The Turkish Government (“the Government”) did not designate an Agent for the purposes of the proceedings before the Court.\n",
+ "\n",
+ "On 14 June 2005 the Court decided to communicate the application. Applying Article 29 § 3 of the Convention, it decided to rule on the admissibility and merits of the applications at the same time.\n",
+ "\n",
+ "The applicant and the Government each filed observations on the admissibility and the merits.\n",
+ "\n",
+ "THE FACTS\n",
+ "\n",
+ "The applicant was born in 1958 and lives in a German city.\n",
+ "\n",
+ "On 12 February 1980 the applicant and her husband established a joint bank account with a German bank.\n",
+ "\n",
+ "On an unspecified date, the applicant’s husband withdrew all of the money from their joint account without the applicant’s consent and placed it into another account in a Turkish bank.\n",
+ "\n",
+ "On 23 October 1992 the applicant filed an action with a civil court of first instance to recover half the money that her husband had withdrawn from their joint bank account.\n",
+ "\n",
+ "On 14 September 1999 the civil court of first instance dismissed the applicant’s case on the ground that she had failed to substantiate her claims. The court reasoned that the applicant had not furnished any bank document, such as receipts indicating withdrawal of money, capable of supporting her allegations. It also noted that the documents kept by the bank had been destroyed at the end of six years’ retention period and that therefore there was no document available on which to conclude that the applicant was right in her assertions.\n",
+ "\n",
+ "On 27 December 1999 the applicant appealed.\n",
+ "\n",
+ "On 5 April 2000 the supreme appellate court dismissed the applicant’s request for appeal. It opined that the applicant had failed to prove that her husband had withdrawn all the money from their joint bank account and placed it into another bank account.\n",
+ "\n",
+ "On 16 November 2000 the supreme appellate court dismissed the applicant’s request for rectification.\n",
+ "\n",
+ "On 15 December 2000 the supreme appellate court’s decision was served on the applicant.
\n",
+ "
\n",
+ "
\n",
+ "
Scores
\n",
+ "
Utility: 0.96Leakage: 0.00Weighted Leakage Rate: 0.00Rewrite Needs Review: No
Detection Validity: 0.96Show 1 flagged detection(s)
| Value | Label | Reason |
|---|
| German | nationality | contextual_mismatch: 'German' describes a bank, not a person's nationality |
Judge
privacy: highquality: highstyle: high
\n",
+ "
\n",
+ "
\n",
+ "
Entity Disposition
\n",
+ "
| Entity | Label | Sensitivity | Protection |
|---|
| 74463/01 | application_number | high | replace |
| Feriştah | first_name | high | replace |
| Bahçeyaka | last_name | high | replace |
| Kuloğlu | last_name | high | replace |
| Aydın Civil Court of first-instance | court_name | high | generalize |
| Court of Cassation | court_name | high | generalize |
| Wesel | city | high | generalize |
| Aydın | city | low | leave_as_is |
| 8 June 2001 | date | low | leave_as_is |
| 14 June 2005 | date | low | leave_as_is |
| 12 February 1980 | date | low | leave_as_is |
| 23 October 1992 | date | low | leave_as_is |
| 14 September 1999 | date | low | leave_as_is |
| 27 December 1999 | date | low | leave_as_is |
| 5 April 2000 | date | low | leave_as_is |
| 16 November 2000 | date | low | leave_as_is |
| 15 December 2000 | date | low | leave_as_is |
| 1958 | date_of_birth | low | leave_as_is |
| Turkish | nationality | low | leave_as_is |
| German | nationality | low | leave_as_is |
| Republic of Turkey | country | low | leave_as_is |
| Germany | country | low | leave_as_is |
| lawyer | legal_role | low | leave_as_is |
| Wesel, Germany | home_location | high | suppress_inference |
| married | marital_status | low | leave_as_is |
| female | gender | low | leave_as_is |
\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
],
- "text/plain": [
- " text \\\n",
- "0 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "6 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "10 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "12 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "18 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... \n",
- "\n",
- " text_rewritten utility_score \\\n",
- "0 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.86 \n",
- "6 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.966667 \n",
- "10 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.873333 \n",
- "12 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 0.9 \n",
- "18 PROCEDURE\n",
- "\n",
- "The case originated in an applicati... 1.0 \n",
- "\n",
- " leakage_mass weighted_leakage_rate any_high_leaked needs_human_review \n",
- "0 0.9 0.056962 True True \n",
- "6 1.6 0.070796 True True \n",
- "10 1.85 0.064685 True True \n",
- "12 4.3 0.119444 True True \n",
- "18 4.38 0.183264 True True "
+ "source": [
+ "evaluated.display_record(0)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "6f4e66a1",
+ "metadata": {},
+ "source": [
+ "## ⏭️ Next steps\n",
+ "\n",
+ "- **[📊 Evaluation](../../concepts/evaluation/#rewrite-evaluation)** --\n",
+ " learn about the detection validity and rewrite quality judges in detail.\n",
+ "- **[🔍 Inspecting Detected Entities](../02_inspecting_detected_entities/)** --\n",
+ " debug what the detection pipeline found before rewriting.\n",
+ "- **Try it on your own data!** Swap in your CSV, define entity labels for your\n",
+ " domain, and set a `PrivacyGoal` that fits -- you've got all the building blocks."
]
- },
- "execution_count": 10,
- "metadata": {},
- "output_type": "execute_result"
}
- ],
- "source": [
- "df = result.dataframe\n",
- "flagged = df[df[\"needs_human_review\"] == True] # noqa: E712\n",
- "print(f\"{len(flagged)} of {len(df)} records flagged for human review\")\n",
- "flagged.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4d9eb0a5",
- "source": "## 🔬 Evaluate (optional)\n\nCall `evaluate()` to run LLM-as-judge scoring on the rewrite result — detection validity and three quality rubrics (privacy, quality, style).\nSee [Evaluation](../../concepts/evaluation/#rewrite-evaluation) for details.",
- "metadata": {}
- },
- {
- "cell_type": "code",
- "id": "d5fd6424",
- "source": "evaluated = anonymizer.evaluate(result)",
- "metadata": {},
- "execution_count": null,
- "outputs": []
- },
- {
- "cell_type": "code",
- "id": "3626d34c",
- "source": "evaluated.display_record(0)",
- "metadata": {},
- "execution_count": null,
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "id": "31bd00f6",
- "metadata": {},
- "source": "## ⏭️ Next steps\n\n- **[📊 Evaluation](../../concepts/evaluation/#rewrite-evaluation)** --\n learn about the detection validity and rewrite quality judges in detail.\n- **[🔍 Inspecting Detected Entities](../02_inspecting_detected_entities/)** --\n debug what the detection pipeline found before rewriting.\n- **Try it on your own data!** Swap in your CSV, define entity labels for your\n domain, and set a `PrivacyGoal` that fits -- you've got all the building blocks."
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": ".venv",
- "language": "python",
- "name": "python3"
+ ],
+ "metadata": {
+ "jupytext": {
+ "cell_metadata_filter": "-all"
+ },
+ "kernelspec": {
+ "display_name": ".venv",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.9"
+ }
},
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
\ No newline at end of file
+ "nbformat": 4,
+ "nbformat_minor": 5
+}