Token Classification
Transformers
Safetensors
English
medextractor
feature-extraction
information-extraction
span-extraction
medical
clinical
biomedical
ner
zero-shot
extractive-qa
custom_code
Instructions to use lion-ai/medextractor-liquid with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lion-ai/medextractor-liquid with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="lion-ai/medextractor-liquid", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("lion-ai/medextractor-liquid", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Shorter README; full results in EVALUATION.md
Browse files- EVALUATION.md +91 -0
- README.md +47 -118
EVALUATION.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MedExtractor Nano — evaluation details
|
| 2 |
+
|
| 3 |
+
Full results behind the summary tables in the [README](README.md).
|
| 4 |
+
|
| 5 |
+
## Protocol
|
| 6 |
+
|
| 7 |
+
Each test split was scored exactly once, after the model, thresholds, adapters and metrics had been fixed on dev data. We ran every competitor ourselves on the same records with the same scorer; no number is copied from a paper or a model card. Each competitor is scored at its own per-corpus dev-best threshold. MedExtractor Nano uses one fixed `list_threshold=0.3` for every corpus.
|
| 8 |
+
|
| 9 |
+
## Zero-shot biomedical NER
|
| 10 |
+
|
| 11 |
+
The fifteen corpora are absent from the training data. The metric is strict character-span micro-F1 per corpus, macro-averaged over corpora. Every system gets the corpus types as labels.
|
| 12 |
+
|
| 13 |
+
- **Strict:** bare labels, primary gold spans only.
|
| 14 |
+
- **Adapted:** the same frozen convention adapters are applied to the output of every system (see the notes below the table). The per-corpus columns show adapted scores.
|
| 15 |
+
|
| 16 |
+
**Seven-corpus suite:**
|
| 17 |
+
|
| 18 |
+
| Model | Size | Macro, adapted | Macro, strict | AnatEM | BC2GM | BioInfer | CG | JNLPBA | Linnaeus | ProGene |
|
| 19 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 20 |
+
| **MedExtractor Nano** | 359M | **66.7** | **59.7** | **50.8** | **84.1** | **43.9** | **67.5** | 62.7 | 74.2 | **83.5** |
|
| 21 |
+
| Gemma 4 31B (LLM, zero-shot prompt) | 31B | 63.5 | 57.0 | 50.5 | 79.8 | 30.5 | 65.2 | 57.5 | **78.0** | 83.0 |
|
| 22 |
+
| GLiNER-BioMed bi-large v1.0 | – | 55.9 | 53.2 | 45.2 | 75.7 | 31.9 | 52.9 | **63.5** | 59.0 | 62.8 |
|
| 23 |
+
| gliner-bi-large v2.0 | 530M | 55.5 | 53.2 | 47.4 | 77.3 | 20.5 | 55.8 | 61.7 | 58.9 | 67.0 |
|
| 24 |
+
| gliner-bi-small v2.0 | 108M | 53.4 | 51.3 | 50.5 | 77.6 | 17.8 | 50.2 | 58.5 | 55.2 | 63.9 |
|
| 25 |
+
| gliner-bi-base v2.0 | 194M | 53.2 | 50.8 | 48.2 | 78.1 | 12.3 | 53.3 | 57.1 | 57.2 | 66.1 |
|
| 26 |
+
| GLiNER-BioMed large v1.0 | – | 52.5 | 50.5 | 36.7 | 69.8 | 28.6 | 55.9 | 52.2 | 56.4 | 67.7 |
|
| 27 |
+
| GLiNER2 large v1 | 486M | 50.2 | 46.4 | 32.5 | 67.1 | 31.5 | 42.7 | 50.2 | 65.6 | 61.5 |
|
| 28 |
+
|
| 29 |
+
**Eight further corpora** (no convention adapters; strict = adapted):
|
| 30 |
+
|
| 31 |
+
| Model | Macro | BioNLP 2011 ID | BioNLP 2013 PC | BioNLP 2019 BB | CellFinder | CPI | miRNA | OSIRIS | PDR |
|
| 32 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 33 |
+
| **MedExtractor Nano** | **61.8** | **65.8** | **74.4** | **46.5** | **60.1** | **66.1** | **71.7** | **43.0** | **66.7** |
|
| 34 |
+
| GLiNER-BioMed large v1.0 | 53.6 | 54.9 | 64.5 | 44.0 | 44.2 | 60.6 | 69.5 | 31.9 | 59.1 |
|
| 35 |
+
| gliner-bi-large v2.0 | 51.9 | 55.1 | 66.4 | 40.0 | 49.4 | 56.3 | 61.8 | 28.5 | 57.3 |
|
| 36 |
+
| GLiNER-BioMed bi-large v1.0 | 50.4 | 50.3 | 62.6 | 40.8 | 43.1 | 56.9 | 61.9 | 31.7 | 56.1 |
|
| 37 |
+
| gliner-bi-base v2.0 | 47.6 | 50.3 | 62.1 | 41.8 | 45.6 | 57.6 | 47.5 | 20.1 | 55.9 |
|
| 38 |
+
| gliner-bi-small v2.0 | 46.7 | 54.7 | 59.3 | 40.4 | 42.5 | 55.7 | 47.1 | 17.7 | 56.1 |
|
| 39 |
+
| GLiNER2 large v1 | 46.6 | 49.9 | 45.7 | 40.3 | 39.4 | 56.9 | 57.0 | 30.1 | 53.5 |
|
| 40 |
+
|
| 41 |
+
Bold marks the best system per column. Gemma 4 31B was run on the seven-corpus suite only.
|
| 42 |
+
|
| 43 |
+
**Convention adapters.** They were frozen on dev before the test run and applied identically to every system:
|
| 44 |
+
- **BC2GM:** the official BioCreative II scorer, which also accepts the annotated alternative boundaries (for example "p53", "p53 gene" and "p53 protein").
|
| 45 |
+
- **JNLPBA:** a GENIA-convention adapter that sets the type from the head noun and attaches left modifiers. MedExtractor Nano additionally gets a one-line description of the convention for each type (see the README usage notes). The GLiNER models take labels only.
|
| 46 |
+
- **Linnaeus:** people nouns ("patients", "women") are dropped, because the corpus tags only species names.
|
| 47 |
+
- **AnatEM:** the umbrella label "anatomy" is queried as the 12 entity types published for the corpus (Pyysalo and Ananiadou, 2014), and the results are merged back. Each competitor keeps whichever variant, bare or expanded, scored better on dev.
|
| 48 |
+
|
| 49 |
+
With the adapters, AnatEM is a near tie: three systems are within 0.3 points. Without the adapters, MedExtractor Nano trails on three corpora: AnatEM 40.9 against 50.5 (gliner-bi-small v2.0), BC2GM 58.6 against 65.8 and JNLPBA 54.0 against 63.7 (both GLiNER-BioMed bi-large).
|
| 50 |
+
|
| 51 |
+
## Clinical notes with user-defined fields
|
| 52 |
+
|
| 53 |
+
The test set holds synthetic EN/PL clinical notes written by Gemini and verified by GPT-5.4. The fields come from two pools:
|
| 54 |
+
- **Seen kinds:** kinds that also occur in MedExtractor Nano's training data. They are new to the other systems, so this row favours our model.
|
| 55 |
+
- **Held-out families:** smoking, physician / department, and referral / follow-up. They were never generated for training.
|
| 56 |
+
|
| 57 |
+
The metric is the share of scalar fields whose value is exact or overlaps the gold span; empty-gold fields count as correct only when the system returns null.
|
| 58 |
+
|
| 59 |
+
| Fields | MedExtractor Nano | GLiNER2 large | Gemma 4 31B |
|
| 60 |
+
| --- | --- | --- | --- |
|
| 61 |
+
| Seen kinds, EN | **76.1** | 63.2 | 69.6 |
|
| 62 |
+
| Seen kinds, PL | 70.2 | 63.3 | **70.3** |
|
| 63 |
+
| Held-out families, EN | 60.6 | 45.0 | **78.8** |
|
| 64 |
+
| ↳ with English field names | 73.1 | 53.9 | **79.1** |
|
| 65 |
+
| ↳ with Polish field names | 17.0 | 14.0 | **78.0** |
|
| 66 |
+
| Held-out families, PL | 38.5 | 40.7 | **84.5** |
|
| 67 |
+
| List fields, seen kinds, EN (strict F1) | **86.9** | 75.5 | 73.5 |
|
| 68 |
+
| Fills of empty fields, held-out EN | **0.4%** | 2.4% | 1.3% |
|
| 69 |
+
|
| 70 |
+
## Clinical notes, out of distribution
|
| 71 |
+
|
| 72 |
+
The test set holds 500 synthetic EN/PL notes for the eight original field families. Their sentence templates, wording and field names were unseen in training, and the thresholds were calibrated on dev.
|
| 73 |
+
|
| 74 |
+
| Metric | MedExtractor Nano |
|
| 75 |
+
| --- | --- |
|
| 76 |
+
| Correct values, all fields | 89.3% |
|
| 77 |
+
| Missed values (answerable fields returned as null) | 9.3% |
|
| 78 |
+
| Fills of fields that should be empty | 0.24% |
|
| 79 |
+
|
| 80 |
+
## In-distribution test splits
|
| 81 |
+
|
| 82 |
+
20,011 records over about 95 sources.
|
| 83 |
+
|
| 84 |
+
| Group | MedExtractor Nano |
|
| 85 |
+
| --- | --- |
|
| 86 |
+
| Scalar fields, accuracy | 65.8 |
|
| 87 |
+
| List fields, strict F1 | 68.5 |
|
| 88 |
+
| English NER, F1 | 79.5 |
|
| 89 |
+
| Non-English NER, F1 | 69.8 |
|
| 90 |
+
| Slot filling, F1 | 56.6 |
|
| 91 |
+
| Field selection, accuracy | 100.0 |
|
README.md
CHANGED
|
@@ -11,21 +11,13 @@ tags: [information-extraction, span-extraction, medical, clinical, biomedical, n
|
|
| 11 |
|
| 12 |
# MedExtractor Nano
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
**
|
| 17 |
-
- **
|
| 18 |
-
- **
|
| 19 |
-
- **One model** for NER, extractive QA and slot filling, with field names and descriptions in any language, at encoder speed.
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
**What changed since v1** (v1 stays available under the `v1` tag)
|
| 24 |
-
- **User-defined fields.** Training now includes synthetic clinical notes whose fields come from a catalogue of 465 clinical field kinds, so the model handles field names and descriptions outside the eight families it was first trained on.
|
| 25 |
-
- **Span conventions in the description.** The description can state how much text to take, for example the full noun phrase with its modifiers, or the name only, and the model follows it.
|
| 26 |
-
- **Status-aware fields.** It separates the patient's value from a relative's, current from previous values, and drugs taken from drugs stopped or causing an allergy.
|
| 27 |
-
|
| 28 |
-
> Not a medical device. It was trained and evaluated only on public datasets and synthetic notes, never on real patient records. Verify every output before using it in care.
|
| 29 |
|
| 30 |
## Usage
|
| 31 |
|
|
@@ -48,126 +40,63 @@ print(model.extract(note, fields))
|
|
| 48 |
# {"age": "67", "admission_date": "03/12/2025", "current_drugs": ["metformin", "ramipril"], "stopped_drugs": ["Atorvastatin"], "ramipril_dose": "5 mg", "cancer": null}
|
| 49 |
```
|
| 50 |
|
| 51 |
-
- **
|
| 52 |
-
- **
|
| 53 |
-
- **Spans:** `with_spans=True`
|
| 54 |
-
- **Limits:** at most 24 fields and 2048 input tokens per pass. Longer texts are truncated, and the output then carries `"_truncated": true`.
|
| 55 |
-
- **Thresholds:** `null_threshold` (default 0.3) and `list_threshold` (default 0.6) were calibrated on in-distribution dev data. For open-type NER with bare entity labels, `list_threshold=0.3` worked best on our zero-shot dev split.
|
| 56 |
-
|
| 57 |
-
## Evaluation
|
| 58 |
-
|
| 59 |
-
Each test split was scored exactly once, after the model, thresholds, adapters and metrics had been fixed on dev data. We ran every competitor ourselves on the same records with the same scorer; no number is copied from a paper or a model card. Each competitor is scored at its own per-corpus dev-best threshold. MedExtractor Nano uses one fixed `list_threshold=0.3` for every corpus.
|
| 60 |
-
|
| 61 |
-
### Zero-shot biomedical NER
|
| 62 |
-
|
| 63 |
-
The fifteen corpora are absent from the training data. The metric is strict character-span micro-F1 per corpus, macro-averaged over corpora. Every system gets the corpus types as labels.
|
| 64 |
|
| 65 |
-
|
| 66 |
-
- **Adapted:** the same frozen convention adapters are applied to the output of every system (see the notes below the table). The per-corpus columns show adapted scores.
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
-
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 72 |
-
| **MedExtractor Nano** | 359M | **66.7** | **59.7** | **50.8** | **84.1** | **43.9** | **67.5** | 62.7 | 74.2 | **83.5** |
|
| 73 |
-
| Gemma 4 31B (LLM, zero-shot prompt) | 31B | 63.5 | 57.0 | 50.5 | 79.8 | 30.5 | 65.2 | 57.5 | **78.0** | 83.0 |
|
| 74 |
-
| GLiNER-BioMed bi-large v1.0 | – | 55.9 | 53.2 | 45.2 | 75.7 | 31.9 | 52.9 | **63.5** | 59.0 | 62.8 |
|
| 75 |
-
| gliner-bi-large v2.0 | 530M | 55.5 | 53.2 | 47.4 | 77.3 | 20.5 | 55.8 | 61.7 | 58.9 | 67.0 |
|
| 76 |
-
| gliner-bi-small v2.0 | 108M | 53.4 | 51.3 | 50.5 | 77.6 | 17.8 | 50.2 | 58.5 | 55.2 | 63.9 |
|
| 77 |
-
| gliner-bi-base v2.0 | 194M | 53.2 | 50.8 | 48.2 | 78.1 | 12.3 | 53.3 | 57.1 | 57.2 | 66.1 |
|
| 78 |
-
| GLiNER-BioMed large v1.0 | – | 52.5 | 50.5 | 36.7 | 69.8 | 28.6 | 55.9 | 52.2 | 56.4 | 67.7 |
|
| 79 |
-
| GLiNER2 large v1 | 486M | 50.2 | 46.4 | 32.5 | 67.1 | 31.5 | 42.7 | 50.2 | 65.6 | 61.5 |
|
| 80 |
|
| 81 |
-
|
| 82 |
|
| 83 |
-
|
| 84 |
-
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 85 |
-
| **MedExtractor Nano** | **61.8** | **65.8** | **74.4** | **46.5** | **60.1** | **66.1** | **71.7** | **43.0** | **66.7** |
|
| 86 |
-
| GLiNER-BioMed large v1.0 | 53.6 | 54.9 | 64.5 | 44.0 | 44.2 | 60.6 | 69.5 | 31.9 | 59.1 |
|
| 87 |
-
| gliner-bi-large v2.0 | 51.9 | 55.1 | 66.4 | 40.0 | 49.4 | 56.3 | 61.8 | 28.5 | 57.3 |
|
| 88 |
-
| GLiNER-BioMed bi-large v1.0 | 50.4 | 50.3 | 62.6 | 40.8 | 43.1 | 56.9 | 61.9 | 31.7 | 56.1 |
|
| 89 |
-
| gliner-bi-base v2.0 | 47.6 | 50.3 | 62.1 | 41.8 | 45.6 | 57.6 | 47.5 | 20.1 | 55.9 |
|
| 90 |
-
| gliner-bi-small v2.0 | 46.7 | 54.7 | 59.3 | 40.4 | 42.5 | 55.7 | 47.1 | 17.7 | 56.1 |
|
| 91 |
-
| GLiNER2 large v1 | 46.6 | 49.9 | 45.7 | 40.3 | 39.4 | 56.9 | 57.0 | 30.1 | 53.5 |
|
| 92 |
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
|
| 96 |
-
- **BC2GM:** the official BioCreative II scorer, which also accepts the annotated alternative boundaries (for example "p53", "p53 gene" and "p53 protein").
|
| 97 |
-
- **JNLPBA:** a GENIA-convention adapter that sets the type from the head noun and attaches left modifiers. MedExtractor Nano additionally gets a one-line description of the convention for each type (the example in Usage). The GLiNER models take labels only.
|
| 98 |
-
- **Linnaeus:** people nouns ("patients", "women") are dropped, because the corpus tags only species names.
|
| 99 |
-
- **AnatEM:** the umbrella label "anatomy" is queried as the 12 entity types published for the corpus (Pyysalo and Ananiadou, 2014), and the results are merged back. Each competitor keeps whichever variant, bare or expanded, scored better on dev.
|
| 100 |
|
| 101 |
-
|
| 102 |
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
-
- **Seen kinds:** kinds that also occur in MedExtractor Nano's training data. They are new to the other systems, so this row favours our model.
|
| 107 |
-
- **Held-out families:** smoking, physician / department, and referral / follow-up. They were never generated for training.
|
| 108 |
|
| 109 |
-
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
| Seen kinds, PL | 70.2 | 63.3 | **70.3** |
|
| 115 |
-
| Held-out families, EN | 60.6 | 45.0 | **78.8** |
|
| 116 |
-
| ↳ with English field names | 73.1 | 53.9 | **79.1** |
|
| 117 |
-
| ↳ with Polish field names | 17.0 | 14.0 | **78.0** |
|
| 118 |
-
| Held-out families, PL | 38.5 | 40.7 | **84.5** |
|
| 119 |
-
| List fields, seen kinds, EN (strict F1) | **86.9** | 75.5 | 73.5 |
|
| 120 |
-
| Fills of empty fields, held-out EN | **0.4%** | 2.4% | 1.3% |
|
| 121 |
-
|
| 122 |
-
### Clinical notes, out of distribution
|
| 123 |
-
|
| 124 |
-
The test set holds 500 synthetic EN/PL notes for the eight original field families. Their sentence templates, wording and field names were unseen in training, and the thresholds were calibrated on dev.
|
| 125 |
-
|
| 126 |
-
| Metric | v2 (this model) | v1 |
|
| 127 |
-
| --- | --- | --- |
|
| 128 |
-
| Correct values, all fields | 89.3% | 91.2% |
|
| 129 |
-
| Missed values (answerable fields returned as null) | 9.3% | 6.3% |
|
| 130 |
-
| Fills of fields that should be empty | 0.24% | 0.32% |
|
| 131 |
-
|
| 132 |
-
### In-distribution test splits
|
| 133 |
-
|
| 134 |
-
20,011 records over about 95 sources; v1 numbers are on the same splits.
|
| 135 |
-
|
| 136 |
-
| Group | v2 (this model) | v1 |
|
| 137 |
-
| --- | --- | --- |
|
| 138 |
-
| Scalar fields, accuracy | 65.8 | 66.4 |
|
| 139 |
-
| List fields, strict F1 | 68.5 | 69.8 |
|
| 140 |
-
| English NER, F1 | 79.5 | 80.2 |
|
| 141 |
-
| Non-English NER, F1 | 69.8 | 66.9 |
|
| 142 |
-
| Slot filling, F1 | 56.6 | 58.8 |
|
| 143 |
-
| Field selection, accuracy | 100.0 | 100.0 |
|
| 144 |
-
|
| 145 |
-
## Known limitations
|
| 146 |
-
|
| 147 |
-
- **Unseen field families:** a prompted 31B LLM is clearly better on field kinds far from training (78.8% against 60.6% in English).
|
| 148 |
-
- **Polish:** unseen Polish field names are the weakest case. Only 17% of values are found when the name is Polish and the note is English, and 38.5% on Polish notes. Polish names of seen field kinds work (70.2%), so we attribute the gap to the backbone's weaker Polish.
|
| 149 |
-
- **Gene and protein boundaries:** JNLPBA stays 0.8 points below GLiNER-BioMed bi-large even with the convention description. Without adapters, BC2GM, JNLPBA and AnatEM trail by 7–10 points.
|
| 150 |
-
- **Linnaeus:** Gemma 4 31B is 3.8 points higher (78.0 against 74.2). Among encoders, MedExtractor Nano leads by 8.6 points.
|
| 151 |
-
- **Compared with v1:** v2 is more conservative on the original eight field families: 89.3% against 91.2% correct, with most extra misses on number fields. In-distribution scores are 0.6–2.2 points lower, except non-English NER (+2.9).
|
| 152 |
-
- **Long texts:** inputs over 2048 tokens are truncated, and there is no sliding window yet.
|
| 153 |
-
- **No real-world clinical validation.** The clinical evaluations use synthetic notes, and no Polish clinical gold standard exists yet.
|
| 154 |
-
- **Training data and zero-shot:** none of the fifteen zero-shot corpora is in the training data, but the training mix contains about 25 other human-annotated biomedical corpora with overlapping entity types (genes, chemicals, diseases). The comparison is between released models with their own training data, not between architectures trained on the same data.
|
| 155 |
|
| 156 |
## Training
|
| 157 |
|
| 158 |
-
- **Data:** 1.25M
|
| 159 |
-
-
|
| 160 |
-
-
|
| 161 |
-
-
|
| 162 |
-
- **Decontamination:**
|
| 163 |
-
- **Procedure:** two-stage fine-tuning of
|
| 164 |
-
- **Hardware:** a single NVIDIA RTX PRO 6000 (96 GB).
|
| 165 |
|
| 166 |
## License
|
| 167 |
|
| 168 |
-
The weights are a
|
| 169 |
-
- commercial use is licensed only for entities below USD 10M annual revenue;
|
| 170 |
-
- `modeling_lfm2_bidirectional.py` and the tokenizer files are unmodified copies from Liquid AI;
|
| 171 |
-
- see `NOTICE` for what was added.
|
| 172 |
-
|
| 173 |
-
The training mix also contains datasets released for **non-commercial use only**, among them MultiNERD (CC BY-NC-SA 4.0), the DDI corpus (CC BY-NC 4.0) and parts of MRQA. It also contains data generated with Gemma 4 31B, which is subject to the Gemma terms of use. Treat this release as **non-commercial / research use**.
|
|
|
|
| 11 |
|
| 12 |
# MedExtractor Nano
|
| 13 |
|
| 14 |
+
A 359M-parameter encoder that extracts user-defined fields from clinical and biomedical text. You pass a text and a list of fields (name, type, description). One forward pass returns, for every field, a span from the text or `null`; list fields return all matching spans.
|
| 15 |
|
| 16 |
+
- **Zero-shot biomedical NER:** highest macro F1 of all systems we evaluated on 15 corpora absent from training, ahead of a prompted Gemma 4 31B on the seven where we ran it.
|
| 17 |
+
- **Your own fields:** handles field names and descriptions it was not trained on, in English and Polish clinical notes.
|
| 18 |
+
- **One model, encoder speed:** NER, extractive QA and slot filling with the same interface.
|
|
|
|
| 19 |
|
| 20 |
+
> Not a medical device. Trained and evaluated only on public datasets and synthetic notes, never on real patient records. Verify every output before using it in care.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
## Usage
|
| 23 |
|
|
|
|
| 40 |
# {"age": "67", "admission_date": "03/12/2025", "current_drugs": ["metformin", "ramipril"], "stopped_drugs": ["Atorvastatin"], "ramipril_dose": "5 mg", "cancer": null}
|
| 41 |
```
|
| 42 |
|
| 43 |
+
- **Descriptions** can be in any language and may state a span convention, for example `"protein, as the outermost (longest) mention"`.
|
| 44 |
+
- **Thresholds:** `null_threshold` (default 0.3) and `list_threshold` (default 0.6). For NER with bare entity labels, `list_threshold=0.3` works better.
|
| 45 |
+
- **Spans:** `with_spans=True` adds character offsets, a score and `p_null`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
## Model details
|
|
|
|
| 48 |
|
| 49 |
+
| | |
|
| 50 |
+
| --- | --- |
|
| 51 |
+
| Base model | [LFM2.5-Encoder-350M](https://huggingface.co/LiquidAI/LFM2.5-Encoder-350M) with an extraction head |
|
| 52 |
+
| Parameters | 359M |
|
| 53 |
+
| Input | up to 2048 tokens and 24 fields per pass (longer texts are truncated) |
|
| 54 |
+
| Field types | `text`, `number`, `date`, `duration`, `list[...]` |
|
| 55 |
+
| Languages | trained on 62; clinical evaluation in English and Polish |
|
| 56 |
|
| 57 |
+
## Evaluation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
All numbers are on locked test splits, scored once after every choice had been fixed on dev data. We ran every competitor ourselves on the same records. Full per-dataset tables and the protocol are in [EVALUATION.md](EVALUATION.md).
|
| 60 |
|
| 61 |
+
**Zero-shot biomedical NER** (strict span micro-F1, macro over corpora; the corpora are absent from training):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
+
| Model | Size | 7 corpora | 7 corpora, adapted | 8 more corpora |
|
| 64 |
+
| --- | --- | --- | --- | --- |
|
| 65 |
+
| **MedExtractor Nano** | 359M | **59.7** | **66.7** | **61.8** |
|
| 66 |
+
| Gemma 4 31B (prompted) | 31B | 57.0 | 63.5 | – |
|
| 67 |
+
| GLiNER-BioMed bi-large v1.0 | – | 53.2 | 55.9 | 50.4 |
|
| 68 |
+
| gliner-bi-large v2.0 | 530M | 53.2 | 55.5 | 51.9 |
|
| 69 |
+
| GLiNER-BioMed large v1.0 | – | 50.5 | 52.5 | 53.6 |
|
| 70 |
+
| GLiNER2 large v1 | 486M | 46.4 | 50.2 | 46.6 |
|
| 71 |
|
| 72 |
+
The seven corpora are AnatEM, BC2GM, BioInfer, BioNLP-CG, JNLPBA, Linnaeus and ProGene. The eight further corpora are BioNLP ID, PC and BB, CellFinder, CPI, miRNA, OSIRIS and PDR. "Adapted" applies the same frozen corpus-convention rules to every system, for example the official BC2GM scorer.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
**Clinical notes with user-defined fields** (share of fields with a correct or overlapping value):
|
| 75 |
|
| 76 |
+
| Fields | MedExtractor Nano | GLiNER2 large | Gemma 4 31B |
|
| 77 |
+
| --- | --- | --- | --- |
|
| 78 |
+
| Seen field kinds, EN | **76.1** | 63.2 | 69.6 |
|
| 79 |
+
| Seen field kinds, PL | 70.2 | 63.3 | **70.3** |
|
| 80 |
+
| Held-out field families, EN | 60.6 | 45.0 | **78.8** |
|
| 81 |
+
| Held-out field families, PL | 38.5 | 40.7 | **84.5** |
|
| 82 |
|
| 83 |
+
Seen kinds also occur in our training data. Held-out families (smoking, physician and department, referral and follow-up) were never generated for training.
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
## Limitations
|
| 86 |
|
| 87 |
+
- On field families far from training, a prompted 31B LLM is clearly better, most of all with Polish field names.
|
| 88 |
+
- Without the convention rules, BC2GM, JNLPBA and AnatEM trail the best GLiNER model by 7–10 points. JNLPBA stays 0.8 below it even with them.
|
| 89 |
+
- The clinical evaluation uses synthetic notes only. The model has no real-world clinical validation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
## Training
|
| 92 |
|
| 93 |
+
- **Data:** 1.25M records from 93 sources:
|
| 94 |
+
- public QA, NER, slot-filling, biomedical and clinical datasets;
|
| 95 |
+
- programmatic EN/PL clinical notes;
|
| 96 |
+
- notes and annotations generated with Gemma 4 31B.
|
| 97 |
+
- **Decontamination:** texts that share a sentence with any evaluation split were removed. The evaluated corpora and held-out field families are not in training. Other human-annotated biomedical corpora with similar entity types are.
|
| 98 |
+
- **Procedure:** two-stage fine-tuning of encoder and head. The released weights average two seeds. Training ran on one NVIDIA RTX PRO 6000.
|
|
|
|
| 99 |
|
| 100 |
## License
|
| 101 |
|
| 102 |
+
The weights are a derivative of LFM2.5-Encoder-350M under the **LFM Open License v1.0** (`LICENSE`). Commercial use is licensed only for organisations below USD 10M annual revenue. The training data also includes non-commercial datasets (MultiNERD, the DDI corpus, parts of MRQA) and Gemma-generated data (Gemma terms of use), so treat this release as **non-commercial / research use**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|