MedLLM is an open 0.1B-parameter (100.29M) decoder-only medical language model trained from scratch through a fully open three-phase pipeline: general pretraining, domain fine-tuning on the MedFineWeb medical web corpus, and preference-aligned fine-tuning (SFT + DPO). It is described in the paper MedLLM: An Open Medical Language Model at the Sub-Billion Scale (Rahman, Ahmed, Mohagheghzadeh & Maass, 2026).
This checkpoint is the DPO-aligned model for MedQA (USMLE-style 4-option clinical vignettes). It starts from the shared domain-fine-tuned MedLLM checkpoint and is then trained with supervised fine-tuning followed by direct preference optimization on the MedQA training set.
Key finding of the paper. At sub-billion scale, medical competence does not degrade uniformly under compression but splits by task type. MedLLM is strong on context-grounded QA (PubMedQA) and on MedMCQA, where it exceeds every 7B and sub-7B baseline, while it stays near the task floor on clinical-vignette MedQA. The paper argues that this dissociation is masked at 7B and surfaces only when capacity is scarce.
| Repository | Aligned for | Score |
|---|---|---|
maxxrichard/medllm-dpo-medmcqa |
MedMCQA & MMLU-Medical | MedMCQA 34.9%, MMLU-Medical 32.4% |
maxxrichard/medllm-dpo-medqa |
MedQA | MedQA 28.1% |
maxxrichard/medllm-dpo-pubmedqa |
PubMedQA | PubMedQA 58.2% |
All three share the same pretraining, domain fine-tuning stage, tokenizer and architecture. They differ only in the SFT + DPO data.
| Property | Value |
|---|---|
| Developed by | Maxx Richard Rahman, Asim Ahmed, Mihan Mohagheghzadeh, Wolfgang Maass (DFKI & Saarland University) |
| Model type | Decoder-only Transformer (OLMo-2 style), custom transformers implementation |
| Parameters | 100.29M |
| Layers / d_model / heads | 20 / 512 / 8 (head dim 64) |
| FFN | 2048, SwiGLU |
| Normalization | Pre-norm RMSNorm (ε = 1e-6) |
| Positional encoding | Rotary (RoPE, base 10,000) |
| Embeddings | Weight-tied input / output, vocab 32,000 |
| Context length | 512 tokens |
| Tokenizer | SentencePiece unigram, 32k vocab, trained on general + medical text (tokenizer.model) |
| Precision | float32 weights (model.safetensors, 467 MB) |
| Language | English |
| License | Apache 2.0 |
| Paper | arXiv:2607.27490 |
| Data | ≈46.08M documents, ≈29.5B tokens (45 GB): RedPajama-V2 (7.55M docs), C4 (32.0M), OpenWebText (8.01M), Wikipedia (6.41M) |
| Objective | Causal LM with z-loss (weight 1e-4) |
| Steps | 200,000 |
| Curriculum | Sequence length 128 → 256 → 512 in three stages |
| Final validation loss | 4.005 |
| Hardware | 2× NVIDIA H100 |
MedFineWeb is a reference-guided medical corpus selected from general web text. General-web documents are split into ≈1,000-word chunks (2M candidates), embedded with a Sentence-Transformer, and scored by mean cosine similarity to their top-5 nearest medical QA references (20,000 MedMCQA, 10,178 MedQA and 20,000 PubMedQA examples, used for selection only, never as training text). The top 50% per reference set is kept, then merged and deduplicated.
| Corpus size | ≈3M chunks, ≈3B SentencePiece tokens (≈1,000 tokens per chunk) |
| Steps | 25,000 |
| Learning rate | 5e-5 |
| Validation perplexity | 27.3 (step 1k) → 15.68 (step 8k) → 13.62 (step 25k) |
| Training examples | 10,178 |
| SFT | 4,000 steps, batch 8, LR 2e-5, label-prediction loss over all options |
| DPO | 500 steps, batch 32, LR 5e-6, β = 0.1, reference policy = the SFT model |
| Preference pairs | The correct answer is paired against each incorrect answer |
| Hardware | 2× NVIDIA A100 |
Protocol. MedLLM is evaluated zero-shot by log-probability ranking (top-token selection): the predicted answer is the option whose answer token receives the highest log-probability. Results are the mean ± standard deviation over three seeds. Pretrained baselines use 3-shot in-context learning; fine-tuned baselines use the same top-token selection. MMLU-Medical covers 1,862 items across nine medical subjects and is scored with the MedMCQA-aligned checkpoint.
| Benchmark | Split | Accuracy (%) |
|---|---|---|
| MedQA | MedQA USMLE 4-option (test, 1,273 items) | 28.1 ± 1.0 |
| Model | Params | MMLU-Med | PubMedQA | MedMCQA | MedQA | Avg |
|---|---|---|---|---|---|---|
| Mistral-7B* | 7B | 25.8 | 17.8 | 30.2 | 41.1 | 28.7 |
| Zephyr-7B-β* | 7B | 32.1 | 43.0 | 33.0 | 42.5 | 37.7 |
| PMC-LLaMA-7B | 7B | 26.4 | 72.9 | 26.6 | 25.5 | 37.9 |
| Falcon-7B | 7B | 23.6 | 65.3 | 31.8 | 21.0 | 35.4 |
| Gemma-2B | 2B | 27.6 | 60.8 | 27.7 | 30.6 | 36.7 |
| BioMedLM-2.7B | 2.7B | 23.8 | 55.2 | 32.2 | 30.6 | 35.5 |
| BioGPT-Large | 1.5B | 21.6 | 60.1 | 33.1 | 31.3 | 36.5 |
| MedLLM (SFT) | 0.1B | 29.7 | 57.9 | 33.9 | 26.6 | 37.0 |
| MedLLM (DPO) | 0.1B | 32.4 | 58.2 | 34.9 | 28.1 | 38.4 |
* Instruction-tuned baselines used with released weights.
The model uses custom architecture code shipped in this repository, so pass
trust_remote_code=True. The tokenizer is a raw SentencePiece model, loaded with the
sentencepiece package rather than AutoTokenizer.
pip install transformers sentencepiece torch
import torch
import sentencepiece as spm
from huggingface_hub import hf_hub_download
from transformers import AutoModelForCausalLM
repo = "maxxrichard/medllm-dpo-medqa"
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True).eval()
sp = spm.SentencePieceProcessor(model_file=hf_hub_download(repo, "tokenizer.model"))
ids = torch.tensor([sp.encode("What is the mechanism of action of metformin?")])
with torch.no_grad():
logits = model(ids).logits # (batch, seq_len, 32000)
The model is trained and evaluated as an option ranker, not a free-text generator. Score each candidate answer by the log-probability the model assigns to it after the question, and pick the best one:
import torch
import torch.nn.functional as F
def option_logprob(prompt: str, option: str) -> float:
"""Sum of log-probs of the option tokens, conditioned on the prompt."""
p_ids = sp.encode(prompt)
o_ids = sp.encode(option)
ids = torch.tensor([p_ids + o_ids])[:, :512]
with torch.no_grad():
logp = F.log_softmax(model(ids).logits[0, :-1].float(), dim=-1)
targets = ids[0, 1:]
start = len(p_ids) - 1
return logp[torch.arange(start, targets.numel()), targets[start:]].sum().item()
question = "A 62-year-old woman presents with sudden-onset crushing chest pain radiating to the left arm. ECG shows ST elevation in leads II, III and aVF. Which coronary artery is most likely occluded?"
options = ["Left anterior descending artery", "Right coronary artery", "Left circumflex artery", "Left main coronary artery"]
letters = ["A", "B", "C", "D"]
prompt = question + "\n" + "\n".join(f"{l}. {o}" for l, o in zip(letters, options)) + "\nAnswer:"
scores = [option_logprob(prompt, " " + l) for l in letters]
print(letters[scores.index(max(scores))])
The exact prompt templates used in the paper, cyclic permutation of the options to remove position bias, and ensembling over several templates all affect the numbers; the protocol above is a minimal reproduction of the top-token scoring.
Intended use. Research on small-scale domain-specific language models, medical multiple-choice QA benchmarking, and as a sub-billion-parameter baseline. The model is released to characterise the sub-billion regime of medical LMs, which prior open work leaves uncharted.
Out of scope. This model is not a medical device and must not be used for diagnosis, treatment decisions, patient-facing advice or any clinical use. Its outputs have not been validated for safety, factual accuracy or absence of harmful content.
Limitations.
@misc{rahman2026medllm,
title={MedLLM: An Open Medical Language Model at the Sub-Billion Scale},
author={Maxx Richard Rahman and Asim Ahmed and Mihan Mohagheghzadeh and Wolfgang Maass},
year={2026},
eprint={2607.27490},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2607.27490},
}
Maxx Richard Rahman (corresponding author), Asim Ahmed, Mihan Mohagheghzadeh and Wolfgang Maass — German Research Center for Artificial Intelligence (DFKI) and Saarland University, Germany.