Downloads · 30 days
595
2% of all-time downloads
microsoft/MediPhi-Clinical
MediPhi-Clinical is a text generation model from microsoft. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
The MediPhi Model Collection comprises 7 small language models of 3.8B parameters from the base model Phi-3.5-mini-instruct specialized in the medical and clinical domains. The collection is designed in a modular fash…
Downloads · 30 days
595
2% of all-time downloads
All-time downloads
32.6K
Public
Parameters
3.8B
7.6 GB on disk
Likes
17
Public
Click a slice to open those files.
.safetensors7.6 GB · 100%
From the Hugging Face model README
The MediPhi Model Collection comprises 7 small language models of 3.8B parameters from the base model Phi-3.5-mini-instruct specialized in the medical and clinical domains. The collection is designed in a modular fashion. Five MediPhi experts are fine-tuned on various medical corpora (i.e. PubMed commercial, Medical Wikipedia, Medical Guidelines, Medical Coding, and open-source clinical documents) and merged back with the SLERP method in their base model to conserve general abilities. One model combined all five experts into one general expert with the multi-model merging method BreadCrumbs. Finally, we clinically aligned this general expert using our large-scale MediFlow corpora (see dataset microsoft/mediflow) to obtain the final expert model MediPhi-Instruct.
This model is MediPhi-Clinical obtained by merging the fine-tuned Clinical expert with the SLERP technique into its base model at 25%.
microsoft/Phi-3.5-mini-instructThe model is intended for research use in English, especially clinical natural language processing. The model provides uses for research which require:
Our model is designed to accelerate research on language models in medical and clinical scenarios. It should be used for research purposes, i.e., in benchmarking context or with expert user verification of the outputs.
Our models are not specifically designed or evaluated for all downstream purposes. Researchers (or developers) should consider common limitations of language models as they select use cases, and evaluate and mitigate for accuracy, safety, and fariness before using within a specific downstream use case, particularly for high risk scenarios. Researchers (or developers) should be aware of and adhere to applicable laws or regulations (including privacy, trade compliance laws, etc.) that are relevant to their use case.
Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.
Like other language models, the Phi family of models and the MediPhi collection can potentially behave in ways that are unfair, unreliable, or offensive. Some of the limiting behaviors to be aware of include:
Researchers should apply responsible AI best practices, including mapping, measuring, and mitigating risks associated with their specific use case and cultural, linguistic context. They are encouraged to rigorously evaluate the model for their use case, fine-tune the models when possible and leverage the models as part of broader AI systems with language-specific safeguards in place. Important areas for consideration include:
<|system|>
GIVE A ROLE AND INSTRUCTIONS FOR CLINICAL NLPTASKS<|end|>
<|user|>
INPUT DOCUMENT<|end|>
<|assistant|>
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
torch.random.manual_seed(0)
model_name = "microsoft/MediPhi-Clinical"
model = AutoModelForCausalLM.from_pretrained(
model_name,
device_map="cuda",
torch_dtype="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "Operative Report:\nPerformed: Cholecystectomy\nOperative Findings: The gallbladder contained multiple stones and had thickening of its wall. Mild peritoneal fluid was noted."
messages = [
{"role": "system", "content": "Extract medical keywords from this operative notes focus on anatomical, pathological, or procedural vocabulary."},
{"role": "user", "content": prompt},
]
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
)
generation_args = {
"max_new_tokens": 500,
"return_full_text": False,
"temperature": 0.0,
"do_sample": False,
}
output = pipe(messages, **generation_args)
print(output[0]['generated_text'])
# gallbladder stones, wall thickening, peritoneal fluid
Notes: If you want to use flash attention, call AutoModelForCausalLM.from_pretrained() with attn_implementation="flash_attention_2".
Check microsoft/Phi-3.5-mini-instruct for details about the tokenizer, requirements and basic capabilities.
Continual Pre-training:
zhengyun21/PMC-Patients, akemiH/NoteChat, and starmpcc/Asclepius-Synthetic-Clinical-Notes (only commercial-friendly licenses across all three datasets)See paper for details.
Modular training making five experts from the base model with pre-instruction tuning, merging them into one model and finally clinically aligning it. See paper for details.
| Phi-3.5-mini-instruct | PubMed | Clinical | MedWiki | Guideline | MedCode | MediPhi | MediPhi-Instruct | |
|---|---|---|---|---|---|---|---|---|
| MedNLI | 66.6 | 68.3 | 69.2 | 72.8 | 70.3 | 68.5 | 66.9 | 71.0 |
| PLS | 28.4 | 29.2 | 29.4 | 29.2 | 29.8 | 22.3 | 28.8 | 26.0 |
| MeQSum | 36.7 | 37.6 | 38.1 | 37.6 | 37.6 | 33.5 | 37.9 | 42.8 |
| LH | 45.9 | 45.7 | 43.5 | 43.6 | 41.1 | 45.7 | 45.7 | 45.0 |
| MeDiSumQA | 25.9 | 26.3 | 26.7 | 25.1 | 25.1 | 23.6 | 26.1 | 29.1 |
| MeDiSumCode | 41.1 | 41.0 | 40.5 | 41.7 | 41.9 | 39.0 | 41.7 | 37.2 |
| RRS QA | 41.2 | 44.1 | 52.1 | 46.7 | 48.9 | 45.6 | 44.5 | 61.6 |
| MedicationQA | 11.2 | 10.3 | 12.0 | 12.2 | 11.9 | 12.0 | 11.3 | 19.3 |
| MEDEC | 14.8 | 22.2 | 34.5 | 28.8 | 28.3 | 18.1 | 29.1 | 34.4 |
| ACI | 42.3 | 42.7 | 43.9 | 44.7 | 44.7 | 39.0 | 44.3 | 43.5 |
| SDoH | 35.1 | 35.8 | 35.8 | 43.6 | 41.0 | 24.8 | 39.7 | 56.7 |
| ICD10CM | 49.3 | 49.5 | 49.6 | 50.2 | 49.8 | 68.7 | 55.5 | 54.9 |
| Average | 36.5 | 37.7 | 39.6 | 39.7 | 39.2 | 36.7 | 39.3 | 43.4 |
New real-world benchmarking also demonstrated good performances on clinical information extraction task: 2507.05517.
We carried out a Medical Red Teaming Protocol of Language Models in which we demonstrate broad conversation of original Phi3.5 safety abilities (see Phi-3 Safety Post-Training). All six merged MediPhi models fully conserve their base model's safety capabilities. For MediPhi-Instruct, it conserved safe behaviors towards jailbreaking and harmfulness, as well as it is improving considerably on groundedness. We further demonstrate safe behaviours at refusing or giving warnings with limited responses for nearly all harmful queries from clinican and patient user perspectives, based on MedSafetyBench and our PatientSafetyBench.
Phi-3.5-mini has 3.8B parameters and is a dense decoder-only Transformer model using the same tokenizer as Phi-3 Mini. It is best suited for prompts using chat format but plain text is also possible. The default context length is of 128K tokens.
Note that by default, the Phi-3.5-mini-instruct model uses flash attention, which requires certain types of GPU hardware to run. We have tested on the following GPU types:
If you want to run the model on:
The model is licensed under the MIT license.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
@inproceedings{corbeil-etal-2025-modular,
title = "A Modular Approach for Clinical {SLM}s Driven by Synthetic Data with Pre-Instruction Tuning, Model Merging, and Clinical-Tasks Alignment",
author = "Corbeil, Jean-Philippe and
Dada, Amin and
Attendu, Jean-Michel and
Ben Abacha, Asma and
Sordoni, Alessandro and
Caccia, Lucas and
Beaulieu, Francois and
Lin, Thomas and
Kleesiek, Jens and
Vozila, Paul",
editor = "Che, Wanxiang and
Nabende, Joyce and
Shutova, Ekaterina and
Pilehvar, Mohammad Taher",
booktitle = "Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
month = jul,
year = "2025",
address = "Vienna, Austria",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2025.acl-long.950/",
doi = "10.18653/v1/2025.acl-long.950",
pages = "19352--19374",
ISBN = "979-8-89176-251-0",
abstract = "High computation costs and latency of large language models such as GPT-4 have limited their deployment in clinical settings. Small language models (SLMs) offer a cost-effective alternative, but their limited capacity requires biomedical domain adaptation, which remains challenging. An additional bottleneck is the unavailability and high sensitivity of clinical data. To address these challenges, we propose a novel framework for adapting SLMs into high-performing clinical models. We introduce the MediPhi collection of 3.8B-parameter SLMs developed with our novel framework: pre-instruction tuning of experts on relevant medical and clinical corpora (PMC, Medical Guideline, MedWiki, etc.), model merging, and clinical-tasks alignment. To cover most clinical tasks, we extended the CLUE benchmark to CLUE+, doubling its size. Our expert models deliver relative improvements on this benchmark over the base model without any task-specific fine-tuning: 64.3{\%} on medical entities, 49.5{\%} on radiology reports, and 44{\%} on ICD-10 coding (outperforming GPT-4-0125 by 14{\%}). We unify the expert models into MediPhi via model merging, preserving gains across benchmarks. Furthermore, we built the MediFlow collection, a synthetic dataset of 2.5 million high-quality instructions on 14 medical NLP tasks, 98 fine-grained document types, and JSON format support. Alignment of MediPhi using supervised fine-tuning and direct preference optimization achieves further gains of 18.9{\%} on average."
}
Jean-Philippe Corbeil