199 lines
14 KiB
Markdown
199 lines
14 KiB
Markdown
|
|
---
|
|||
|
|
license: apache-2.0
|
|||
|
|
base_model: Qwen/Qwen3-4B
|
|||
|
|
base_model_relation: finetune
|
|||
|
|
library_name: transformers
|
|||
|
|
pipeline_tag: text-generation
|
|||
|
|
language:
|
|||
|
|
- en
|
|||
|
|
thumbnail: https://huggingface.co/vmal/med-advisor-conversation-4B/resolve/main/assets/launch-scorecard.png
|
|||
|
|
tags:
|
|||
|
|
- medical
|
|||
|
|
- healthcare
|
|||
|
|
- biology
|
|||
|
|
- medical-education
|
|||
|
|
- chat
|
|||
|
|
- conversational
|
|||
|
|
- reasoning
|
|||
|
|
- qwen
|
|||
|
|
- qwen3
|
|||
|
|
- reinforcement-learning
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
# Med Advisor Conversation 4B
|
|||
|
|
|
|||
|
|
**A 4B medical explainer that adjusts its answer to who is asking: patient, caregiver, science-literate adult, medical student or healthcare worker.**
|
|||
|
|
|
|||
|
|
It is Qwen3-4B, fully fine-tuned on medical conversations. It holds multi-turn conversations, supports thinking and non-thinking modes.
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
| HealthBench Consensus, 1,000 English prompts | Qwen3-4B (base) | After fine-tuning (SFT) | **Med Advisor (RL100)** |
|
|||
|
|
|---|---:|---:|---:|
|
|||
|
|
| Non-thinking | 34.5% | 40.7% | **54.4%** |
|
|||
|
|
| Thinking | 32.0% | 47.9% | **59.9%** |
|
|||
|
|
|
|||
|
|
RL100 is the released model: the reinforcement-learning (RL) training checkpoint after 100 updates. Same system message and sampling settings for every model. Graded by GPT-6 Luna, not the official HealthBench grader, so compare the columns with each other and not with published HealthBench numbers. [Details](#evaluation).
|
|||
|
|
|
|||
|
|
**This model has not been clinically validated.** It is for education and research. It can be wrong, and it must not be used for diagnosis, prescribing, personal dosing, treatment selection or interpreting an individual's medical records.
|
|||
|
|
|
|||
|
|
<!-- Before publishing: confirm the uploaded weights are the RL100 checkpoint, run the quick-start snippet against them in both modes, and add author and citation details. This comment does not show on the rendered page. -->
|
|||
|
|
|
|||
|
|
[Three examples](#start-with-three-conversations) · [Scope](#scope) · [Quick start](#quick-start) · [All examples](#example-conversations) · [RL Recipe](#rl-recipe) · [Evaluation](#evaluation) · [Limitations](#intended-use-and-limitations)
|
|||
|
|
|
|||
|
|
## Start with three conversations
|
|||
|
|
|
|||
|
|
- **A number explained in plain terms:** [The advert says 50% fewer heart attacks](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n09-relative-vs-absolute-risk.md). The model turns a 50% relative reduction at a 4% baseline risk into absolute numbers, then writes a version to say to a patient.
|
|||
|
|
- **A correction changes the answer:** [Metformin or metoprolol?](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t02-metformin-or-metoprolol.md) The user checks the bottle in turn three, and the model updates its explanation.
|
|||
|
|
- **A follow-up changes the urgency:** [An eGFR of 42 on a weekend, then new confusion](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t03-egfr-then-confusion.md). When the user adds acute symptoms, the next reply leads with escalation.
|
|||
|
|
|
|||
|
|
## Scope
|
|||
|
|
|
|||
|
|
| | |
|
|||
|
|
|---|---|
|
|||
|
|
| **Audiences (5)** | Curious patient · Caregiver · Science-literate adult · Medical student · Healthcare worker |
|
|||
|
|
| **Kinds of request (6)** | Explanation, mechanism and evidence · Lab, test and risk interpretation · Medication and numerical reasoning · Self-care and next steps · Safety escalation · Misinformation correction |
|
|||
|
|
| **Domains (16)** | General medicine · Oncology · Laboratory and diagnostic medicine · Medication safety · Cardiovascular · Infectious disease · Endocrinology · Neurology · Respiratory · Musculoskeletal · Gastroenterology · Dermatology · Genetics and genomics · Nephrology and urology · Rare disease · Mental health |
|
|||
|
|
| **Modes** | Thinking (reasons first, then answers) and non-thinking, switched with `enable_thinking` |
|
|||
|
|
| **Language** | English |
|
|||
|
|
|
|||
|
|
The audience changes the depth and vocabulary of an answer. It does not change the rules: the model is trained to explain, to stay out of personal clinical decisions for every audience, and to put emergency escalation first.
|
|||
|
|
|
|||
|
|
## Quick start
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
pip install "transformers>=4.57" accelerate safetensors
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
The BF16 weights need about 8 GB of memory, plus room for the context.
|
|||
|
|
|
|||
|
|
```python
|
|||
|
|
import torch
|
|||
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|||
|
|
|
|||
|
|
MODEL_ID = "vmal/med-advisor-conversation-4B"
|
|||
|
|
THINKING = False # True: the model reasons before the visible answer
|
|||
|
|
|
|||
|
|
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
|||
|
|
model = AutoModelForCausalLM.from_pretrained(MODEL_ID, dtype=torch.bfloat16, device_map="auto").eval()
|
|||
|
|
|
|||
|
|
system_message = (
|
|||
|
|
"You are Med Advisor, a clear, evidence-aware medical and scientific "
|
|||
|
|
"explainer. Use the native reasoning channel when thinking is enabled, and "
|
|||
|
|
"keep the visible answer self-contained. Give useful general education with "
|
|||
|
|
"calibrated uncertainty. Do not diagnose, prescribe, select patient-specific "
|
|||
|
|
"treatment, provide patient-specific dosing, interpret personal medical data "
|
|||
|
|
"or genetic variants as clinical conclusions, or replace clinician judgment. "
|
|||
|
|
"Escalate emergencies immediately."
|
|||
|
|
)
|
|||
|
|
messages = [
|
|||
|
|
{"role": "system", "content": system_message},
|
|||
|
|
{"role": "user", "content": "My mom's lab report says eGFR 42. What does that number mean?"},
|
|||
|
|
]
|
|||
|
|
inputs = tokenizer.apply_chat_template(
|
|||
|
|
messages, tokenize=True, add_generation_prompt=True,
|
|||
|
|
enable_thinking=THINKING, return_dict=True, return_tensors="pt",
|
|||
|
|
).to(model.device)
|
|||
|
|
|
|||
|
|
with torch.inference_mode():
|
|||
|
|
output = model.generate(
|
|||
|
|
**inputs, do_sample=True, top_k=20, max_new_tokens=8192,
|
|||
|
|
temperature=0.6 if THINKING else 0.7,
|
|||
|
|
top_p=0.95 if THINKING else 0.8,
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
text = tokenizer.decode(output[0, inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
|
|||
|
|
answer = text.split("</think>")[-1].strip()
|
|||
|
|
print(answer)
|
|||
|
|
messages.append({"role": "assistant", "content": answer}) # keep only the visible answer in history
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Three things matter for getting the behavior shown here:
|
|||
|
|
|
|||
|
|
- **Use this system message.** The model was trained and evaluated with it.
|
|||
|
|
- **Keep only visible answers in the conversation history**, never the reasoning.
|
|||
|
|
- **Cap `max_new_tokens` in thinking mode.** The model occasionally loops while reasoning. If an answer does not finish, retry in non-thinking mode.
|
|||
|
|
|
|||
|
|
## Example conversations
|
|||
|
|
|
|||
|
|
Twenty selected conversations show how the model answers five audiences across six kinds of request, in thinking and non-thinking mode. [Browse all examples](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/README.md).
|
|||
|
|
|
|||
|
|
| Audience | Thinking | Non-thinking |
|
|||
|
|
|---|---|---|
|
|||
|
|
| Curious patient | [Back pain with cancer is only urgent at 10 out of 10?](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t01-cancer-back-pain.md)<br>[Metformin or metoprolol? The user checks the bottle](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t02-metformin-or-metoprolol.md) | [Facial swelling and chest veins: ER tonight or doctor next week?](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n01-facial-swelling-er.md)<br>[Six turns on why a trial statistic is not a personal prognosis](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n02-trial-statistics-prognosis.md) |
|
|||
|
|
| Caregiver | [An eGFR of 42 on a weekend, then new confusion](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t03-egfr-then-confusion.md)<br>[Seizure first aid, then a version for the fridge door](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t04-seizure-first-aid.md) | [Alendronate "with food to protect her stomach"](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n03-alendronate-instructions.md)<br>[A symptom timeline to bring to the appointment](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n04-symptom-timeline.md) |
|
|||
|
|
| Science-literate adult | [From sensitivity and specificity to the chance a positive is real](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t05-positive-predictive-value.md)<br>[Low-dose naltrexone for Hashimoto's: how good is the evidence?](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t06-low-dose-naltrexone.md) | [mEq/L and mmol/L, and why valence matters](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n05-meq-and-mmol.md)<br>["Caregiver stress raises cortisol 300% and destroys the brain"](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n06-caregiver-stress-cortisol.md) |
|
|||
|
|
| Medical student | [Lorazepam before an MRI "eliminates anxiety with no risks"?](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t07-lorazepam-before-mri.md)<br>[Why a rare-disease trial must name its population and endpoint](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t08-rare-disease-trials.md) | [Inflammation versus infection, then the receptor-to-cytokine pathway](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n07-inflammation-vs-infection.md)<br>[A medical student wants a levothyroxine dose to request for a parent](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n08-levothyroxine-dose.md) |
|
|||
|
|
| Healthcare worker | ["After 24 hours the testis is dead, book it as outpatient"](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t09-testicular-torsion-note.md)<br>[Predictive versus prognostic biomarkers](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/thinking/t10-predictive-vs-prognostic.md) | [The advert says 50% fewer heart attacks](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n09-relative-vs-absolute-risk.md)<br>[A "screening" CA 19-9 of 45 in a healthy 55-year-old](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/examples/non-thinking/n10-ca-19-9-screening.md) |
|
|||
|
|
|
|||
|
|
*Illustrative examples, selected to show response style. The model's replies are unedited. Not medical advice.*
|
|||
|
|
|
|||
|
|
One short excerpt. A caregiver has just been given seizure first-aid steps and asks for something shorter:
|
|||
|
|
|
|||
|
|
> **User:** That makes sense, thank you — so no holding her down, nothing in her mouth, and time it. Can you give me a really short version I could write on a note for the fridge or repeat to another family member?
|
|||
|
|
>
|
|||
|
|
> **Med Advisor:**
|
|||
|
|
>
|
|||
|
|
> **Fridge note:**
|
|||
|
|
> - Don’t hold her down.
|
|||
|
|
> - Don’t put anything in her mouth.
|
|||
|
|
> - Clear hard objects.
|
|||
|
|
> - If on the floor, turn her on her side if safe.
|
|||
|
|
> - Time it.
|
|||
|
|
> - Call emergency if seizure lasts more than 5 minutes, or she has another seizure without waking.
|
|||
|
|
> - Follow her seizure action plan.
|
|||
|
|
|
|||
|
|
## RL Recipe
|
|||
|
|
|
|||
|
|
- [RL training recipe and code](https://github.com/vimalKeshu/med-advisor-conversation-4B/tree/main/rl-training): architecture, simulated conversations, grading rubrics, reward calculation, and policy updates.
|
|||
|
|
|
|||
|
|
## Evaluation
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
**Reading the chart.** Baseline is Qwen3-4B before any training. SFT is the model after supervised fine-tuning. RL25, RL50, RL75 and RL100 are checkpoints saved during reinforcement-learning training, after 25, 50, 75 and 100 updates. RL100 is the released model. T is thinking mode and NT is non-thinking mode.
|
|||
|
|
|
|||
|
|
**What was run.** 1,000 English prompts drawn from the 3,671-example HealthBench Consensus set, stratified by theme. Each model answered once per prompt with the system message and sampling settings above. Only the visible answer was graded. The benchmark allowed up to 32,768 tokens per reply, more than the quick-start cap. The grader was GPT-6 Luna; the official HealthBench grader is a different model, so these scores are not comparable with published HealthBench results. [Full protocol, intervals and saved results](https://huggingface.co/vmal/med-advisor-conversation-4B/blob/main/evaluation/README.md).
|
|||
|
|
|
|||
|
|
| Stage | What it is | Non-thinking | Thinking |
|
|||
|
|
|---|---|---:|---:|
|
|||
|
|
| Baseline | Qwen3-4B, before training | 34.5% | 32.0% |
|
|||
|
|
| SFT | After supervised fine-tuning | 40.7% | 47.9% |
|
|||
|
|
| RL25 | RL training checkpoint, 25 updates | 41.9% | 51.8% |
|
|||
|
|
| RL50 | RL training checkpoint, 50 updates | 48.9% | 55.6% |
|
|||
|
|
| RL75 | RL training checkpoint, 75 updates | 51.5% | 56.9% |
|
|||
|
|
| **RL100** | **RL training checkpoint, 100 updates (this model)** | **54.4%** | **59.9%** |
|
|||
|
|
|
|||
|
|
The score rises at every RL checkpoint in both modes. The 95% intervals are about ±2.5 points; for RL100 they are 51.8 to 56.8 (non-thinking) and 57.4 to 62.4 (thinking).
|
|||
|
|
|
|||
|
|
Against the base model in the same mode, RL100 gains 19.9 points without thinking (paired 95% interval 17.4 to 22.3) and 28.0 points with thinking (25.5 to 30.5).
|
|||
|
|
|
|||
|
|
**By theme** (mean score per prompt):
|
|||
|
|
|
|||
|
|
| Theme | Base, non-thinking | Med Advisor, non-thinking | Med Advisor, thinking |
|
|||
|
|
|---|---:|---:|---:|
|
|||
|
|
| Emergency referrals | 22.0% | 55.3% | 65.9% |
|
|||
|
|
| Context seeking | 22.5% | 50.5% | 58.1% |
|
|||
|
|
| Communication | 10.8% | 32.8% | 42.6% |
|
|||
|
|
| Hedging | 51.2% | 70.1% | 77.0% |
|
|||
|
|
| Global health | 62.4% | 79.8% | 82.4% |
|
|||
|
|
| Health data tasks | 41.7% | 50.9% | 49.1% |
|
|||
|
|
| Complex responses | 21.0% | 27.3% | 25.6% |
|
|||
|
|
|
|||
|
|
**Reading these numbers.** Med Advisor also writes much shorter answers: a median of 157 to 208 words against about 350 for the base model. The gain is not only brevity. On prompts where both models wrote answers of similar length (within 25%), it was 18.3 points without thinking (194 prompts) and 16.1 points with thinking (64 prompts).
|
|||
|
|
|
|||
|
|
|
|||
|
|
## Intended use and limitations
|
|||
|
|
|
|||
|
|
**Use it for** learning and explaining: what a term or result means, how a mechanism works, how strong the evidence is, what to ask a clinician, and when something is an emergency. It is also a research artifact for studying conversation-level reinforcement learning.
|
|||
|
|
|
|||
|
|
**Do not use it for** diagnosis, prescribing, dosing for a specific person, choosing a treatment, or interpreting someone's records. It is trained to decline these, but it will not always do so.
|
|||
|
|
|
|||
|
|
## License
|
|||
|
|
|
|||
|
|
Apache 2.0, the same license as the base model.
|
|||
|
|
|
|||
|
|
## Citation
|
|||
|
|
|
|||
|
|
If you use this checkpoint, please cite the model page.
|