# Running Zeroshot Ner

Extract arbitrary, custom entity types from clinical or biomedical text with no...

- Repository: https://github.com/maziyarpanahi/openmed (5755 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add maziyarpanahi/openmed --skill running-zeroshot-ner -g -a claude-code -y`
Codex: `npx skills add maziyarpanahi/openmed --skill running-zeroshot-ner -g -a codex -y`
Cursor: `npx skills add maziyarpanahi/openmed --skill running-zeroshot-ner -g -a cursor -y`
Gemini CLI: `npx skills add maziyarpanahi/openmed --skill running-zeroshot-ner -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add maziyarpanahi/openmed`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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

```bash
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.

1. **`openmed zero index <models_dir>`**, scan a directory of downloaded GLiNER /
   GLiNER2 checkpoints and write `index.json` (model ids, family, domains, paths).
2. **`openmed zero infer "<text>" --model-id <id>`**, run extraction against a
   model from the index, with labels you supply.

```bash
# 1) Build the index over your local models (writes <models_dir>/index.json)
openmed zero index /models/gliner --output /models/gliner/index.json

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/running-zeroshot-ner/SKILL.md
