Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

docs(examples): replay the recorded Comprehend redaction arm (#484)

svonavab6a0ed7a8573
diff --git a/examples/redact/README.md b/examples/redact/README.md
index ae6cb7f14..493791ab2 100644
--- a/examples/redact/README.md
+++ b/examples/redact/README.md
@@ -8,7 +8,7 @@ that page's [SOURCES.md](https://superlinked.com/reference/redact/SOURCES.md).
The study asks one question of each redaction option: how much of the personal
data in a document does it leave readable? It sends 660 synthetic financial
-documents through five arms and counts, for each, the in-scope personal-data
+documents through six arms and counts, for each, the in-scope personal-data
spans it masks completely. The metric was fixed before the first request on
30 September 2026.
@@ -42,18 +42,19 @@ spans it masks completely. The metric was fixed before the first request on
## Results
-| Arm | Masked (of 1,792) | Coverage recall | 95% interval | States and countries excused | $ a month, 1M documents |
-| --- | --- | --- | --- | --- | --- |
-| SIE, two models composed | 1,591 | 88.8% | 86.7% to 90.9% | 90.5% | $32 |
-| Claude Haiku 4.5 | 1,490 | 83.1% | 80.8% to 85.2% | 92.6% | $725 |
-| GPT-6 Luna | 1,448 | 80.8% | 78.2% to 83.1% | 93.2% | $57 |
-| OpenAI Privacy Filter | 1,214 | 67.7% | 64.3% to 71.0% | 69.8% | $23 (self-hosted, L4) |
-| Microsoft Presidio | 859 | 47.9% | 45.0% to 50.8% | 49.6% | $3 (self-hosted, CPU) |
-| AWS Comprehend | not measured | | | | $351 |
-
-SIE minus each arm, paired: Presidio +37.5 to +44.3 points, Privacy Filter
-+17.8 to +24.5, Claude Haiku 4.5 +2.8 to +8.6, GPT-6 Luna +5.3 to +11.0. With
-states and countries excused SIE stays well ahead of Presidio (+37.6 to +44.3)
+| Arm | Masked (of 1,792) | Coverage recall | 95% interval | States and countries excused | $ a month, 1M documents, real-time | LLM Batch API |
+| --- | --- | --- | --- | --- | --- | --- |
+| SIE, two models composed | 1,591 | 88.8% | 86.7% to 90.9% | 90.5% | $32 | |
+| Claude Haiku 4.5 | 1,490 | 83.1% | 80.8% to 85.2% | 92.6% | $1,450 | $725 |
+| GPT-6 Luna | 1,448 | 80.8% | 78.2% to 83.1% | 93.2% | $113 | $57 |
+| OpenAI Privacy Filter | 1,214 | 67.7% | 64.3% to 71.0% | 69.8% | $23 (self-hosted, L4) | |
+| Microsoft Presidio | 859 | 47.9% | 45.0% to 50.8% | 49.6% | $3 (self-hosted, CPU) | |
+| AWS Comprehend | 1,491 | 83.2% | 80.3% to 85.8% | 84.2% | $351 lower bound | |
+
+SIE minus each arm, paired: AWS Comprehend +2.7 to +8.6 points, Presidio
++37.5 to +44.3 points, Privacy Filter +17.8 to +24.5, Claude Haiku 4.5 +2.8 to +8.6, GPT-6 Luna +5.3 to +11.0. With
+states and countries excused SIE stays ahead of Comprehend (+3.5 to +9.3),
+well ahead of Presidio (+37.6 to +44.3)
and Privacy Filter (+17.4 to +24.1), is level with Claude Haiku 4.5 (-4.5 to
+0.3) and behind GPT-6 Luna (-4.9 to -0.4). SIE's lead over the two LLM prompts
on the first figure is addresses whose state they left readable; the label list
@@ -61,14 +62,17 @@ has no `state`. So this study makes no detection claim against an LLM prompt.
It does say what they cost, and that redacting with an LLM API sends the
unredacted text to that API.
-**AWS Comprehend, Azure AI Language and Google Cloud DLP were not measured.**
-The study had no access to them. Comprehend documents an entity type for 96.2%
-of the in-scope spans here (all but coordinates, employee IDs and customer
-IDs), so nothing here places it above or below SIE. Its row is price only.
+**AWS Comprehend was measured on the same 660 documents.** Its arm was
+registered before any Comprehend request, with a quality-claim rule requiring
+SIE's paired 95% lower bound to exceed zero on both coverage measures. Both
+bounds are positive. This establishes the recorded comparison on this
+synthetic financial set; it does not establish performance on other documents.
+Azure AI Language, Google Cloud DLP and Bedrock Guardrails were not measured.
Overlap precision is low for every arm (0.35 to 0.60) because Gretel annotates
a subset of each document's personal data: a mask on an unannotated name or
-email counts against it.
+email counts against it. SIE also propagates erroneous person labels such as
+`Insured`, removing useful text. Validate unnecessary masks as well as misses.
## The arms
@@ -76,6 +80,7 @@ email counts against it.
| --- | --- |
| SIE | `urchade/gliner_multi_pii-v1` and `numind/NuNER_Zero` on `https://api.superlinked.com`, the same 36 labels, each span kept at score 0.6 or above, the two unioned. Then every other whole-word, case-sensitive mention of a three-letter or longer token from a returned `person` span is masked, in the caller's code. A document over 300 words is sent as 300-word windows with a 50-word overlap, each window's offset added back to its spans. |
| OpenAI Privacy Filter | the `opf` package from [openai/privacy-filter](https://github.com/openai/privacy-filter) at `f7f00ca`, default checkpoint and decoding, every span masked, on one NVIDIA L4 |
+| AWS Comprehend | `DetectPiiEntities`, `LanguageCode="en"`, region `us-east-1`, one request per document, every returned entity masked regardless of type or score |
| Microsoft Presidio | `presidio-analyzer` 2.2.364 `AnalyzerEngine()` defaults with spaCy `en_core_web_lg` 3.8.0, every entity masked |
| GPT-6 Luna | `reasoning_effort: "none"`, `temperature: 0`, strict JSON schema, the 36 labels in the prompt |
| Claude Haiku 4.5 | no extended thinking, `temperature: 0`, JSON schema, the same prompt |
@@ -99,18 +104,23 @@ Zero 62.7%.
### Price inputs
For 1,000,000 documents a month like these, list prices read on 30 September
-2026. `score.py` holds each input as a named constant.
+2026; SIE rates match the [published prices](https://superlinked.com/pricing)
+on 1 October 2026. `score.py` holds each input as a named constant.
- **SIE:** $0.04 per million input tokens for GLiNER PII and $0.05 for NuNER
Zero, on the 238,605 and 227,727 tokens their tokenizers count in the 660
documents.
- **AWS Comprehend `DetectPiiEntities`:** $0.000025 per 100-character unit,
its cheapest tier, 3-unit minimum per request, units counted as characters
- over 100 with no rounding up.
+ over 100 with no rounding up. This deliberately understates the cost: AWS
+ rounds units up (550 characters bills six units). The table shows a lower
+ bound, not an expected bill; this monthly workload does not reach the
+ cheapest tier.
- **LLMs:** the tokens each provider reported for the run, at each vendor's
Batch API price, their cheapest: $0.05 and $0.25 (GPT-6 Luna) and $0.50 and
$2.50 (Claude Haiku 4.5) per million input and output tokens. At standard
- prices they cost twice that: $113 and $1,450.
+ prices they cost twice that: $113 and $1,450. The page compares real-time
+ request-path prices; the discounted Batch API column is for work that can wait.
- **Presidio and Privacy Filter** are free to download, so their price is the
compute: Modal list price per second (L4 $0.000222, a core $0.0000131, a GiB
$0.00000222), divided by 75% utilisation and times 1.75 for region, at the
@@ -158,6 +168,7 @@ Claude Haiku 4.5 1,490 of 1,792 83.1% 9
GPT-6 Luna 1,448 of 1,792 80.8% 93.2% 0.590 0.474
OpenAI Privacy Filter 1,214 of 1,792 67.7% 69.8% 0.590 0.504
Microsoft Presidio 859 of 1,792 47.9% 49.6% 0.346 0.167
+AWS Comprehend 1,491 of 1,792 83.2% 84.2% 0.400 0.413
...
Every figure matches the recorded results and the published page.
```
@@ -181,7 +192,7 @@ it left readable, and whether its spans match the recording.
- **Nothing about your documents.** Gretel's documents are synthetic and
financial. Measure on your own data before relying on any of these figures.
-- **Nothing about AWS Comprehend, Azure or Google Cloud DLP.** They were not
+- **Nothing about Azure, Google Cloud DLP or Bedrock Guardrails.** They were not
run.
- **No lead over an LLM prompt.** It depends on whether a readable state counts
as a leak.
diff --git a/examples/redact/fetch.py b/examples/redact/fetch.py
index 142df453f..2cd7e84de 100755
--- a/examples/redact/fetch.py
+++ b/examples/redact/fetch.py
@@ -34,9 +34,9 @@ HERE = Path(__file__).resolve().parent
EVIDENCE = HERE / "evidence"
DATASET = "superlinked/sie-task-evidence"
-REVISION = "4999a499aed5ea77181973070fa435a616552d80"
+REVISION = "31383ae9986d9dc9edd4e3a06ee9fb40b223d6fb"
TASK = "redact"
-MANIFEST_SHA256 = "a3a7b8b6c73f20e4bcf99b5adec37ada0ff67f7a57d8b91cf8fac9e0406a6961"
+MANIFEST_SHA256 = "8170519b9ad94c35dd53f2d22d96689d41e9c0e26d9c0fc25bba83230cbee4dc"
API = f"https://huggingface.co/api/datasets/{DATASET}/tree/{REVISION}"
FILES = f"https://huggingface.co/datasets/{DATASET}/resolve/{REVISION}"
@@ -50,6 +50,7 @@ REQUIRED = (
"rows/sie__numind__NuNER_Zero.jsonl",
"rows/presidio.jsonl",
"rows/privacy-filter.jsonl",
+ "rows/comprehend.jsonl",
"rows/llm__gpt-6-luna.jsonl",
"rows/llm__claude-haiku-4-5.jsonl",
"results/gretel-main_results.json",
diff --git a/examples/redact/score.py b/examples/redact/score.py
index 35cc103ea..1963be51f 100755
--- a/examples/redact/score.py
+++ b/examples/redact/score.py
@@ -10,7 +10,7 @@ Standard library only. No API key, no network, no inference spend.
The run: 660 documents from the English test split of
gretelai/synthetic_pii_finance_multilingual, 1,792 in-scope personal-data
-spans, five arms. The figure is coverage recall: the share of in-scope gold
+spans, six arms. The figure is coverage recall: the share of in-scope gold
spans whose every non-space character sits under the union of an arm's masks,
whatever label the arm gave it.
@@ -102,6 +102,7 @@ ARMS = [
("llm:gpt-6-luna", "GPT-6 Luna", "llm__gpt-6-luna.jsonl"),
("privacy-filter", "OpenAI Privacy Filter", "privacy-filter.jsonl"),
("presidio", "Microsoft Presidio", "presidio.jsonl"),
+ ("comprehend", "AWS Comprehend", "comprehend.jsonl"),
(f"sie:{FIRST_MODEL}", "SIE GLiNER PII alone, one request", "sie__urchade__gliner_multi_pii-v1.jsonl"),
(f"sie:{SECOND_MODEL}", "SIE NuNER Zero alone, one request", "sie__numind__NuNER_Zero.jsonl"),
]
@@ -114,6 +115,7 @@ PUBLISHED_MASKED = {
"llm:gpt-6-luna": 1448,
"privacy-filter": 1214,
"presidio": 859,
+ "comprehend": 1491,
}
PUBLISHED_GOLD = 1792
PUBLISHED_DOCUMENTS = 660
@@ -124,7 +126,8 @@ MONTHLY_DOCUMENTS = 1_000_000
SIE_PRICE_PER_1M_TOKENS = {FIRST_MODEL: 0.04, SECOND_MODEL: 0.05}
SIE_TOKENS = {FIRST_MODEL: 238_605, SECOND_MODEL: 227_727}
# AWS Comprehend DetectPiiEntities: cheapest tier, per 100-character unit, 3-unit minimum per request,
-# units counted as characters over 100 with no rounding up.
+# units counted as characters over 100 with no rounding up: a conservative lower bound,
+# not the expected bill. AWS rounds units up (550 characters bills six units).
COMPREHEND_PER_UNIT = 0.000025
COMPREHEND_MIN_UNITS = 3
COMPREHEND_CHARS_PER_UNIT = 100
@@ -144,7 +147,7 @@ CONTAINERS = {
"presidio": {"gpus": 0, "cores": 8, "gib": 16},
"privacy-filter": {"gpus": 1, "cores": 8, "gib": 32},
}
-COMPREHEND = "aws-comprehend"
+COMPREHEND = "comprehend"
PUBLISHED_MONTHLY_USD = {
COMPOSITION: 32,
"presidio": 3,
@@ -153,6 +156,10 @@ PUBLISHED_MONTHLY_USD = {
"llm:claude-haiku-4-5": 725,
COMPREHEND: 351,
}
+PUBLISHED_REALTIME_MONTHLY_USD = {
+ "llm:gpt-6-luna": 113,
+ "llm:claude-haiku-4-5": 1450,
+}
# --- the composition -----------------------------------------------------------------------------------------------
@@ -426,7 +433,10 @@ def load_documents(evidence: Path) -> list[dict[str, Any]]:
def load_rows(path: Path, documents: list[dict[str, Any]]) -> dict[int, dict[str, Any]]:
- rows = {r["index"]: r for r in read_jsonl(path)}
+ records = read_jsonl(path)
+ rows = {r["index"]: r for r in records}
+ if len(rows) != len(records):
+ raise SystemExit(f"{path}: duplicate document indices")
if set(rows) != {d["index"] for d in documents}:
raise SystemExit(f"{path}: rows do not match the {len(documents)} documents")
return rows
@@ -537,7 +547,9 @@ def main() -> int:
)
scoped = [g for d in documents for g in d["scoped"]]
bound = sum(g["label"] not in NO_COMPREHEND_TYPE for g in scoped) / len(scoped)
- print(f"In-scope spans with a documented AWS Comprehend type: {pct(bound)} (Comprehend was not measured)")
+ print(
+ f"In-scope spans with a documented AWS Comprehend type: {pct(bound)} (Comprehend also measured on the same documents)"
+ )
check.equal(
"Comprehend documented-type bound", round(bound, 12), round(recorded["comprehend_documented_type_bound"], 12)
)
@@ -565,12 +577,22 @@ def main() -> int:
check.equal(f"{model} tokens (e2)", e2["sie_tokens"][model], count)
usd = monthly_usd(documents, rows, e2)
print()
- print(f"$ a month for {MONTHLY_DOCUMENTS:,} documents like these:")
+ print(f"$ a month for {MONTHLY_DOCUMENTS:,} documents like these (LLM Batch API; real-time separately):")
+ at_list = monthly_usd(documents, rows, e2, LLM_LIST_PRICES)
names = {arm: name for arm, name, _ in ARMS} | {COMPOSITION: "SIE", COMPREHEND: "AWS Comprehend"}
for arm in (COMPOSITION, "presidio", "privacy-filter", "llm:gpt-6-luna", "llm:claude-haiku-4-5", COMPREHEND):
masked = pct(summary[arm]["coverage_recall"]) if arm in summary else "not measured"
- print(f" {names[arm]:<24} ${usd[arm]:>9,.2f} (${round(usd[arm]):,}) masked {masked}")
+ extra = f"; real-time ${at_list[arm]:,.2f}" if arm in LLM_LIST_PRICES else ""
+ if arm == COMPREHEND:
+ extra += "; conservative lower bound, cheapest tier before unit rounding"
+ print(f" {names[arm]:<24} ${usd[arm]:>9,.2f} (${round(usd[arm]):,}) masked {masked}{extra}")
check.equal(f"{arm} $ a month (published)", round(usd[arm]), PUBLISHED_MONTHLY_USD[arm])
+ if arm in LLM_LIST_PRICES:
+ check.equal(
+ f"{arm} $ a month (published real-time)",
+ round(at_list[arm]),
+ PUBLISHED_REALTIME_MONTHLY_USD[arm],
+ )
priced = e2["usd_per_1m_documents"]
recorded_usd = {
COMPOSITION: next(v for k, v in priced.items() if k.startswith("sie-composition (")),
@@ -580,8 +602,8 @@ def main() -> int:
"presidio": e2["self_host"]["presidio"]["usd_per_1m_documents"],
"privacy-filter": e2["self_host"]["privacy-filter"]["usd_per_1m_documents"],
}
- # The recording costs the LLMs at standard prices; the page and the table above use batch.
- at_list = monthly_usd(documents, rows, e2, LLM_LIST_PRICES)
+ # The recording and page cost the LLMs at standard prices; discounted Batch
+ # prices are printed separately, never substituted for the request-path comparison.
for arm, value in recorded_usd.items():
got = at_list[arm] if arm in LLM_LIST_PRICES else usd[arm]
check.equal(f"{arm} $ per 1M documents (recorded)", round(got, 6), round(value, 6))