Downloads · 30 days
61
36% of all-time downloads
doctolib-lab/doctomodernbert-fr-large
doctomodernbert-fr-large is a fill-mask model from doctolib-lab. Use it when you need the model to fill a missing word. It is set up for transformers. The card lists the license as apache-2.0.
<center <img src="assets/logodoctomodernbert.png" width="100%" alt="DoctoModernBERT" </center
Downloads · 30 days
61
36% of all-time downloads
All-time downloads
170
Public
Parameters
396M
1.6 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors1.6 GB · 98%
From the Hugging Face model README
DoctoModernBERT-fr-large is the large-size French medical encoder in the DoctoBERT family, for biomedical and clinical NLP. It uses the ModernBERT architecture (395M parameters, up to 8192-token context) and is pretrained from scratch on FineMed-fr and FineMed-rephrased-fr.
Its training data is curated from heterogeneous open web corpora (FineWeb-2, FinePDFs, FineWiki), which bring scale, source and stylistic diversity, and inherited quality control. Each document is annotated along three axes: subdomain, educational quality, and medical-term density. DoctoModernBERT then trains on a mix of two parts: the filtered high-quality, entity-rich documents, and LLM-rephrased variants that raise medical-term density and vary the contexts around medical terms across many genres, audiences, and registers. This breadth and density build robustness to real-world clinical text, which is often noisy and inconsistent in style.
For the base-size version, see DoctoModernBERT-fr-base. For a classic RoBERTa encoder, see DoctoBERT-fr-base.
Requires a recent transformers with ModernBERT support.
Using AutoModelForMaskedLM:
from transformers import AutoTokenizer, AutoModelForMaskedLM
model_id = "doctolib-lab/doctomodernbert-fr-large"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForMaskedLM.from_pretrained(model_id)
text = f"Le patient souffre d'une {tokenizer.mask_token} aiguë."
inputs = tokenizer(text, return_tensors="pt")
logits = model(**inputs).logits
masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
print(tokenizer.decode(logits[0, masked_index].argmax(-1)))
Using a pipeline:
from transformers import pipeline
fill = pipeline("fill-mask", model="doctolib-lab/doctomodernbert-fr-large")
print(fill(f"Le patient souffre d'une {fill.tokenizer.mask_token} aiguë."))
For long inputs, load with attn_implementation="flash_attention_2" for faster, more memory-efficient attention.
DoctoModernBERT fine-tunes like any BERT/ModernBERT encoder, with the appropriate task head or framework:
AutoModelForSequenceClassification (see the text-classification guide).AutoModelForTokenClassification (see the token-classification guide).| Property | Value |
|---|---|
| Architecture | ModernBERT |
| Parameters | 395M total (343M backbone, 52M embeddings) |
| Layers | 28 |
| Hidden size | 1024 |
| Attention heads | 16 |
| MLP | GeGLU |
| Intermediate size | 2624 |
| Context window | 8192 tokens |
| Vocabulary size | 50,368 |
| Language | French |
The tokenizer is a SentencePiece BPE model of 50,368 tokens, trained on the entity-rich FineMed-filtered subset (educational quality >= 4 and medical-term density >= 0.1) for efficient tokenization of dense medical vocabulary. It splits digits into single tokens and uses byte fallback for unseen characters.
DoctoModernBERT-fr-large is pretrained from scratch on a mix of FineMed-filtered (FineMed-fr under the same educational-quality and medical-term-density filter) and FineMed-rephrased-fr, over three phases totaling 140B tokens:
DoctoModernBERT is an encoder for French biomedical and clinical NLP (NER, classification, retrieval, long-document tasks), used by fine-tuning on a downstream task. It is not generative and not a medical device; its outputs must not drive clinical decisions. It was pretrained on public web, PDF, and encyclopedic medical text and reflects the biases and gaps of those sources.
<!-- ## 📖 Citation ```bibtex @misc{doctobert2026, title = {Where Does the Signal Live? A Web Data Recipe for Medical Encoder Pretraining}, author = {Huang, Bofeng and Sun, Jacques and Bouchacourt, Diane and Barascud, Nicolas and Fogel, Fajwel}, year = {2026}, eprint = {2606.XXXXX}, archivePrefix = {arXiv}, primaryClass = {cs.CL} } ``` -->Released under Apache-2.0. DoctoModernBERT was trained on FineMed-fr and FineMed-rephrased-fr, which derive from FineWeb-2 / FinePDFs (ODC-BY 1.0) and FineWiki (CC BY-SA 4.0); please attribute those upstream sources.
This work was granted access to the HPC resources of IDRIS (Jean Zay) under the allocations 2025-AD011016291 and 2026-A0200617487 made by GENCI.