MedSparse Healthcare — MIRIAD Full-Parameter SFT
A 38.8M-parameter sparse Mixture-of-Experts language model, trained from scratch and then full-parameter fine-tuned on the MIRIAD medical Q&A dataset on a single consumer-grade GPU.
Research only. Not for diagnosis, treatment, triage, medication dosing or any decision about a real person. Its medical correctness and safety have not been established, and it can produce fluent but wrong answers.
MedSparse is a custom, Mixtral-inspired architecture. It is not official Mistral or Mixtral weights,
and it is not a Transformers AutoModelForCausalLM checkpoint.
Project: AI Lab — MedSparse Healthcare · Source code
Lineage
- Pre-training from scratch on healthcare-domain text, from random initialization.
- Medical SFT on FreedomIntelligence/medical-o1-reasoning-SFT → sudhanshu42844/medsparse-healthcare-medical-sft.
- This model: full-parameter SFT of stage 2 on MIRIAD. All weights are updated (no LoRA or frozen layers), with a fresh AdamW optimizer.
Model details
| Attribute | Value |
|---|---|
| Total parameters | 38,779,008 |
| Layers / hidden size | 4 / 384 |
| Query / KV heads | 6 / 2 (grouped-query attention) |
| Experts | 4 per block, top-2 routing |
| Expert intermediate size | 768 |
| Vocabulary | 30,001 |
| Configured max positions | 2,048 (trained at 192 tokens; longer inputs are untested) |
Training
| Setting | Value |
|---|---|
| Data | MIRIAD 5.8M (question → answer), 5,821,948 Q&A pairs |
| Held-out split | 2.0% of papers (seed 42); every Q&A from a held-out paper is excluded |
| Loss | Completion-only cross-entropy (prompt masked) plus MoE load-balancing loss |
| Sequence length | 192 tokens |
| Batch | 1 × gradient accumulation 4 |
| Optimizer | AdamW, lr 2e-05, weight decay 0.01, 100 warmup steps |
| Precision | FP32 |
| Optimizer steps at this checkpoint | 1,507,000 |
| Training examples processed, including repeats | 6,031,000 |
| Answers truncated to fit 192 tokens | 398,337 (6.6% of training answers) |
| Best validation cross-entropy (64 held-out examples, completion-only) | 2.1897 |
This checkpoint is the one with the lowest validation loss during the run.
Data coverage. The run resumed several times using a shuffled streaming reader with skip(). That skip did not line up with the shuffled stream: the epoch-0 row counter reached 6,150,107, which is 328,159 rows past MIRIAD's 5,821,948 rows. So some Q&A pairs were trained on more than once, and full coverage of MIRIAD is not verified: some rows may never have been seen. The paper-level held-out filter was applied to every row, so no held-out paper entered training.
Prompt format used in training and inference:
### System:
Provide accurate educational medical information, and acknowledge uncertainty.
### User:
<question>
### Assistant:
Evaluation
15 questions from 15 different held-out papers (one per question), using the training script's own paper-level split. Greedy decoding with repetition penalty 1.2. "Before MIRIAD" is the stage-2 model this one was fine-tuned from.
| Model | Perplexity on reference answers (lower is better) | Mean word overlap F1 (higher is better) |
|---|---|---|
| MedSparse (MIRIAD SFT) | 9.50 | 0.346 |
| Before MIRIAD | 383.49 | 0.185 |
Perplexity is measured on MIRIAD's reference answers. Word overlap is a rough lexical score, not a measure of medical correctness. These are small development checks, not a clinical benchmark.
Read-through of the 15 answers (informal, not an expert clinical review): The MIRIAD checkpoint produced more fluent and less repetitive responses in this sample, although some responses went off topic. Factual accuracy is still low: about 3 of 15 answers were correct or mostly correct, 5 were on topic but vague or incomplete, and 7 were wrong. Examples of the errors: it confused rowing "stroke rate" with stroke the disease, invented heart treatments for methylnicotinate, described the labor-delaying drug isoxsuprine as an anti-cancer antioxidant, placed Iran in the Maghreb, and repeated a single word in place of a list. Every answer needs checking against a reliable source.
Usage
python -m pip install torch safetensors tokenizers huggingface_hub
python -c "from huggingface_hub import snapshot_download; print(snapshot_download('sudhanshu42844/medsparse-healthcare-miriad-sft'))"
From the downloaded folder:
python load_model.py --sft --prompt "What is the role of troponin in diagnosing myocardial infarction?"
Limitations
- Small model (38.8M parameters): expect factual errors, omissions and confident hallucinations.
- Trained on 192-token windows; long answers in training were truncated, so outputs tend to be short.
- MIRIAD answers were generated by language models from research papers and can themselves contain errors.
- No clinical safety, fairness, robustness, privacy or medication-safety evaluation has been done.
License and attribution
- Model weights and code in this repository: Apache License 2.0.
- Training data: MIRIAD (arXiv:2506.06091), released under ODC-By v1.0, with the dataset authors noting OpenAI's usage terms: its content must not be used for medical diagnosis or decisions about real individuals. That restriction applies to this model too.