Instructions to use lion-ai/medextractor-eu-test with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lion-ai/medextractor-eu-test with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="lion-ai/medextractor-eu-test", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("lion-ai/medextractor-eu-test", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
MedExtractor EU (test build)
Schema-conditioned information extraction for clinical text. You pass a document and a list of fields (name, type, description); one forward pass returns, for every field, the exact text span(s) from the document or nothing. Built on Gemma 4 E2B used as a bidirectional encoder, tuned for European languages with a focus on Polish hospital documentation.
Private test build: one training seed, not a release.
Usage
import torch
from transformers import AutoModel
model = AutoModel.from_pretrained("lion-ai/medextractor-eu-test", trust_remote_code=True, dtype=torch.bfloat16).cuda() # or .to("mps")
note = """Pacjentka w stanie og贸lnym 艣rednim, w pe艂nym kontakcie s艂owno-logicznym. BP 128/76mmHg, HR 102/min, Sat. 96% bez tlenoterapii.
W nocy gor膮czka do 38,3. Brzuch niebolesny, perystaltyka s艂yszalna. CRP 98-->121.3. W艂膮czono fosfomycyn臋."""
fields = [
("cisnienie_tetnicze", "text", "warto艣膰 ci艣nienia t臋tniczego"),
("tetno", "text", "cz臋sto艣膰 akcji serca (t臋tno)"),
("temperatura", "list[text]", "zmierzone warto艣ci temperatury cia艂a"),
("badanie_brzucha", "text", "opis badania brzucha, ca艂y zapis"),
("leki_w_szpitalu", "list[text]", "leki podane lub w艂膮czone w trakcie hospitalizacji (nazwy lek贸w)"),
("alergie", "list[text]", "substancje, na kt贸re pacjent jest uczulony"),
]
print(model.extract(note, fields))
# with character offsets and scores: model.extract(note, fields, with_spans=True)
- Field types:
text,number,date,durationandlist[...]of those. Scalar fields return a string orNone; list fields return a list. - The description decides what is returned: say "ca艂y zapis" (whole entry) or "sama warto艣膰" (value only), "nie zaprzeczenia" (no negations), "przed przyj臋ciem" / "przy wypisie".
- Up to 32 fields and 8192 tokens (document plus schema) per call;
extractaccepts a list of documents. A field asked astextreturns one piece of evidence; asklist[text]to get every mention. - Thresholds:
null_thresholdandlist_threshold(defaults inconfig.json, calibrated on development data) can be passed toextract; a lowernull_thresholdfills fewer scalar fields. For presence decisions usewith_spans=Trueand1 - p_null. - Apple silicon (MPS):
dtype=torch.bfloat16works and is about 3x faster thanfloat32(same decisions in an external test); on CPU usedtype=torch.float32.
Model details
| Base | Gemma 4 E2B (text model, bidirectional attention mask) |
| Parameters | 4.6B stored (2.8B embedding tables), 1.9B computed per token |
| Requires | transformers >= 5.0 with Gemma 4 support, trust_remote_code=True |
Development results
| Set | Metric | Score |
|---|---|---|
| Out-of-distribution field accuracy (dev) | exact span | 94.1 |
| List fields, in-distribution dev | F1 | 79.8 |
| Open-schema clinical notes, field families not in training (EN / PL) | exact or overlapping span | 71.3 / 72.6 |
| Zero-shot biomedical NER, two suites of unseen corpora (EN) | strict F1 | 57.8 / 60.3 |
| Polish real-style notes (15 documents, 25 fields each) | strict F1 / false fills on empty fields | 0.91 / 0.4% |
| Admission-audit style schema on the same notes (presence of evidence, one threshold for all fields) | accuracy / F1 | 98.0% / 0.90 |
The Polish real-style sets guided data design, so their scores are development numbers.
Limitations
Test build from a single seed. Polish hospital style is learned from synthetic notes; other languages rely on public clinical corpora. Extraction only: the model copies spans and does not normalise or infer values. Not a medical device.
- Downloads last month
- 8