One token-classification model that tags six entity types in English biomedical text in a single pass: Gene (genes and gene products), Chemical, Disease (including phenotypic features, following BioRED), Species, Variant (sequence variants) and CellLine. 108.9M parameters, fine-tuned from microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext on four public corpora. ONNX (fp32 and int8) files are included, and the int8 model runs in the browser with transformers.js.
Need it smaller or faster? quorumbio/biomedical-ner-gene-chemical-disease-species-small is a 6-layer distilled version (66.8 MB int8, about 2x faster on CPU, about 0.01 to 0.02 F1 lower).
Companion to quorumbio/biomedical-ner-chemical-disease (Chemical and Disease only). On the same pipeline it scores about the same on BC5CDR and somewhat lower on NCBI-disease, and adds four types; see the comparison below. If you only need chemicals and diseases, compare both on your own text.
from transformers import pipeline
ner = pipeline("token-classification", model="quorumbio/biomedical-ner-gene-chemical-disease-species", aggregation_strategy="simple")
ner("The BRCA1 c.68_69delAG mutation was found in HeLa cells and in mice with breast cancer that were treated with tamoxifen.")
ONNX: onnx/model.onnx (fp32, 435.9 MB) and onnx/model_quantized.onnx (dynamic int8, 109.7 MB); inputs input_ids, attention_mask, token_type_ids, output logits (13 labels: O and B-/I- for each type).
The four corpora annotate different subsets of the six types (table below). A plain tagger would learn that, say, every gene in a BC5CDR sentence is "not an entity", because BC5CDR does not label genes. We use a partial-label loss instead: a word tagged O in a corpus is only taken to mean "none of this corpus's types", so the loss sums the probability of O and of every label of a type that corpus does not annotate. Words with a real tag must get exactly that tag. The result is still a standard token-classification model.
We compared this with the plain objective (every O is O), same data and settings. Selection was on validation (mean entity F1 over the four validation sets: partial-label 0.894, plain 0.869). Test F1 for both:
| Test set | Partial-label (released) | Plain objective |
|---|---|---|
| BC5CDR | 0.889 | 0.883 |
| NCBI-disease | 0.867 | 0.883 |
| NLM-Gene | 0.933 | 0.922 |
| BioRED | 0.898 | 0.799 |
The plain objective loses mostly recall on BioRED, the only corpus with all six types. It did better on NCBI-disease test; we report that rather than hide it.
Entity-level precision / recall / F1 (seqeval, exact span and type) on words from a simple regex tokenizer, sentence-split input, through the transformers pipeline (aggregation_strategy="simple"). Each test set is scored only on the types its corpus annotates (other predicted types are dropped first), and test sets were scored once after the checkpoint was chosen on validation (epoch 5). Intervals are 95% bootstrap intervals over test abstracts (2000 resamples).
| Test set | Types scored | P / R / F1 | F1 95% interval |
|---|---|---|---|
| BC5CDR (500 abstracts) | Chemical, Disease | 0.872 / 0.905 / 0.888 | 0.879 to 0.898 |
| NCBI-disease (100 abstracts) | Disease | 0.846 / 0.884 / 0.865 | 0.840 to 0.888 |
| NLM-Gene (100 abstracts) | Gene | 0.930 / 0.935 / 0.933 | 0.920 to 0.944 |
| BioRED (100 abstracts) | Chemical, Disease, Gene, Species, Variant, CellLine | 0.892 / 0.905 / 0.898 | 0.881 to 0.916 |
BioRED test by type:
| Type | Mentions | P / R / F1 | F1 95% interval |
|---|---|---|---|
| Gene | 1180 | 0.915 / 0.908 / 0.912 | 0.888 to 0.934 |
| Chemical | 754 | 0.883 / 0.883 / 0.883 | 0.843 to 0.921 |
| Disease | 917 | 0.837 / 0.885 / 0.861 | 0.832 to 0.887 |
| Species | 393 | 0.960 / 0.972 / 0.966 | 0.946 to 0.983 |
| Variant | 241 | 0.902 / 0.921 / 0.912 | 0.857 to 0.954 |
| CellLine | 50 | 0.957 / 0.880 / 0.917 | 0.864 to 0.984 |
CellLine has few test mentions, so its interval is wide. These scores are not comparable to published BC5CDR, NCBI-disease, NLM-Gene or BioRED numbers, which use different tokenization, scoring and (for NLM-Gene and BioRED) sometimes normalization to identifiers.
Same pipeline and scoring; paired bootstrap over the same resampled abstracts:
| Test set | Types | This model F1 | v2 F1 | Difference (95% interval) |
|---|---|---|---|---|
| BC5CDR | Chemical, Disease | 0.888 | 0.889 | -0.001 (-0.006 to +0.005) |
| NCBI-disease | Disease | 0.865 | 0.878 | -0.013 (-0.032 to +0.005) |
On the Chemical and Disease mentions of BioRED test, which v2 was never trained on, this model scores 0.871 and v2 0.852; BioRED is in-domain for this model only, so this is not a fair head-to-head.
We retrained 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. Numbers are test entity F1 from the training script's own evaluation (same metric, different input path from the pipeline table, so values differ slightly).
| Test set | Mean ± SD | Range |
|---|---|---|
| BC5CDR | 0.889 ± 0.002 | 0.886 to 0.890 |
| NCBI-disease | 0.873 ± 0.004 | 0.867 to 0.877 |
| NLM-Gene | 0.930 ± 0.002 | 0.929 to 0.933 |
| BioRED | 0.901 ± 0.002 | 0.898 to 0.904 |
Per-seed values: seed_results.json.
| File | BC5CDR F1 | NCBI-disease F1 | NLM-Gene F1 | BioRED F1 | ms/sentence | Size |
|---|---|---|---|---|---|---|
| fp32 | 0.888 | 0.866 | 0.932 | 0.898 | 29.14 | 435.9 MB |
| int8 (dynamic quantization) | 0.887 | 0.865 | 0.932 | 0.897 | 16.48 | 109.7 MB |
fp32 ONNX vs PyTorch: max absolute logit difference 7.18e-05, token argmax agreement 1.0000 on 300 BioRED test sentences. (These use the training script's input path, so they differ slightly from the pipeline table.)
| Corpus | Types annotated | Train abstracts | Validation | Test | Removed from train / validation |
|---|---|---|---|---|---|
| BC5CDR | Chemical, Disease | 480 | 489 | 500 | 20 / 11 |
| NCBI-disease | Disease | 588 | 100 | 100 | 4 / 0 |
| NLM-Gene | Gene | 359 | 50 | 100 | 0 / 0 |
| BioRED | Chemical, Disease, Gene, Species, Variant, CellLine | 279 | 78 | 100 | 121 / 22 |
No test abstract is used for training. The corpora share many PubMed abstracts (for example, 121 BioRED training abstracts are also in other corpora's test or validation sets). We kept every test set exactly as published and removed from training and validation any abstract that appears in any test set, and from training any abstract in any validation set. NLM-Gene has no validation split, so 50 of its training abstracts were drawn at random (seed 13) before training. Label mapping: BioRED ChemicalEntity, DiseaseOrPhenotypicFeature, GeneOrGeneProduct, OrganismTaxon, SequenceVariant and CellLine map to the six types; NLM-Gene's Gene, GENERIF and STARGENE mentions map to Gene, and its Domain and Other mentions (protein domains, gene products used as drugs or tools, which its guidelines say not to annotate as genes) are ignored in training and scoring.
5 epochs, batch size 16, learning rate 5e-05, max length 256, bf16 autocast, AdamW with linear warmup/decay, one NVIDIA RTX 3060 (about 9 minutes). Reproduce: python training/prepare_data.py, python training/prepare_data3.py (after downloading BIORED.zip and NLM-Gene-Corpus.zip; URLs and hashes in training/data3_meta.json), then python training/train3.py --base microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext --out v3a.
Model weights: Apache-2.0. Base model: MIT (see NOTICE). Training data: NLM-Gene is CC0 1.0. BioRED is a US Government work with an NCBI public domain notice. NCBI-disease is distributed by NCBI under its public domain notice. BC5CDR: the distributors do not state an explicit license ("freely available for the research community"); BigBio lists it as Public Domain Mark 1.0. If you have strict compliance needs, review the corpus terms yourself. Please cite the corpora (references in NOTICE).
SHA256SUMS lists checksums for every file in this repo.
onnx/model.onnx 436 MBmodel.safetensors 436 MBonnx/model_quantized.onnx 110 MB