Instructions to use OpenMed/GLiNER2.5-DrugChemical-Small-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER2
How to use OpenMed/GLiNER2.5-DrugChemical-Small-v1 with GLiNER2:
from gliner2 import AutoExtractor extractor = AutoExtractor.from_pretrained("OpenMed/GLiNER2.5-DrugChemical-Small-v1") # Extract entities text = "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday." result = extractor.extract_entities(text, ["company", "person", "product", "location"]) print(result) - GLiNER
How to use OpenMed/GLiNER2.5-DrugChemical-Small-v1 with GLiNER:
from gliner import GLiNER model = GLiNER.from_pretrained("OpenMed/GLiNER2.5-DrugChemical-Small-v1") text = "Cristiano Ronaldo dos Santos Aveiro was born on 5 February 1985 in Funchal, Madeira, Portugal." labels = ["person", "date", "location"] entities = model.predict_entities(text, labels) for entity in entities: print(entity["text"], "=>", entity["label"]) - Notebooks
- Google Colab
- Kaggle
OpenMed GLiNER2.5 DrugChemical Small v1
OpenMed's open model for finding drugs and chemicals in biomedical text. It returns every drug and chemical mention in English biomedical text with exact character offsets and a confidence score. Trained and evaluated by OpenMed. Apache-2.0, 73.9M parameters, runs on CPU.
| Developed by | OpenMed |
|---|---|
| Task | Chemical and drug mention extraction, one label: chemical or drug (the prompt it was trained with) |
| Output | text, start, end, score; text[start:end] is the exact span |
| Parameters | 73.9M |
| Default threshold | 0.4 |
| Language | English |
| License | Apache-2.0 |
About OpenMed
OpenMed builds open models and open-source tools for clinical and biomedical text that run on your own hardware.
- 2,300+ open models on Hugging Face for clinical NER, de-identification and more.
- The OpenMed Python SDK, Apache-2.0:
pip install openmedfor de-identification, clinical NER, and FHIR and HL7 tooling, all local. - New models every week: follow OpenMed on Hugging Face and @OpenMed_AI on X.
Quick start
pip install -U "openmed[gliner2]" # OpenMed 3.2 or later
from openmed import OpenMedConfig, analyze_text
text = (
"Metformin lowered fasting glucose and insulin levels "
"in obese mice fed a high-fat diet, without changing "
"body weight."
)
result = analyze_text(
text,
model_id="OpenMed/GLiNER2.5-DrugChemical-Small-v1",
labels=["chemical or drug"],
threshold=0.05,
confidence_threshold=0.4,
max_length=150,
config=OpenMedConfig(use_medical_tokenizer=False),
)
for e in result.entities:
print(e.start, e.end, e.text, f"{e.confidence:.2f}")
0 9 Metformin 0.97
26 33 glucose 0.89
38 45 insulin 0.95
The settings
labels=["chemical or drug"]is the prompt the model was trained with. Keep it as written.threshold=0.05lets the model propose spans down to 0.05, andconfidence_threshold=0.4keeps those scoring 0.4 or more. This is the decoding behind the evaluation below. Raiseconfidence_thresholdfor fewer, surer spans.max_length=150makesanalyze_textgroup sentences into pieces of at most 600 characters, the window size used in training and evaluation. It only matters for long texts.use_medical_tokenizer=Falsekeeps the model's own span boundaries. The SDK default merges touching spans of one label: in example 6 it would return D2 receptor antagonist haloperidol as one span instead of D2 receptor antagonist and haloperidol.
Long abstracts, many abstracts, GPU
- Pass a whole abstract:
analyze_textsplits it into sentences and returns offsets into the original text. - The model loads once and stays cached, so call
analyze_textin a loop for many texts. - On a GPU, pass
config=OpenMedConfig(device="cuda", use_medical_tokenizer=False).
Evaluation
MedMentions, 200 held-out abstracts: PubMed abstracts with 1,858 human-annotated chemical and drug mentions (the 20 semantic types of the UMLS Chemicals & Drugs semantic group, mapped to one label). The model was trained on 800 other MedMentions abstracts, both thresholds were chosen on 200 more, and these 200 were scored once at the end, with the model, thresholds and scoring code frozen first. A prediction counts only if its character span matches exactly. All abstracts come from the official MedMentions training partition; the official test set was not used, so these numbers are not comparable to published MedMentions results.
| Model | Precision | Recall | F1 |
|---|---|---|---|
| OpenMed GLiNER2.5 DrugChemical Small v1 (this model), threshold 0.4 | 65.55 | 69.43 | 67.43 |
| Before OpenMed fine-tuning: fastino/gliner2.5-small-v1, threshold 0.5 | 40.39 | 51.02 | 45.09 |
OpenMed's fine-tuning added +22.34 F1 points (95% CI +19.27 to +25.93, paired bootstrap over the 200 abstracts, 2,000 resamples). Each model runs at its own best threshold, chosen on the calibration abstracts before testing. At the same threshold, 0.5, the scores are 66.81 for this model and 45.09 before fine-tuning.
The OpenMed GLiNER2.5 Small models
Same base model, same MedMentions source, one label each, each scored on its own held-out abstracts.
| Model | Finds | Prompt | Default threshold | F1 before fine-tuning | F1 |
|---|---|---|---|---|---|
| OpenMed GLiNER2.5 DrugChemical Small v1 (this model) | drugs and chemicals | chemical or drug |
0.4 | 45.09 | 67.43 |
| OpenMed GLiNER2.5 Anatomy Small v1 | anatomy | anatomy |
0.3 | 25.71 | 61.85 |
Examples
Real outputs of this model through the OpenMed SDK, with the quick-start settings (default threshold 0.4), on CPU. The sentences are synthetic, written in the style of PubMed abstracts for this card. Extracted spans are in bold with their scores.
- Pharmacology: Metformin0.97 lowered fasting glucose0.89 and insulin0.95 levels in obese mice fed a high-fat diet, without changing body weight.
- Oncology regimen: Patients with advanced non-small cell lung cancer received cisplatin0.97 plus pemetrexed0.94, followed by maintenance pembrolizumab0.97.
- Enzymes and receptors: Celecoxib0.96, a selective cyclooxygenase-2 inhibitor0.78, reduced prostaglandin E20.89 release from cultured synovial fibroblasts.
- Environmental exposure: Urinary bisphenol A0.96 and phthalate0.78 metabolites were measured in 312 pregnant women during the first trimester.
- Antibiotic susceptibility: All carbapenem-resistant Klebsiella pneumoniae isolates remained susceptible to colistin1.00 and tigecycline1.00.
- Neuropharmacology: Amphetamine0.96 increased dopamine0.85 release in the striatum, and pretreatment with the D2 receptor antagonist0.57 haloperidol0.79 blocked the effect.
- Supplements: Daily vitamin D30.94 and omega-3 fatty acid0.92 supplementation did not change serum calcium0.86 or parathyroid hormone0.92 concentrations.
- Abbreviations: Serum IL-60.94 and TNF-alpha0.95 fell after 12 weeks of MTX0.79 combined with HCQ0.87.
- Dose and route: Patients received intravenous vancomycin0.93 15 mg/kg every 12 hours for 14 days.
- No chemicals: Participants completed questionnaires on sleep quality, mood and daily physical activity at baseline and at six months. (nothing extracted)
A longer abstract (939 characters, 16 spans) in one analyze_text call:
BACKGROUND: Statins lower low-density lipoprotein cholesterol, but their effect on hepatic steatosis is uncertain.
METHODS: In this randomized trial, 240 adults with nonalcoholic fatty liver disease received atorvastatin, ezetimibe or placebo for 24 weeks. Liver fat was measured by magnetic resonance imaging, and serum alanine aminotransferase, triglycerides and high-sensitivity C-reactive protein were assessed at baseline and at the end of treatment.
RESULTS: Atorvastatin reduced LDL cholesterol by 41% and alanine aminotransferase by 18%, whereas ezetimibe had no significant effect on liver fat. Combined treatment with atorvastatin and ezetimibe lowered triglycerides more than either drug alone. Myalgia was reported by six patients in the atorvastatin group, and no case of rhabdomyolysis occurred.
CONCLUSIONS: Atorvastatin, alone or with ezetimibe, improved lipid and liver enzyme profiles in nonalcoholic fatty liver disease.
Good to know
- Molecules made by the body are chemicals under the UMLS definition it was trained on: glucose and insulin (example 1), dopamine (example 6), IL-6 and TNF-alpha (example 8).
- Enzymes and receptors come back too, here inside drug-class phrases: cyclooxygenase-2 inhibitor (example 3) and D2 receptor antagonist (example 6).
- Abbreviations work: MTX and HCQ in example 8.
- It finds the drug, not the dose: example 9 returns vancomycin and nothing for intravenous or 15 mg/kg. Example 10, with no chemicals, returns nothing.
- It can miss a mention: LDL cholesterol in the longer abstract, where it finds low-density lipoprotein cholesterol.
Limitations
- Trained and tested on English PubMed abstracts (MedMentions). It has not been validated on hospital notes or other clinical text; the examples above are synthetic.
- One broad label from the UMLS Chemicals & Drugs group, which covers drugs and also proteins, enzymes, receptors, hormones and other biomolecules. It does not tell them apart.
- It finds mentions only. It is not a medication-event, dosing or drug-interaction model: it returns no doses, routes or frequencies, and does not say whether a drug was given.
- No normalization: spans are not mapped to RxNorm, ChEBI or UMLS codes.
- Scores rank spans; they are not calibrated probabilities.
- The base model's pretraining data is not public, so whether it saw these abstracts is unknown.
- It finds text spans. It does not give medical advice and is not a medical device.
Built on
OpenMed fine-tuned this model from fastino/gliner2.5-small-v1 by Fastino (Apache-2.0), built with the open-source GLiNER2 library. Training and evaluation data: the MedMentions corpus of PubMed abstracts annotated with UMLS concepts by Mohan and Li (2019, CC0); mentions of the UMLS Chemicals & Drugs semantic group were mapped to one label. Thank you to Fastino and to the MedMentions authors for releasing their work openly.
This model is released under Apache-2.0. No corpus text, UMLS concept IDs or terminology files are included in this repository.
Citation
@misc{panahi2025openmedner,
title={OpenMed NER: Open-Source, Domain-Adapted State-of-the-Art Transformers for Biomedical NER Across 12 Public Datasets},
author={Maziyar Panahi},
year={2025},
eprint={2508.01630},
archivePrefix={arXiv}
}
@inproceedings{mohan2019medmentions,
title={MedMentions: A Large Biomedical Corpus Annotated with {UMLS} Concepts},
author={Mohan, Sunil and Li, Donghui},
booktitle={Proceedings of the 2019 Conference on Automated Knowledge Base Construction (AKBC)},
year={2019}
}
@misc{zaratiana2025gliner2,
title={GLiNER2: An Efficient Multi-Task Information Extraction System with Schema-Driven Interface},
author={Urchade Zaratiana and Gil Pasternak and Oliver Boyd and George Hurn-Maloney and Ash Lewis},
year={2025},
eprint={2507.18546},
archivePrefix={arXiv}
}
OpenMed · Hugging Face · GitHub · PyPI · X
- Downloads last month
- 30
Model tree for OpenMed/GLiNER2.5-DrugChemical-Small-v1
Base model
fastino/gliner2.5-small-v1Dataset used to train OpenMed/GLiNER2.5-DrugChemical-Small-v1
Papers for OpenMed/GLiNER2.5-DrugChemical-Small-v1
OpenMed NER: Open-Source, Domain-Adapted State-of-the-Art Transformers for Biomedical NER Across 12 Public Datasets
GLiNER2: An Efficient Multi-Task Information Extraction System with Schema-Driven Interface
Article mentioning OpenMed/GLiNER2.5-DrugChemical-Small-v1
Evaluation results
- F1 (exact span, threshold 0.4) on MedMentions (200 held-out abstracts)self-reported67.430