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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: arcee-ai/AFM-4.5B
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
tags:
|
| 8 |
+
- medical
|
| 9 |
+
- instruction-tuned
|
| 10 |
+
- dpo
|
| 11 |
+
- grpo
|
| 12 |
+
- cot
|
| 13 |
+
- mergekit
|
| 14 |
+
- arcee-fusion
|
| 15 |
+
- openmed
|
| 16 |
+
license: apache-2.0
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# AFM-4.5B-OpenMed-GGUF
|
| 20 |
+
|
| 21 |
+
**Lightweight medical finetune on top of Arcee’s AFM-4.5B** for education and research use. Trained with a simple 3-stage recipe (SFT → DPO → GRPO-CoT) and finalized via **Arcee Fusion** weight merging (MergeKit).
|
| 22 |
+
|
| 23 |
+
More information about our **methodology** will be available in a forthcoming **blog post**.
|
| 24 |
+
|
| 25 |
+
All experiments were performed on **AMD MI300x** GPUs, with computing credits generously provided by [Hot AISLE](https://hotaisle.xyz/).
|
| 26 |
+
|
| 27 |
+
> ⚠️ **Medical safety**
|
| 28 |
+
> This model is **not** a clinician. It can hallucinate and should **not** be used for diagnosis or treatment. Always involve qualified medical professionals.
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## TL;DR
|
| 33 |
+
|
| 34 |
+
- **Base:** [`arcee-ai/AFM-4.5B`](https://huggingface.co/arcee-ai/AFM-4.5B) – Arcee’s 4.5B instruction model intended for cloud-to-edge deployment.
|
| 35 |
+
- **Training (high level):**
|
| 36 |
+
1) **SFT** proprietary synthetic medical datasets + **tool-calling (search) traces**
|
| 37 |
+
2) **DPO** using **MedMCQA-derived** preferences (multiple-choice signal)
|
| 38 |
+
3) **GRPO** for **chain-of-thought enrichment**, using **MedReason** verifiable rewards; short rationales encouraged, final answer checked.
|
| 39 |
+
4) **Model merge:** **Arcee Fusion** (MergeKit) for selective, importance-aware parameter fusion.
|
| 40 |
+
- **Eval (EleutherAI harness; author’s settings, bs=64)**
|
| 41 |
+
- **MMLU:** **61.10** (vs **55.53** base)
|
| 42 |
+
- **MMLU-Pro:** **33.44** (vs **32.61** base) – harder 10-choice variant.
|
| 43 |
+
- **IFEVAL:** **63.55** (vs **63.67** base) – verifiable instruction following.
|
| 44 |
+
|
| 45 |
+
_Note:_ Arcee’s internal evals may use different harnesses; avoid cross-harness comparisons.
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## What’s inside
|
| 50 |
+
|
| 51 |
+
### Specialization steps
|
| 52 |
+
|
| 53 |
+
1. **Domain SFT (medical + tools)**
|
| 54 |
+
Instruction-style synthetic medical Q&A + conversions; supervised **search/tool-use traces** to teach function-calling patterns compatible with chat templates.
|
| 55 |
+
|
| 56 |
+
2. **Preference alignment — DPO**
|
| 57 |
+
Uses **MedMCQA** correctness as a proxy preference signal to bias toward concise, clinically reasonable options.
|
| 58 |
+
|
| 59 |
+
3. **Reasoning enrichment — GRPO (CoT)**
|
| 60 |
+
**Group Relative Policy Optimization** without a critic; groups of sampled solutions are scored by **verifiable rewards** (answer correctness + light format checks). Trained with **MedReason** QA signal.
|
| 61 |
+
|
| 62 |
+
4. **Finalization — Arcee Fusion (MergeKit)**
|
| 63 |
+
**Selective** weight fusion to preserve gains while limiting over-averaging; configured via `merge_method: arcee_fusion`.
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
## Intended use & limitations
|
| 68 |
+
|
| 69 |
+
**Intended:** Medical SLM's **research**, tool-augmented retrieval demos.
|
| 70 |
+
|
| 71 |
+
**Out of scope:** Unsupervised patient care, generating prescriptions, and time-critical guideline decisions.
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## Evaluation
|
| 76 |
+
|
| 77 |
+
> Author-run with the EleutherAI `lm-evaluation-harness`; seeds, prompts, and templates affect absolute scores.
|
| 78 |
+
|
| 79 |
+
| Benchmark | AFM-4.5B-OpenMed | AFM-4.5B (same harness) |
|
| 80 |
+
|---|---:|---:|
|
| 81 |
+
| **MMLU** | **61.10** | 55.53 |
|
| 82 |
+
| **MMLU-Pro** | **33.44** | 32.61 |
|
| 83 |
+
| **IFEVAL** | 63.55 | **63.67** |
|
| 84 |
+
|
| 85 |
+
- **MMLU-Pro** increases difficulty (10 options; more reasoning-heavy); small deltas are still meaningful.
|
| 86 |
+
- **IFEVAL** checks **verifiable** constraints (length, keyword counts, format, etc.).
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
| mmlu | AFM-4.5B-OpenMed | AFM-4.5B |
|
| 90 |
+
| :-------------------- | :--------------- | :------- |
|
| 91 |
+
| **other** | | |
|
| 92 |
+
| clinical_knowledge | 67.55 | 65.66 |
|
| 93 |
+
| college_medicine | 64.74 | 54.34 |
|
| 94 |
+
| professional_medicine | 63.97 | 59.56 |
|
| 95 |
+
| virology | 49.4 | 48.19 |
|
| 96 |
+
| **stem** | | |
|
| 97 |
+
| anatomy | 62.96 | 56.3 |
|
| 98 |
+
| college_biology | 78.47 | 65.97 |
|
| 99 |
+
| college_chemistry | 44.00 | 37.00 |
|
| 100 |
+
| high_school_biology | 79.03 | 71.29 |
|
| 101 |
+
| high_school_chemistry | 53.2 | 43.84 |
|
| 102 |
+
| **groups** | | |
|
| 103 |
+
| humanities | 56.13 | 50.46 |
|
| 104 |
+
| other | 68.97 | 63.47 |
|
| 105 |
+
| social sciences | 73.25 | 68.61 |
|
| 106 |
+
| stem | 48.91 | 42.53 |
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
### Reproduce (example commands)
|
| 110 |
+
|
| 111 |
+
```bash
|
| 112 |
+
# MMLU classic
|
| 113 |
+
lm_eval --model hf \
|
| 114 |
+
--model_args pretrained=openmed-community/AFM-4.5B-OpenMed,parallelize=True,dtype=bfloat16,trust_remote_code=True \
|
| 115 |
+
--task mmlu \
|
| 116 |
+
--batch_size=64 \
|
| 117 |
+
--apply_chat_template \
|
| 118 |
+
--output_path=results \
|
| 119 |
+
--fewshot_as_multiturn
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
# MMLU-Pro (10-choice)
|
| 123 |
+
lm_eval --model hf \
|
| 124 |
+
--model_args pretrained=openmed-community/AFM-4.5B-OpenMed,parallelize=True,dtype=bfloat16,trust_remote_code=True \
|
| 125 |
+
--tasks leaderboard_mmlu_pro \
|
| 126 |
+
--batch_size=64 \
|
| 127 |
+
--apply_chat_template \
|
| 128 |
+
--output_path=results \
|
| 129 |
+
--fewshot_as_multiturn
|
| 130 |
+
|
| 131 |
+
# IFEVAL (verifiable instruction following)
|
| 132 |
+
lm_eval --model hf \
|
| 133 |
+
--model_args pretrained=openmed-community/AFM-4.5B-OpenMed,parallelize=True,dtype=bfloat16,trust_remote_code=True \
|
| 134 |
+
--tasks leaderboard_ifeval \
|
| 135 |
+
--batch_size=64 \
|
| 136 |
+
--apply_chat_template \
|
| 137 |
+
--output_path=results \
|
| 138 |
+
--fewshot_as_multiturn
|
| 139 |
+
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## Quickstart (Transformers)
|
| 145 |
+
|
| 146 |
+
```python
|
| 147 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 148 |
+
import torch
|
| 149 |
+
|
| 150 |
+
model_id = "openmed-community/AFM-4.5B-OpenMed"
|
| 151 |
+
tok = AutoTokenizer.from_pretrained(model_id, use_fast=True)
|
| 152 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
|
| 153 |
+
|
| 154 |
+
messages = [
|
| 155 |
+
{"role": "system", "content": "You are a careful medical assistant. Cite sources and warn this is not medical advice."},
|
| 156 |
+
{"role": "user", "content": "Briefly: cellulitis vs erysipelas differences?"}
|
| 157 |
+
]
|
| 158 |
+
prompt = tok.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
| 159 |
+
inputs = tok(prompt, return_tensors="pt").to(model.device)
|
| 160 |
+
out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
|
| 161 |
+
print(tok.decode(out[0], skip_special_tokens=True))
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
## Data & training notes
|
| 165 |
+
|
| 166 |
+
* **SFT data:** Proprietary synthetic medical data + search traces.
|
| 167 |
+
* **DPO signal:** Preferences derived from **MedMCQA** multiple-choice correctness.
|
| 168 |
+
* **GRPO reward:** Answer-checking + format verifiers; **MedReason** used to shape faithful, short CoT.
|
| 169 |
+
* No known PHI; please open an issue if you spot any.
|
| 170 |
+
|
| 171 |
+
---
|
| 172 |
+
|
| 173 |
+
## Compatibility & licenses
|
| 174 |
+
|
| 175 |
+
* **Base model:** AFM-4.5B (Arcee). Refer to the base card/blog for architecture and usage details. License for AFM releases is **Apache 2.0**;
|
| 176 |
+
* **Merging:** MergeKit with **Arcee Fusion**; see repo/blog for configuration.
|
| 177 |
+
|
| 178 |
+
---
|
| 179 |
+
|
| 180 |
+
## Additional note
|
| 181 |
+
|
| 182 |
+
We also provide a **non-merged** [openmed-community/AFM-4.5B-OpenMed-RL-CoT](https://huggingface.co/openmed-community/AFM-4.5B-OpenMed-RL-CoT) checkpoint after step 3 (**GRPO**). In our harness, it shows **better CoT** behavior but a significant drop on **IFEVAL**. Consider it if you want maximum reasoning verbosity, then apply your own MergeKit recipe.
|