Instructions to use CobuildX-AI/cbx-clinical-entity-extractor-17M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CobuildX-AI/cbx-clinical-entity-extractor-17M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="CobuildX-AI/cbx-clinical-entity-extractor-17M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("CobuildX-AI/cbx-clinical-entity-extractor-17M") model = AutoModelForMaskedLM.from_pretrained("CobuildX-AI/cbx-clinical-entity-extractor-17M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
cbx-clinical-entity-extractor-17M
Extracts clinical entities from English clinical narrative text such as case reports: signs and symptoms, diseases, diagnostic and therapeutic procedures, lab values, medications and doses, anatomy, dates, durations and more: the 41 entity types of MACCROBAT2020. Fine-tuned from Ettin encoder 17m (16.8M parameters). 0.547 exact-match F1 and 0.685 overlap F1 on our MACCROBAT2020 test split; about 24 ms per ~700-token document on a CPU.
Current version: v0.1 (use revision="v0.1" to pin it). Also available in
68M.
Licence: CC BY-NC 4.0, non-commercial use only (see Licence). Not a medical device; not for diagnosis or treatment decisions (see Intended use and disclaimer).
Quick start
pip install -r requirements.txt
python example.py
from cbx_clinical import ClinicalEntityExtractor
ner = ClinicalEntityExtractor(".") # folder with the model files (or a snapshot_download path)
ner.extract("A 47-year-old woman presented with fever and right upper quadrant pain.")
# [{'label': 'Age', 'start': 2, 'end': 13, 'text': '47-year-old'},
# {'label': 'Sex', ...}, {'label': 'Clinical_event', ...}, {'label': 'Sign_symptom', ...}, ...]
To download: huggingface_hub.snapshot_download("CobuildX-AI/cbx-clinical-entity-extractor-17M", revision="v0.1"), then pass that folder.
Input. Plain text; one document or note at a time. Up to 2,046 tokens in one pass (about 9,000 characters); longer texts are tagged in overlapping windows. Output. A flat list of spans with character offsets, one label each (spans do not overlap).
Entity types (41)
| Group | Labels |
|---|---|
| Findings and conditions | Sign_symptom, Disease_disorder, History, Family_history, Outcome |
| Procedures and tests | Diagnostic_procedure, Therapeutic_procedure, Lab_value |
| Medication | Medication, Dosage, Administration, Frequency |
| Anatomy and description | Biological_structure, Detailed_description, Severity, Biological_attribute, Shape, Color, Texture |
| Measurements | Distance, Area, Volume, Mass, Height, Weight, Quantitative_concept, Qualitative_concept |
| Time and events | Date, Time, Duration, Clinical_event, Activity, Other_event |
| People and places | Age, Sex, Occupation, Personal_background, Subject, Nonbiological_location |
| Other | Coreference, Other_entity |
Spans follow MACCROBAT's conventions: short, atomic spans ("severe" Severity + "chest" Biological_structure +
"pain" Sign_symptom); a test and its result are separate entities ("troponin" Diagnostic_procedure, "elevated"
Lab_value).
Evaluation
MACCROBAT2020 has no official split. We split its 200 documents into 140 train / 30 validation / 30 test documents (iterative stratification by label, seed 42) and report the test split (30 documents, 4,128 entities), scored once. Exact = start, end and label all match; overlap = same label and overlapping characters (one-to-one). All annotated entities are scored, including nested ones the model cannot output (a perfect flat tagger would reach about 0.985 exact F1).
| Model | Exact F1 | Precision | Recall | Overlap F1 | Macro F1 (labels with โฅ 10 test entities) |
|---|---|---|---|---|---|
| cbx-clinical-entity-extractor-17M (this model) | 0.547 | 0.502 | 0.601 | 0.685 | 0.476 |
| cbx-clinical-entity-extractor-68M | 0.622 | 0.585 | 0.663 | 0.757 | 0.540 |
| CRF (word features), trained by us on the same 140 documents | 0.538 | 0.571 | 0.508 | 0.664 | 0.482 |
| gpt-5.4-mini, zero-shot (annotation guide, reasoning low) | 0.512 | 0.524 | 0.500 | 0.642 | 0.501 |
| gpt-5.4-mini, few-shot (guide + 2 annotated training documents) | 0.505 | 0.499 | 0.512 | 0.651 | 0.479 |
| GLiNER-BioMed large v1.0, zero-shot | 0.319 | 0.352 | 0.291 | 0.412 | 0.306 |
- 95% bootstrap interval (by document) of this model's exact F1: 0.502โ0.587. Validation split exact F1: 0.550.
- The CRF, gpt-5.4-mini and GLiNER-BioMed rows were run by us on the same test split. gpt-5.4-mini was given an annotation guide with all 41 labels and MACCROBAT's span conventions, one call per document. GLiNER-BioMed was given the 41 labels as plain-English names; its threshold was chosen on the validation split.
- Most remaining errors are span boundaries (overlap F1 is well above exact F1), and the long-modifier and
history labels (
Detailed_description,History,Family_history,Coreference).
Per-label exact F1 on the test split (labels with at least 10 test entities):
| Label | Test entities | Exact F1 |
|---|---|---|
| Diagnostic_procedure | 772 | 0.65 |
| Sign_symptom | 562 | 0.60 |
| Biological_structure | 507 | 0.62 |
| Lab_value | 478 | 0.65 |
| Detailed_description | 449 | 0.31 |
| Medication | 200 | 0.69 |
| Disease_disorder | 199 | 0.41 |
| Therapeutic_procedure | 163 | 0.38 |
| Date | 133 | 0.57 |
| Clinical_event | 88 | 0.62 |
| History | 66 | 0.23 |
| Dosage | 60 | 0.57 |
| Severity | 59 | 0.66 |
| Nonbiological_location | 51 | 0.66 |
| Coreference | 44 | 0.13 |
| Duration | 44 | 0.43 |
| Age | 30 | 0.94 |
| Sex | 28 | 0.98 |
| Administration | 26 | 0.64 |
| Distance | 21 | 0.53 |
| Activity | 19 | 0.00 |
| Family_history | 18 | 0.08 |
| Time | 18 | 0.23 |
| Subject | 15 | 0.19 |
| Frequency | 12 | 0.13 |
Labels with fewer than 10 test entities (for example Mass, Height, Weight, Biological_attribute) are too
rare in MACCROBAT to measure or learn reliably.
Speed
One document, median of 20 runs (tokenise + model + decode):
| ~700 tokens | ~1,840 tokens | |
|---|---|---|
| CPU, 8 threads | 24 ms | 100 ms |
| GPU (NVIDIA TITAN RTX) | 7 ms | 10 ms |
Training
- Data: MACCROBAT2020 (Caufield, J. Harry (2019). MACCROBAT. figshare. Dataset. MACCROBAT2020 release (version 2). https://doi.org/10.6084/m9.figshare.9764942.v2; CC BY 4.0): 200 PubMed Central clinical case reports annotated by hand with 41 entity types. Training used the 140 training documents (17,113 entities). Overlapping annotations (1.8%) were reduced to the longest span for training; discontinuous ones were split into fragments.
- Model: Ettin encoder with a linear BIO tagging layer (83 tags), whole documents up to 2,048 tokens, fp16 mixed precision; learning rate and checkpoint chosen on the validation split.
Limitations
- Small training set (140 documents of one genre: published case reports). Expect lower accuracy on other clinical text such as EHR notes, discharge summaries, abbreviations-heavy notes or non-English text.
- Flat output: one label per span, no nested or discontinuous spans, no relations, no negation or uncertainty
attributes (in "no fever", "fever" is returned as
Sign_symptom; the negation is not marked). - Tag one document per call. Predictions depend on the surrounding text: when we joined four unrelated documents into one input, about 20% of the predicted spans changed compared with tagging each document alone. Texts longer than 2,046 tokens are split into overlapping windows, which also shifts a few predictions.
- Rare labels (fewer than about 30 training examples) are unreliable.
- Not tested for fairness across patient groups; may reflect biases of the published case-report literature.
Intended use and disclaimer
- Intended for research and non-commercial information extraction from clinical narrative text, for example structuring case reports or building research datasets, with human review of the output.
- Not a medical device. Not for diagnosis, treatment, triage or any clinical decision. Outputs can be wrong or incomplete and must be checked by a qualified person before any use that could affect a patient.
- Do not process identifiable patient data unless you have a lawful basis and appropriate safeguards; the model does not de-identify text.
- Provided "as is", without warranty; Cobuild Tech Private Limited accepts no responsibility for how it is used.
Licence
CC BY-NC 4.0 (LICENSE): you may use, share and adapt this model for non-commercial purposes, with
attribution. MACCROBAT2020 itself is released under CC BY 4.0, but its text comes from PubMed Central case reports
whose own licences vary, and many of them are non-commercial or carry no open licence; we therefore release the
model for non-commercial use only. Third-party notices (Ettin: MIT; MACCROBAT2020: CC BY 4.0) are in NOTICE.
Citation
If you use this model, please cite the dataset:
Caufield, J. Harry (2019). MACCROBAT. figshare. Dataset. MACCROBAT2020 release (version 2). https://doi.org/10.6084/m9.figshare.9764942.v2
and the base model, Ettin encoder 17m (see its model card for the citation).
Files
model.safetensors (weights), config.json (Ettin backbone configuration), tokenizer.json,
tokenizer_config.json, cner_config.json (labels and tags), cbx_clinical.py (loader), example.py,
requirements.txt, LICENSE, NOTICE, checksums.sha256.
- Downloads last month
- 31
Model tree for CobuildX-AI/cbx-clinical-entity-extractor-17M
Base model
jhu-clsp/ettin-encoder-17m