running-zeroshot-ner
Skill này làm gì
Skill này dạy agent cách tìm bất kỳ tập mục có tên nào trong văn bản mà không cần huấn luyện mô hình trước. Dành cho các bộ nhãn mà không mô hình y khoa có sẵn nào bao quát, như thiết bị hoặc implant.
Khi nào nên dùng
- ✓Khi người dùng cần tìm một danh sách thuật ngữ tùy chỉnh, như tên thiết bị, trong văn bản y khoa mà không có dữ liệu có nhãn.
- ✓Khi một dự án cần thử nhanh một bộ nhãn mới trước khi huấn luyện mô hình được tinh chỉnh.
- ✓Khi người dùng hỏi cách thiết lập GLiNER hoặc lệnh openmed zero để trích xuất.
Liên kết skill
https://github.com/maziyarpanahi/openmed/blob/master/skills/running-zeroshot-ner/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể tìm tất cả tên implant và thiết bị trong ghi chú phòng khám của tôi, dù không có mô hình nào được huấn luyện cho chúng không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent xây một chỉ mục cục bộ từ mô hình GLiNER rồi chạy nó với các nhãn người dùng nêu. Nhãn có thể thay đổi bất cứ lúc nào.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Running Zero-Shot NER
Zero-shot NER lets you extract entity types you name at inference time — no
training, no labelled data. OpenMed wraps GLiNER (v1) and GLiNER2 behind a small
index + inference layer, exposed via the openmed zero CLI and the openmed.ner
Python API. It runs on-device.
When to use
- Your label set is custom or evolving ("Device", "Implant", "Allergen") and no fine-tuned OpenMed model emits exactly those labels.
- You have no labelled data to fine-tune with.
- You need a quick prototype or a one-off extraction over an unusual schema.
When to prefer a fine-tuned model instead (extracting-clinical-entities):
for a fixed, well-supported schema (diseases, drugs, anatomy), a fine-tuned
OpenMed model is more accurate and faster than zero-shot. Zero-shot trades some
accuracy for total label flexibility — use it for coverage of new types, then
graduate to a fine-tuned model once the schema stabilises.
Install
pip install "openmed[gliner]" # GLiNER v1 span models
pip install "openmed[gliner2]" # GLiNER2.5 checkpoints via gliner2.AutoExtractor
openmed zero deps # diagnostic: prints "GLiNER v1: ok" / "GLiNER v2: ok"
openmed zero deps only checks availability — it does not install anything.
The two-step workflow: index, then infer
GLiNER checkpoints live as local model directories. OpenMed resolves them by a
short model_id via an index.json, so you build the index once and run inference
many times.
openmed zero index <models_dir>— scan a directory of downloaded GLiNER / GLiNER2 checkpoints and writeindex.json(model ids, family, domains, paths).openmed zero infer "<text>" --model-id <id>— run extraction against a model from the index, with labels you supply.
# 1) Build the index over your local models (writes <models_dir>/index.json)
openmed zero index /models/gliner --output /models/gliner/index.json
# 2) Run zero-shot NER with your OWN labels (comma-separated)
openmed zero infer "Patient on insulin glargine via an insulin pump for type 1 diabetes." \
--model-id gliner-biomedical \
--labels "Drug,Device,Disease" \
--threshold 0.5 \
--index-path /models/gliner/index.json
Output is JSON: each entity has text, start, end, label, and score.
CLI flags:
zero infer: positionaltext;--model-id/-m(required, an id from the index),--labels/-l(comma-separated custom labels),--domain/-d(label preset hint),--threshold/-c(default0.5),--index-path/-i.zero index: positionalmodels_dir;--output/-o,--pretty/--compact.
If you omit --labels, OpenMed falls back to the --domain defaults (or generic
defaults). Passing explicit --labels is what makes it truly zero-shot.
Python API
The same flow in code via openmed.ner:
from openmed.ner import infer, NerRequest
request = NerRequest(
model_id="gliner-biomedical", # id from your index.json
text="Started on insulin glargine via an insulin pump for type 1 diabetes.",
labels=["Drug", "Device", "Disease"], # your custom labels — no fine-tuning
threshold=0.5,
)
response = infer(request, index_path="/models/gliner/index.json")
for ent in response.entities:
print(f"{ent.label:8} {ent.text!r:30} {ent.score:.2f} [{ent.start}:{ent.end}]")
NerRequest fields: model_id, text, labels (None ⇒ domain/default labels),
domain, threshold. infer(...) returns a NerResponse whose .entities are
Entity objects with .text, .start, .end, .label, .score.
Build / load the index from Python too:
from openmed.ner import build_index, write_index, load_index, is_gliner_available
if is_gliner_available():
index = build_index("/models/gliner")
write_index(index, "/models/gliner/index.json")
index = load_index("/models/gliner/index.json")
Helpful label utilities:
from openmed.ner import get_default_labels, available_domains
available_domains() # domains with built-in label presets
get_default_labels("clinical") # default labels for a domain hint
Writing good labels
Zero-shot quality hinges on label phrasing. Prefer natural, specific noun phrases:
- Good:
["Drug", "Medical Device", "Disease", "Symptom", "Procedure"] - Weak:
["X", "thing", "misc"]
Tune threshold to trade recall for precision. Start at 0.5 and raise it if you
see spurious spans.
Hand-off to / from Ope
Câu hỏi thường gặp
Zero-shot có chính xác bằng mô hình đã huấn luyện không?
Skill nói nó đánh đổi một phần độ chính xác để lấy tính linh hoạt của nhãn, nên mô hình đã huấn luyện thường tốt hơn cho các loại phổ biến.
Các mô hình được cài đặt thế nào?
Skill nói hãy cài phần mở rộng gliner. Lệnh openmed zero deps chỉ kiểm tra những gì đã có sẵn.
Nó có cần ví dụ có nhãn không?
Không. Skill nói không cần huấn luyện hay dữ liệu có nhãn.
Chi tiết
Mô tả gốc của tác giả
Extract arbitrary, custom entity types from clinical or biomedical text with no fine-tuning using OpenMed's GLiNER / GLiNER2 zero-shot support. Use when the user wants to define their own labels on the fly (e.g. Drug, Symptom, Device, Procedure), has no labelled data or a label set not covered by a fine-tuned model, or asks about openmed zero deps/index/infer, the gliner extra, or GLiNER. Pairs adjacent to extracting-clinical-entities (use that for high-accuracy fixed-schema NER) and loading-openmed-models.
repo: maziyarpanahi/openmed
Độ phổ biến
- Sao GitHub
- 5.8k
- Vị trí xếp hạng
- #14729
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
annotating-variants
5.8kGiúp agent dự đoán tác động của biến thể di truyền, đổi tên HGVS sang vị trí bộ gen và gắn tần suất quần thể bằng công cụ chú giải miễn phí.
ask-openmed
5.8kGiúp agent chọn đúng quy trình OpenMed cho yêu cầu về văn bản lâm sàng, luôn kiểm tra quyền riêng tư trước khi có thể có dữ liệu bệnh nhân.
assembling-fhir-bundles
5.8kGói nhiều bản ghi y tế FHIR thành một Bundle giao dịch để gửi tới EHR, với các tham chiếu nội bộ được liên kết đúng.
auditing-deid-leakage
5.8kQuét văn bản lâm sàng đã khử nhận dạng để tìm định danh còn sót như SSN, số thẻ, email và ngày tháng, và chặn phát hành nếu còn sót.
Skill tương tự
gitcrawl
394kCho phép agent của bạn tìm trong kho lưu trữ issue và pull request GitHub, gom các mục trùng lặp và kiểm tra trạng thái hiện tại trên GitHub.
slacrawl
394kCho phép agent của bạn tìm và đếm tin nhắn trong kho lưu trữ Slack cục bộ, kiểm tra kho đó mới đến mức nào và làm mới khi cần.
goplaces
394kGiúp agent của bạn tìm địa điểm, lấy chi tiết và đánh giá, và xác định tên địa điểm bằng Google Places, với đầu ra JSON cho script.