Image-Text-to-Text
Transformers
Safetensors
GGUF
English
qwen3_5
text-generation-inference
unsloth
medical
triage
emergency-medicine
dpo
rlhf
medical-llm
clinical
healthcare
medicine
medical-ai
clinical-decision-support
conversational
Instructions to use vadimbelsky/qwen3.5-medical-ft-stage3-dpo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vadimbelsky/qwen3.5-medical-ft-stage3-dpo with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="vadimbelsky/qwen3.5-medical-ft-stage3-dpo") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("vadimbelsky/qwen3.5-medical-ft-stage3-dpo") model = AutoModelForMultimodalLM.from_pretrained("vadimbelsky/qwen3.5-medical-ft-stage3-dpo", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use vadimbelsky/qwen3.5-medical-ft-stage3-dpo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vadimbelsky/qwen3.5-medical-ft-stage3-dpo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vadimbelsky/qwen3.5-medical-ft-stage3-dpo", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/vadimbelsky/qwen3.5-medical-ft-stage3-dpo
- SGLang
How to use vadimbelsky/qwen3.5-medical-ft-stage3-dpo with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "vadimbelsky/qwen3.5-medical-ft-stage3-dpo" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vadimbelsky/qwen3.5-medical-ft-stage3-dpo", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "vadimbelsky/qwen3.5-medical-ft-stage3-dpo" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vadimbelsky/qwen3.5-medical-ft-stage3-dpo", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Unsloth Desktop
- Docker Model Runner
How to use vadimbelsky/qwen3.5-medical-ft-stage3-dpo with Docker Model Runner:
docker model run hf.co/vadimbelsky/qwen3.5-medical-ft-stage3-dpo
Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: unsloth/Qwen3.5-9B
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- medical
|
| 7 |
+
- emergency-medicine
|
| 8 |
+
- triage
|
| 9 |
+
- dpo
|
| 10 |
+
- rlhf
|
| 11 |
+
- qwen3_5
|
| 12 |
+
- unsloth
|
| 13 |
+
language:
|
| 14 |
+
- en
|
| 15 |
+
license: apache-2.0
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Qwen3.5-9B — Medical Triage Stage 3 DPO
|
| 19 |
+
|
| 20 |
+
Fine-tuned **Qwen3.5-9B** for emergency department triage decision support. This is the fully merged Stage 3 checkpoint, aligned with DPO to reduce over-triage and preserve recall for high-acuity patients.
|
| 21 |
+
|
| 22 |
+
## Model Description
|
| 23 |
+
|
| 24 |
+
| Property | Value |
|
| 25 |
+
|---|---|
|
| 26 |
+
| Base model | `unsloth/Qwen3.5-9B` |
|
| 27 |
+
| Architecture | Qwen 3.5 — 9B parameters |
|
| 28 |
+
| Precision | bfloat16 |
|
| 29 |
+
| Training stages | 3 (SFT stage 1 → SFT stage 2 → DPO stage 3) |
|
| 30 |
+
| Task | Emergency triage — ESI level assignment from SOAP notes |
|
| 31 |
+
|
| 32 |
+
## Training — Stage 3 (this checkpoint)
|
| 33 |
+
|
| 34 |
+
Stage 3 applies Direct Preference Optimization (DPO) on top of Stage 2 SFT adapters to correct over-triage bias.
|
| 35 |
+
|
| 36 |
+
| Hyperparameter | Value |
|
| 37 |
+
|---|---|
|
| 38 |
+
| Method | DPO (sigmoid loss) |
|
| 39 |
+
| Beta | 0.1 |
|
| 40 |
+
| Learning rate | 5e-5 |
|
| 41 |
+
| Epochs | 1 |
|
| 42 |
+
| Batch size | 2 × 8 grad accum = 16 effective |
|
| 43 |
+
| Optimizer | AdamW 8-bit |
|
| 44 |
+
| LoRA rank | 16 |
|
| 45 |
+
| Training pairs | 3,730 |
|
| 46 |
+
| Validation pairs | 197 |
|
| 47 |
+
| Framework | Unsloth + TRL |
|
| 48 |
+
|
| 49 |
+
**Alignment objective:** reduce over-triage (assigning ESI 1/2 to ESI 3/4/5 cases) while preserving recall for truly high-acuity patients.
|
| 50 |
+
|
| 51 |
+
## System Prompt
|
| 52 |
+
|
| 53 |
+
```
|
| 54 |
+
You are an expert emergency medicine triage nurse. Given a SOAP intake note, provide a structured triage decision including ESI level with justification, key clinical findings, time-to-provider target, and any immediate interventions required.
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Usage
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 61 |
+
import torch
|
| 62 |
+
|
| 63 |
+
model_id = "vadimbelsky/qwen3.5-medical-ft-stage3-dpo"
|
| 64 |
+
|
| 65 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 66 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 67 |
+
model_id,
|
| 68 |
+
dtype=torch.bfloat16,
|
| 69 |
+
device_map="auto",
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
system_prompt = (
|
| 73 |
+
"You are an expert emergency medicine triage nurse. "
|
| 74 |
+
"Given a SOAP intake note, provide a structured triage decision including "
|
| 75 |
+
"ESI level with justification, key clinical findings, time-to-provider target, "
|
| 76 |
+
"and any immediate interventions required."
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
soap_note = """
|
| 80 |
+
S: 67-year-old male, chest pain radiating to left arm x 45 minutes, diaphoretic, nausea.
|
| 81 |
+
O: BP 160/95, HR 102, RR 20, SpO2 96% RA, temp 37.1°C.
|
| 82 |
+
A: Suspected ACS / STEMI rule-out.
|
| 83 |
+
P: 12-lead ECG, troponin, aspirin 325mg, IV access.
|
| 84 |
+
"""
|
| 85 |
+
|
| 86 |
+
messages = [
|
| 87 |
+
{"role": "system", "content": system_prompt},
|
| 88 |
+
{"role": "user", "content": soap_note.strip()},
|
| 89 |
+
]
|
| 90 |
+
|
| 91 |
+
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
|
| 92 |
+
outputs = model.generate(inputs, max_new_tokens=512, temperature=0.1, do_sample=True)
|
| 93 |
+
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
## Intended Use
|
| 97 |
+
|
| 98 |
+
- Clinical decision support tool for emergency triage education and research
|
| 99 |
+
- **Not validated for clinical deployment** — always defer to licensed clinical staff
|
| 100 |
+
|
| 101 |
+
## Limitations
|
| 102 |
+
|
| 103 |
+
- Trained on a curated DPO dataset; real-world distribution may differ
|
| 104 |
+
- Does not replace clinical judgment or access to vital signs, lab results, or imaging
|
| 105 |
+
- Performance on rare ESI 1 presentations (e.g. cardiac arrest, airway emergency) should be independently validated
|