A smaller, faster version of quorumbio/biomedical-ner-gene-chemical-disease-species that tags the same six entity types (Gene, Chemical, Disease, Species, Variant, CellLine) in English biomedical text. 66.4M parameters (6 transformer layers instead of 12). The int8 ONNX file is 66.8 MB (full model: 109.7 MB) and ran at 8.61 ms per sentence on CPU in our test (full model: 16.48 ms). Mean validation F1 is 0.013 lower. Pick this one for browsers, CPUs and high volume; pick the full model when accuracy matters more.
from transformers import pipeline
ner = pipeline("token-classification", model="quorumbio/biomedical-ner-gene-chemical-disease-species-small", 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, 265.6 MB) and onnx/model_quantized.onnx (dynamic int8, 66.8 MB); inputs input_ids, attention_mask, token_type_ids, output logits (13 labels: O and B-/I- for each type).
Student: the full model with every other transformer layer kept (layers 2, 4, 6, 8, 10 and 12 of 12), so it starts from trained weights. It was then trained on the same data with the full model's partial-label loss (an O word in a corpus means "none of this corpus's types"), plus distillation from the full model: loss = 0.5 x partial-label loss + 0.5 x T^2 x KL(teacher || student), temperature T = 2, on the first subword of each word. Checkpoint chosen on validation (mean entity F1 over the four validation sets: 0.881; full model 0.894). Before training we set the rule that a small model would be released only if it stayed within 0.02 of the full model on that validation mean.
Test F1, same pipeline and scoring:
| Test set | This model | Full model | Difference |
|---|---|---|---|
| BC5CDR | 0.877 | 0.888 | -0.011 |
| NCBI-disease | 0.869 | 0.865 | +0.004 |
| NLM-Gene | 0.915 | 0.933 | -0.018 |
| BioRED | 0.882 | 0.898 | -0.016 |
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.860 / 0.895 / 0.877 | 0.867 to 0.887 |
| NCBI-disease (100 abstracts) | Disease | 0.850 / 0.887 / 0.869 | 0.845 to 0.891 |
| NLM-Gene (100 abstracts) | Gene | 0.905 / 0.925 / 0.915 | 0.896 to 0.930 |
| BioRED (100 abstracts) | Chemical, Disease, Gene, Species, Variant, CellLine | 0.873 / 0.892 / 0.882 | 0.864 to 0.901 |
BioRED test by type:
| Type | Mentions | P / R / F1 | F1 95% interval |
|---|---|---|---|
| Gene | 1180 | 0.891 / 0.892 / 0.891 | 0.864 to 0.917 |
| Chemical | 754 | 0.869 / 0.879 / 0.874 | 0.831 to 0.913 |
| Disease | 917 | 0.827 / 0.876 / 0.851 | 0.821 to 0.879 |
| Species | 393 | 0.962 / 0.967 / 0.964 | 0.941 to 0.984 |
| Variant | 241 | 0.841 / 0.876 / 0.858 | 0.779 to 0.919 |
| CellLine | 50 | 0.846 / 0.880 / 0.863 | 0.706 to 0.986 |
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 | Chemical/Disease model F1 | Difference (95% interval) |
|---|---|---|---|---|
| BC5CDR | Chemical, Disease | 0.877 | 0.889 | -0.012 (-0.018 to -0.006) |
| NCBI-disease | Disease | 0.869 | 0.878 | -0.009 (-0.025 to +0.007) |
We repeated the distillation with 4 more seeds (1, 2, 3, 4; same teacher), 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.878 ± 0.002 | 0.876 to 0.881 |
| NCBI-disease | 0.872 ± 0.005 | 0.867 to 0.880 |
| NLM-Gene | 0.912 ± 0.003 | 0.909 to 0.915 |
| BioRED | 0.884 ± 0.003 | 0.880 to 0.888 |
Per-seed values: seed_results.json.
| File | BC5CDR F1 | NCBI-disease F1 | NLM-Gene F1 | BioRED F1 | ms/sentence | Size |
|---|---|---|---|---|---|---|
| fp32 | 0.878 | 0.867 | 0.914 | 0.884 | 15.44 | 265.6 MB |
| int8 (dynamic quantization) | 0.877 | 0.873 | 0.913 | 0.883 | 8.61 | 66.8 MB |
fp32 ONNX vs PyTorch: max absolute logit difference 5.29e-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 train or download the full model and run python training/train3_distill.py --teacher <full model dir> --keep 1,3,5,7,9,11 --out v3S.
Model weights: Apache-2.0. Distilled from our Apache-2.0 full model, which is fine-tuned from an MIT base model (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 266 MBmodel.safetensors 266 MBonnx/model_quantized.onnx 67 MBquorumbio/biomedical-ner-gene-chemical-disease-species