Evaluating With Leakage Gates 标志

Evaluating With Leakage Gates

社区热门
maziyarpanahi
evaluating-with-leakage-gates

根据 G1a 至 G8 的泄漏优先发布门槛,评估 OpenMed 去标识化模型或临床 NER 模型。这些门槛依据残留 PHI 泄漏情况而非 F1 决定是否发布。当用户想要在合成黄金测试集上运行 OpenMed 评估工具、判断去标识化模型是否可发布(RELEASABLE)或应隔离(QUARANTINED)、执行直接标识符召回率下限、要求关键泄漏为零、拟合校准阈值,或生成带签名的门槛报告时使用。在 OpenMed 去标识化场景中,用户提到“发布门槛”“泄漏”“这个模型可以安全上线吗”“G1a”“G3”“隔离”“召回率下限”或“校准阈值”时触发。

Add to TypingMind

概览

发布者maziyarpanahi
代码仓库openmed
技能名称evaluating-with-leakage-gates
星标数
5.3K
复刻数
677
附带文件
仅含指令
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 maziyarpanahi 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Evaluating With Leakage Gates AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/maziyarpanahi/openmed/tree/master/skills/evaluating-with-leakage-gates
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/maziyarpanahi/openmed.git /tmp/openmed
mkdir -p .claude/skills
cp -r /tmp/openmed/skills/evaluating-with-leakage-gates .claude/skills/evaluating-with-leakage-gates
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Evaluating With Leakage Gates,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Evaluating With Leakage Gates。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Evaluating With Leakage Gates 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Evaluating with Leakage Gates

OpenMed's release gates answer one question: did any PHI leak? A de-id model with a beautiful F1 can still leak a single SSN — and that one leak is a HIPAA breach. So openmed.eval gates on residual leakage and per-label recall floors, not on aggregate F1. The candidate is either RELEASABLE or QUARANTINED; there is no partial credit.

When to use this skill

  • You have a candidate de-id or PII model and need a ship / no-ship decision.
  • You want to run the benchmark harness over a synthetic golden suite.
  • You need to enforce direct-identifier recall floors and critical_leakage == 0.
  • You need calibration thresholds (thresholds.json) before the gate will pass.
  • You want a signed, reproducible gate report for governance.

This is the flagship eval skill. For a pure NER scorecard see benchmarking-clinical-ner; for CI wiring see gating-deid-leakage.

The gates (G1a–G8)

GateChecksFloor / rule
G1aDirect & quasi identifiers (PERSON, EMAIL, PHONE, SSN, ID_NUM, DATE_OF_BIRTH, ...)recall ≥ 0.990 (v1.6) / 0.995 (v2.0); strict-no-leak policies raise the floor
G1bStructured secrets (API_KEY, ACCOUNT_NUMBER, CREDIT_CARD, IBAN)recall ≥ 0.995
G2Free-text names/locations/datesrecall ≥ 0.980 (v1.6) / 0.990 (v2.0)
G3Critical leakage (SSN, CREDIT_CARD, CVV, API_KEY, PIN, IBAN, ...)count must be exactly 0
G4Quantized recall delta vs fp parentwithin INT8 / INT4 limits
G5Latency & RAM vs device tier budgetp50/p95/RAM under tier budget
G6p50/p95 latency documentedmust be present and finite
G7Baseline regressionrecall drop ≤ 0.002/label; leakage ≤ soft ceiling 0.005 and ≤ steward target; no leakage regression vs last-green
G8Span integritypredicted spans validate (no overlaps/out-of-range)

Constants live in openmed.eval.release_gates (G1A_V16_RECALL_FLOOR, G1B_RECALL_FLOOR, G7_RECALL_DROP_LIMIT, RESIDUAL_LEAKAGE_SOFT_CEILING, ...). Confirm them there rather than hardcoding — they move per milestone.

Quick start

Run a candidate benchmark over a synthetic golden suite, then gate it:

python
from openmed.eval import run_suite, ReleaseGate, RELEASABLE

# 1) Produce a candidate BenchmarkReport from a SYNTHETIC fixtures file.
#    Each fixture carries gold PHI spans; no real patient text is committed.
report = run_suite(
    "eval/golden/phi_synthetic.json",     # user-supplied synthetic fixtures
    suite="golden",
    model_name="OpenMed/Privacy-PII-Detection",
    device="cpu",
    metadata={
        "family": "PII",
        "tier": "base",
        "policy": "hipaa_safe_harbor",
        # calibration artifacts are required for mask/replace policies (see below)
        "thresholds_path": "eval/artifacts/thresholds.json",
        "calibration_report_path": "eval/artifacts/calibration_report.json",
    },
)

# 2) Gate it. The gate reads the last-green baseline store read-only and
#    returns a signed GateReport.
gate = ReleaseGate(milestone="v1.6", policy="hipaa_safe_harbor")
decision = gate.evaluate(report)

print(decision.decision)                  # "RELEASABLE" or "QUARANTINED"
for check in decision.gate_results:
    if not check.passed:
        print(check.gate, "->", check.reason, check.details)

assert decision.decision == RELEASABLE, "do not ship a quarantined model"

CLI equivalent (fails closed, exit code 1 on quarantine):

bash
python -m openmed.eval.release_gates \
  --candidate eval/out/candidate_report.json \
  --milestone v1.6 --policy hipaa_safe_harbor \
  --output release-gate-report.json

Workflow

  1. Build a synthetic golden suite. Fixtures are JSON with text and gold_spans (offsets + labels). Use building-gold-corpus to scaffold one. Committed gold must be synthetic; DUA corpora (i2b2/n2c2) are eval-only and never committed.

  2. Fit calibration thresholds for any policy that masks or replaces:

    python
    from openmed.eval import write_calibration_artifacts
    
    paths = write_calibration_artifacts(
        calibration_samples,                 # held-out score/target samples
        artifact_dir="eval/artifacts",
        model_id="OpenMed/Privacy-PII-Detection",
        suite="golden",
        target_leakage=0.0,                   # leakage-first: drive leakage to 0
    )
    # writes thresholds.json + calibration_report.json the gate looks for

    The gate's calibration_present check fails the build if these are missing for a mask/replace policy.

  3. Run the suite (run_suite / run_benchmark) to get a BenchmarkReport.

  4. Evaluate with ReleaseGate(...).evaluate(report).

  5. Read the per-gate results. Each GateCheck carries gate, passed, reason, and details (e.g. which labels fell below the recall floor).

  6. Fail closed. Treat anything other than RELEASABLE as a hard stop.

  7. Audit subgroups with fairness_report (see auditing-subgroup-fairness) so an aggregate pass doesn't hide an under-protected group.

Hand-off to / from OpenMed

  • From building-with-openmed and the de-id pipeline: you evaluate the model produced by openmed.deidentify / openmed.extract_pii.
  • To gating-deid-leakage: wrap ReleaseGate.evaluate(...) in a pytest/CLI gate so CI fails closed on regression.
  • To authoring-model-cards: feed GateReport, fairness_report, and error_report outputs into the model card's metrics and limitations sections.
  • Pairs with auditing-subgroup-fairness (fairness_report) and benchmarking-clinical-ner (error_report).

Edge cases & gotchas

  • F1 is not a gate. A model can have higher F1 and still be quarantined if it leaks one critical identifier (G3) or drops a label below its floor (G1a/G1b).
  • Calibration is mandatory for mask/replace policies. No thresholds.json → calibration_present fails → QUARANTINED.
  • Baselines are read, never written, by the gate. The gate compares against the last-green baseline store without mutating it (G7). Promote baselines in a separate, deliberate step.
  • Strict-no-leak policies raise the G1a floor and force the leakage target to 0. Don't assume the default floor.
  • Reports must carry identity metadata (family, tier, format, eval_set_hash, leakage_fixture_hash); manifest_coherence fails without it.
  • Reports are signed (HMAC-SHA256). Set OPENMED_RELEASE_GATE_KEY for a real signing key; GateReport.verify(key) checks the repro hash and signature.
  • No raw PHI in the report. Gate evidence is offsets, hashes, and labels — never plaintext identifiers. Keep it that way in any wrapper you write.

Standards & references

常见问题

Evaluating With Leakage Gates AI 技能有什么作用?

根据 G1a 至 G8 的泄漏优先发布门槛,评估 OpenMed 去标识化模型或临床 NER 模型。这些门槛依据残留 PHI 泄漏情况而非 F1 决定是否发布。当用户想要在合成黄金测试集上运行 OpenMed 评估工具、判断去标识化模型是否可发布(RELEASABLE)或应隔离(QUARANTINED)、执行直接标识符召回率下限、要求关键泄漏为零、拟合校准阈值,或生成带签名的门槛报告时使用。在 OpenMed 去标识化场景中,用户提到“发布门槛”“泄漏”“这个模型可以安全上线吗”“G1a”“G3”“隔离”“召回率下限”或“校准阈值”时触发。

为什么在 TypingMind 中使用 Evaluating With Leakage Gates?

因为您只需安装一次,就能搭配任何模型使用。Evaluating With Leakage Gates 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Evaluating With Leakage Gates?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/maziyarpanahi/openmed/tree/master/skills/evaluating-with-leakage-gates。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Evaluating With Leakage Gates?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Evaluating With Leakage Gates 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Evaluating With Leakage Gates 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Evaluating With Leakage Gates AI 技能免费吗?

是的。maziyarpanahi 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇