Token-classification model that tags Chemical and Disease mentions in English biomedical text. 108.9M parameters, fine-tuned from microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext on the BC5CDR and NCBI-disease training sets. ONNX (fp32 and int8) files are included.
Version note. This is v2 (trained on BC5CDR + NCBI-disease). v1 (BC5CDR only) is kept as the git revision v1.0 of this repo.
Need genes, species, variants or cell lines too? See quorumbio/biomedical-ner-gene-chemical-disease-species, which tags six types in one pass and scores about the same as this model on BC5CDR (slightly lower on NCBI-disease).
from transformers import pipeline
ner = pipeline("token-classification", model="quorumbio/biomedical-ner-chemical-disease", aggregation_strategy="simple")
ner("Naloxone reverses the antihypertensive effect of clonidine.")
ONNX: onnx/model.onnx (fp32, 435.8 MB) and onnx/model_quantized.onnx (dynamic int8, 109.7 MB), inputs input_ids, attention_mask, token_type_ids, output logits. Tokenize with the tokenizer in this repo.
Entity-level precision / recall / F1 (seqeval) on words from a simple regex tokenizer, sentence-split input, test splits scored once. The checkpoint was chosen on the validation sets (best mean validation entity F1 across the two corpora, epoch 5). The released checkpoint is seed 13; seed variation is measured below.
| Test set | Entity types scored | P / R / F1 | v1 (BC5CDR only) F1 |
|---|---|---|---|
| BC5CDR (500 abstracts) | Chemical, Disease | 0.881 / 0.897 / 0.889 | 0.896 |
| NCBI-disease (100 abstracts) | Disease | 0.859 / 0.898 / 0.878 | 0.735 (never trained on this corpus) |
BC5CDR per type (P / R / F1): Chemical 0.927 / 0.916 / 0.922; Disease 0.828 / 0.875 / 0.850.
NCBI-disease annotates Disease only, so on that test set predicted Chemical mentions are dropped before scoring. Adding NCBI-disease to training lowered BC5CDR F1 slightly (v1, a single seed: 0.896; v2 over 5 seeds: 0.889 ± 0.002, so the drop looks real but small) and raised NCBI-disease F1 a lot, which is expected since it is now in-domain. We also tried ignoring O labels for NCBI sentences (to avoid penalizing unlabeled chemicals); that variant collapsed precision on NCBI-disease (F1 0.427) and was discarded.
We retrained v2 with the same data and settings using 4 more seeds (1, 2, 3, 4), chosen before training. All 5 runs (with the released seed 13) are reported, none dropped. Numbers are test entity F1 from the training script's own evaluation: same seqeval metric, but a different input path from the pipeline-based table above, which is why seed 13 shows 0.870 on NCBI-disease here and 0.878 there.
| Test set | Mean ± SD | Range |
|---|---|---|
| BC5CDR | 0.889 ± 0.002 | 0.887 to 0.891 |
| NCBI-disease | 0.872 ± 0.002 | 0.870 to 0.875 |
The released checkpoint is typical, not a lucky seed. These intervals cover training randomness only, not uncertainty from the small test sets (NCBI-disease test has 100 abstracts). Per-seed values: seed_results.json.
The seed variation above covers training randomness only. To show how much the test sets limit precision, we bootstrapped whole test abstracts, with 2000 resamples, for the released checkpoint on the pipeline path of the main table. 95% percentile intervals for entity F1:
| Test set | F1 | 95% interval |
|---|---|---|
| BC5CDR (500 abstracts), all types | 0.889 | 0.879 to 0.898 |
| BC5CDR, Chemical | 0.922 | 0.909 to 0.934 |
| BC5CDR, Disease | 0.850 | 0.836 to 0.863 |
| NCBI-disease (100 abstracts), Disease | 0.878 | 0.851 to 0.904 |
v1 vs v2 on BC5CDR, paired on the same resampled abstracts: v2 minus v1 F1 = -0.0069 (95% interval -0.0121 to -0.0020). v2 scored lower in 99.5% of resamples, so the drop is small but consistent. Details: bootstrap_ci.json; script: training/bootstrap_ner.py.
| Runtime check (ONNX via onnxruntime, CPU) | BC5CDR F1 | NCBI-disease F1 | ms/sentence | Size |
|---|---|---|---|---|
| fp32 | 0.889 | 0.878 | 24.47 | 435.8 MB |
| int8 (dynamic quantization) | 0.886 | 0.879 | 13.63 | 109.7 MB |
fp32 ONNX vs PyTorch: max absolute logit difference 3.43e-05, token argmax agreement 1.0000 on 300 BC5CDR sentences.
d4data/biomedical-ner-allWe ran d4data/biomedical-ner-all through the same pipeline and scoring (the v1 numbers below are from that run; v2 is in the table above). It is a general clinical model with 84 entity types that was not trained on either corpus, so its labels do not line up and we mapped them ourselves, which affects its score. Strict mapping (Disease_disorder to Disease, Medication to Chemical): BC5CDR F1 0.479 (P 0.629, R 0.386); NCBI-disease Disease F1 0.377 (P 0.502, R 0.302). Generous mapping (also Sign_symptom to Disease): BC5CDR F1 0.533; NCBI-disease F1 0.329. Our model was trained on these corpora's training splits, so this is an in-domain versus out-of-domain comparison, not evidence that our model is better in general. d4data/biomedical-ner-all (66.4M parameters) is smaller and ran faster than this model in our GPU test (13.7 s vs 17.2 s for 4821 BC5CDR sentences). Its coverage of other entity types (symptoms, procedures, doses and more) is far broader than ours.
These scores are not directly comparable to published BC5CDR or NCBI-disease numbers, which use different tokenization and scoring.
training/ has the scripts and provenance.json (source URLs and SHA256). 5 epochs, batch size 16, learning rate 5e-05, max length 256, bf16 autocast, AdamW with linear warmup/decay, one NVIDIA RTX 3060 (about 5 minutes). Reproduce: python training/prepare_data.py then python training/train2.py --base microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext --out run2a (v1: train.py --corpus bc5cdr).
Model weights: Apache-2.0. Base model: MIT (see NOTICE). Training data: (1) BioCreative V CDR corpus (Li et al., 2016, Database baw068): the distributors do not state an explicit license on the BioCreative page or the public GitHub mirror ("freely available for the research community"); BigBio lists it as Public Domain Mark 1.0. (2) NCBI Disease corpus (Dogan et al., 2014): distributed by NCBI under its public domain notice. If you have strict compliance needs, review the corpus terms yourself.
SHA256SUMS lists checksums for every file in this repo.
onnx/model.onnx 436 MBmodel.safetensors 436 MBonnx/model_quantized.onnx 110 MBmicrosoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext