building-gold-corpus
它能做什么
这项技能用于搭建金标准标注项目,即一组用于衡量模型的人工标注测试样例。内容包括标签、标注指南、标注工具设置,以及彼此独立的训练集、开发集和测试集。适合需要科学衡量模型的团队。
适用场景
- ✓当你需要测试样例来衡量临床 NER 或去标识化模型的时候。
- ✓当你开始一项标注工作,需要标签集和标注指南的时候。
- ✓当你希望有一个可以提交并在 CI 中检查的小型合成测试集的时候。
技能链接
https://github.com/maziyarpanahi/openmed/blob/master/skills/building-gold-corpus/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我搭建一个标注项目,包括标签集、标注指南和测试集划分,用来衡量我们的去标识化模型。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会定义标签结构和指南,配置标注工具格式,并创建彼此没有重叠的训练集、开发集和测试集。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Building a Gold Corpus
You can't evaluate what you can't measure against. This skill scaffolds a gold-standard annotation project whose output drops straight into the OpenMed eval harness as fixtures. The hard rule: anything committed to the repo is synthetic. Licensed clinical corpora (i2b2, n2c2, MIMIC) are DUA-gated — use them at eval time from the user's own copy, never check them in.
When to use this skill
- You need eval fixtures for
benchmarking-clinical-nerorevaluating-with-leakage-gatesand have none. - You're standing up an annotation effort: schema, guidelines, tool config.
- You need disciplined train/dev/test splits with no leakage between them.
- You want a small synthetic golden set you can commit and gate on in CI.
The OpenMed fixture shape (your target output)
Annotations must serialize to character-offset spans the harness understands:
{
"fixtures": [
{
"id": "synthetic-0001",
"language": "en",
"text": "Ms. Jane Roe (MRN 0000000) seen 2099-01-02 for type 2 diabetes.",
"gold_spans": [
{"start": 4, "end": 12, "label": "PERSON"},
{"start": 18, "end": 25, "label": "ID_NUM"},
{"start": 32, "end": 42, "label": "DATE"},
{"start": 47, "end": 62, "label": "DISEASE"}
]
}
]
}
openmed.eval.harness.load_fixtures accepts a top-level list or a {"fixtures": [...]} mapping. Offsets are character indices into text; labels are
OpenMed-canonical.
Quick start — scaffold the project
eval/
gold/
guidelines.md # annotation manual + edge-case decisions
label_schema.json # canonical labels + definitions + examples
synthetic/ # COMMITTED synthetic fixtures (CI-gateable)
train.json
dev.json
test.json
external/ # GITIGNORED: licensed DUA corpora, eval-only
.gitignore # * (never commit i2b2/n2c2/MIMIC)
Verify your synthetic fixtures load and validate spans before you trust them:
from openmed.eval.harness import load_fixtures
fixtures = load_fixtures("eval/gold/synthetic/test.json")
print(len(fixtures), "fixtures;", sum(len(f.gold_spans) for f in fixtures), "spans")
# load_fixtures normalizes spans against source text and rejects duplicate ids.
Workflow
- Define the label schema. Reuse OpenMed canonical labels (PERSON, DATE, ID_NUM, EMAIL, PHONE, DISEASE, DRUG, ...). Each label gets a one-line definition, in/out examples, and a boundary rule (include titles? trailing punctuation?).
- Write annotation guidelines. The manual is the contract: span boundaries, nested/overlapping policy, ambiguous cases, and a decision log appended as real cases force calls. Vague guidelines → low agreement → unusable gold.
- Generate synthetic source text. Compose realistic clinical narratives with fabricated identifiers (Faker-style names, impossible dates like 2099-, all-zero MRNs). Never paste real notes into committed data.
- Configure the tool. BRAT uses
annotation.conf(entity types) producing.annstandoff; Label Studio uses a labeling-config XML producing JSON. Map either back to the fixture shape above. - Double-annotate and measure agreement. Have ≥2 annotators on an overlap set; compute span-level inter-annotator agreement (F1 or Cohen's κ). Adjudicate disagreements and fold the resolutions into the decision log.
- Split with discipline. Partition by document/patient, not by sentence, so no patient appears in two splits. Freeze test; never tune on it.
- Validate and commit. Run
load_fixtures; confirm spans align and ids are unique. Commit only the synthetic splits.
Hand-off to / from OpenMed
- To
benchmarking-clinical-ner: dev/test fixtures feedrun_suiteanderror_reportfor the NER scorecard. - To
evaluating-with-leakage-gatesandgating-deid-leakage: the synthetic held-out set is exactly what the release gates and the CI gate run against. - To
building-with-openmed: synthetic notes can be generated by running surrogate replacement throughopenmed.deidentify(method="replace"). - Pairs with
auditing-subgroup-fairness: tag each gold span with agroupinmetadatasofairness_reportcan slice by demographic surrogate.
Edge cases & gotchas
- Committed = synthetic. No exceptions. Real PHI in the repo is a breach even if the repo is private. G
常见问题
我可以提交真实的患者记录吗?
不可以。这项技能会确保提交到代码仓库的内容都是合成数据,授权的临床语料库只能从你自己的副本中使用。
标注使用什么格式?
标注以字符偏移片段的形式保存,评估工具可以读取。
为什么要把数据集分开?
分开的数据集可以防止训练和测试之间的数据泄露,让评分保持客观。
详情
作者的原始描述
Scaffold a synthetic gold-standard annotation project for evaluating OpenMed NER and de-identification models — label schema, annotation guidelines, BRAT or Label Studio config, and disjoint train/dev/test splits. Use when the user wants to create eval fixtures, set up annotation, define a label set, write guidelines, configure an annotation tool, or build a held-out gold set for the OpenMed eval harness. Trigger on \"gold corpus\", \"annotation project\", \"label schema\", \"annotation guidelines\", \"BRAT\", \"Label Studio\", \"train dev test split\", or \"build eval fixtures\" for OpenMed.
repo: maziyarpanahi/openmed
热度
- GitHub 星标
- 5.8k
- 排名
- #14678
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
annotating-variants
5.8k帮你的智能体预测基因变异的作用,把 HGVS 名称转换为基因组位置,并使用免费的公共注释工具添加人群频率。
ask-openmed
5.8k帮你的智能体为临床文本请求选择合适的 OpenMed 工作流程,并在可能涉及患者数据时,先进行隐私检查。
assembling-fhir-bundles
5.8k把多份 FHIR 健康记录打包成一个事务 Bundle,可直接发送给 EHR 系统,并正确链接其中的内部引用。
auditing-deid-leakage
5.8k扫描已去标识化的临床文本,查找残留的标识符,例如社会安全号、银行卡号、电子邮件地址和日期,若仍有残留则阻止发布。