-
Notifications
You must be signed in to change notification settings - Fork 14
docs: update notebooks for release #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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] | ||
| # <!-- | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # --> | ||
| # # 🕵️ 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: | ||
|
binaryaaron marked this conversation as resolved.
|
||
| # | ||
| # 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. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
“Exceed” is accurate for leakage, but utility triggers review when it falls below its threshold. Could we say: “Records that cross the configured leakage or utility thresholds are flagged for manual review.” The same wording appears in notebook 05. |
||
| # - `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. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
“Their” has no clear plural antecedent here. I suggest: “The holistic privacy rubric and pipeline leakage metric are independent, so they may disagree.” The same sentence appears in notebook 05. |
||
| # See [Evaluation](../../concepts/evaluation/#rewrite-evaluation) for details. | ||
|
|
||
| # %% | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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] | ||
| # <!-- | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # --> | ||
| # # 🕵️ 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. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is not always true. Suggested wording: “The repair loop stops after |
||
| # - 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. | ||
|
|
||
| # %% | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.