Agent Skillsmaziyarpanahi/openmed › pick-a-pii-model

pick-a-pii-model

GitHub

根据语言、运行时格式和设备预算,从本地注册表中筛选并选择最适合的端侧 PII 检测模型,强调部署前必须进行召回率验证,确保数据安全。

skills/pick-a-pii-model/SKILL.md maziyarpanahi/openmed

Trigger Scenarios

需要选择本地 PII 检测模型时 进行模型导出或量化前的验证

Install

npx skills add maziyarpanahi/openmed --skill pick-a-pii-model -g -y
More Options

Use without installing

npx skills use maziyarpanahi/openmed@pick-a-pii-model

指定 Agent (Claude Code)

npx skills add maziyarpanahi/openmed --skill pick-a-pii-model -a claude-code -g -y

安装 repo 全部 skill

npx skills add maziyarpanahi/openmed --all -g -y

预览 repo 内 skill

npx skills add maziyarpanahi/openmed --list

SKILL.md

Frontmatter
{
    "name": "pick-a-pii-model",
    "description": "Select an on-device OpenMed PII model from the committed registry by language, runtime format, and size budget, then require recall validation before deployment. Use when an agent must choose a local PII detector for CPU, Apple Silicon, or a mobile export without relying on live model discovery."
}

Pick an on-device PII model

Use the committed registry to build an offline shortlist. Treat the language default as the safety baseline, but never treat model size or format as proof of recall.

Procedure

  1. Identify the input language and script before choosing a model.
  2. Choose the runtime: pytorch for local CPU/GPU and mobile export sources, mlx-fp or mlx-8bit for Apple Silicon.
  3. Read get_default_pii_model(language) as the baseline.
  4. Filter get_pii_models_by_language(language) by runtime and device budget.
  5. Prefer the baseline when it fits; otherwise select a compatible candidate.
  6. Benchmark the candidate on direct identifiers, critical leakage, scripts, and the target quantization before shipping.

Runnable offline shortlist

This snippet reads only the bundled manifest; it does not download weights.

from openmed import get_default_pii_model, get_pii_models_by_language

LANGUAGE = "en"
TARGET_FORMAT = "mlx-fp"  # Use "pytorch" for CPU or as an export source.
MAX_PARAMETERS_M = 150

baseline_id = get_default_pii_model(LANGUAGE)
models = get_pii_models_by_language(LANGUAGE)

shortlist = [
    (key, info)
    for key, info in models.items()
    if TARGET_FORMAT in info.formats
    and info.size_mb is not None
    and info.size_mb <= MAX_PARAMETERS_M
]
shortlist.sort(
    key=lambda item: (
        item[1].model_id != baseline_id,
        item[1].size_mb,
        item[0],
    )
)

if not shortlist:
    raise RuntimeError("No compatible PII model fits the requested budget")

registry_key, selected = shortlist[0]
print(
    {
        "registry_key": registry_key,
        "model_id": selected.model_id,
        "format": TARGET_FORMAT,
        "parameters_m": selected.size_mb,
        "recommended_confidence": selected.recommended_confidence,
        "is_language_default": selected.model_id == baseline_id,
    }
)
print("Benchmark this candidate against the language default before release.")

For Android, Core ML, ONNX, or browser deployment, select a compatible pytorch source and use the target export workflow. Re-run PII recall after conversion or quantization.

Selection rules

  • Reject an unsupported language instead of silently falling back to English.
  • Prefer audited script coverage over a model's name or marketing description.
  • Treat parameter count as a rough capacity signal, not download size, latency, peak memory, or quality.
  • Measure latency and peak memory on the real target device.
  • Fail closed when conversion or quantization drops direct-identifier recall or introduces residual critical leakage.
  • Cache approved weights locally and set offline mode for steady-state use.

Repository example

Read the PII model comparison example for registry inspection and model-by-model inference.

Version History

  • ab3d454 Current 2026-07-31 07:37

Same Skill Collection

skills/benchmark-pii-recall/SKILL.md
skills/building-with-openmed/SKILL.md
skills/deidentify-a-dataset/SKILL.md
skills/extract-clinical-entities-to-fhir/SKILL.md
skills/loading-openmed-models/SKILL.md
skills/annotating-variants/SKILL.md
skills/assembling-fhir-bundles/SKILL.md
skills/auditing-deid-leakage/SKILL.md
skills/auditing-deidentification-runs/SKILL.md
skills/auditing-part11-trails/SKILL.md
skills/auditing-safe-harbor-checklist/SKILL.md
skills/auditing-subgroup-fairness/SKILL.md
skills/authoring-model-cards/SKILL.md
skills/batch-processing-clinical-text/SKILL.md
skills/benchmarking-clinical-ner/SKILL.md
skills/bridging-presidio-and-spacy/SKILL.md
skills/building-gold-corpus/SKILL.md
skills/building-patient-timelines/SKILL.md
skills/checking-hipaa-compliance/SKILL.md
skills/choosing-openmed-models/SKILL.md
skills/coding-hcc-risk-adjustment/SKILL.md
skills/coding-icd10/SKILL.md
skills/computing-ecqms/SKILL.md
skills/configuring-privacy-policies/SKILL.md
skills/defining-cohort-phenotypes/SKILL.md
skills/deidentifying-clinical-text/SKILL.md
skills/deidentifying-multilingual-text/SKILL.md
skills/deploying-openmed-mcp/SKILL.md
skills/detecting-pv-signals/SKILL.md
skills/enforcing-nophi-logging/SKILL.md
skills/etl-to-omop-cdm/SKILL.md
skills/evaluating-with-leakage-gates/SKILL.md
skills/exporting-bulk-fhir/SKILL.md
skills/exporting-to-fhir/SKILL.md
skills/extracting-clinical-entities/SKILL.md
skills/extracting-dicom-metadata/SKILL.md
skills/extracting-lab-tables/SKILL.md
skills/extracting-pii-entities/SKILL.md
skills/extracting-sdoh/SKILL.md
skills/fetching-fhir-resources/SKILL.md
skills/gating-deid-leakage/SKILL.md
skills/generating-synthea-data/SKILL.md
skills/generating-synthetic-surrogates/SKILL.md
skills/ingesting-clinical-documents/SKILL.md
skills/linking-umls-concepts/SKILL.md
skills/mapping-loinc/SKILL.md
skills/mapping-to-snomed/SKILL.md
skills/mining-pubmed-literature/SKILL.md
skills/normalizing-rxnorm/SKILL.md

Metadata

Files
0
Version
de90aba
Hash
4e75f454
Indexed
2026-07-31 07:37

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-03 15:13
浙ICP备14020137号-1 $Map of visitor$