Views
No views yet
fill-mask: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.FillMaskPipelinetransformers library starting from v4.48.0:pip install -U transformers>=4.48.0fill-mask pipeline or load it via AutoModelForMaskedLM. To use BioClinical ModernBERT for downstream tasks like classification, retrieval, or QA, fine-tune it following standard BERT fine-tuning recipes.pip install flash-attnAutoModelForMaskedLM:1from transformers import AutoTokenizer, AutoModelForMaskedLM
2model_id = "thomas-sounack/BioClinical-ModernBERT-large"
3tokenizer = AutoTokenizer.from_pretrained(model_id)
4model = AutoModelForMaskedLM.from_pretrained(model_id)
5text = "Mitochondria is the powerhouse of the [MASK]."
6inputs = tokenizer(text, return_tensors="pt")
7outputs = model(**inputs)
8# To get predictions for the mask:
9masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
10predicted_token_id = outputs.logits[0, masked_index].argmax(axis=-1)
11predicted_token = tokenizer.decode(predicted_token_id)
12print("Predicted token:", predicted_token)
13# Predicted token: cell1import torch
2from transformers import pipeline
3from pprint import pprint
4pipe = pipeline(
5 "fill-mask",
6 model="thomas-sounack/BioClinical-ModernBERT-large",
7 torch_dtype=torch.bfloat16,
8)
9input_text = "[MASK] is a disease caused by an uncontrolled division of abnormal cells in a part of the body."
10results = pipe(input_text)
11pprint(results)token_type_ids parameter.| Name | Country | Clinical Source | Clinical Context | Samples | Tokens (M) |
|---|---|---|---|---|---|
| ACI-BENCH | US | Clinical Notes | Not Reported | 207 | 0.1 |
| ADE Corpus | Several | Clinical Notes | Not Reported | 20,896 | 0.5 |
| Brain MRI Stroke | Korea | Radiology Reports | Neurology | 2,603 | 0.2 |
| CheXpert Plus | US | Radiology Reports | Pulmonology | 223,460 | 60.6 |
| CHIFIR | Australia | Pathology Reports | Hematology / Oncology | 283 | 0.1 |
| CORAL | US | Progress Notes | Hematology / Oncology | 240 | 0.7 |
| Eye Gaze CXR | US | Radiology Reports | Pulmonology | 892 | 0.03 |
| Gout Chief Complaints | US | Chief Complaint | Internal Medicine | 8,429 | 0.2 |
| ID-68 | UK | Clinical Notes | Psychology | 78 | 0.02 |
| Inspect | US | Radiology Reports | Pulmonology | 22,259 | 2.8 |
| MedNLI | US | Clinical Notes | Internal Medicine | 14,047 | 0.5 |
| MedQA | US | National Medical Board Examination | Not Reported | 14,366 | 2.0 |
| MIMIC-III | US | Clinical Notes | Internal Medicine | 2,021,411 | 1,047.7 |
| MIMIC-IV Note | US | Clinical Notes | Internal Medicine | 2,631,243 | 1,765.7 |
| MTSamples | Not Reported | Clinical Notes | Internal Medicine | 2,358 | 1.7 |
| Negex | US | Discharge Summaries | Not Reported | 2,056 | 0.1 |
| PriMock57 | UK | Simulated Patient Care | Internal Medicine | 57 | 0.01 |
| Q-Pain | US | Clinical Vignettes | Palliative Care | 51 | 0.01 |
| REFLACX | US | Radiology Reports | Pulmonology | 2,543 | 0.1 |
| Simulated Resp. Interviews | Canada | Simulated Patient Care | Pulmonology | 272 | 0.6 |
| Model | Context Length | ChemProt | Phenotype | COS | Social History | DEID | |
|---|---|---|---|---|---|---|---|
| Base | BioBERT | 512 | 89.5 | 26.6 | 94.9 | 55.8 | 74.3 |
| Clinical BERT | 512 | 88.3 | 25.8 | 95.0 | 55.2 | 74.2 | |
| BioMed-RoBERTa | 512 | 89.0 | 36.8 | 94.9 | 55.2 | 81.1 | |
| Clinical-BigBird | 4096 | 87.4 | 26.5 | 94.0 | 53.3 | 71.2 | |
| Clinical-Longformer | 4096 | 74.2 | 46.4 | 95.2 | 56.8 | 82.3 | |
| Clinical ModernBERT | 8192 | 86.9 | 54.9 | 93.7 | 53.8 | 44.4 | |
| ModernBERT - base | 8192 | 89.5 | 48.4 | 94.0 | 53.1 | 78.3 | |
| BioClinical ModernBERT - base | 8192 | 89.9 | 58.1 | 95.1 | 58.5 | 82.7 | |
| Large | ModernBERT - large | 8192 | 90.2 | 58.3 | 94.4 | 54.8 | 82.1 |
| BioClinical ModernBERT - large | 8192 | 90.8 | 60.8 | 95.1 | 57.1 | 83.8 |
@misc{sounack2025bioclinicalmodernbertstateoftheartlongcontext,
title={BioClinical ModernBERT: A State-of-the-Art Long-Context Encoder for Biomedical and Clinical NLP},
author={Thomas Sounack and Joshua Davis and Brigitte Durieux and Antoine Chaffin and Tom J. Pollard and Eric Lehman and Alistair E. W. Johnson and Matthew McDermott and Tristan Naumann and Charlotta Lindvall},
year={2025},
eprint={2506.10896},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2506.10896},
}