Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -25,16 +25,69 @@ Qwen3.5-2B fine-tuned on ~200K medical VQA records from the SynthVision pipeline
|
|
| 25 |
| **Fine-tuned** | **0.5521** | **0.4748** | **0.6880** | **0.5716** |
|
| 26 |
| Delta | +0.8% | +24.2% | +22.5% | +15.0% |
|
| 27 |
|
| 28 |
-
##
|
|
|
|
|
|
|
| 29 |
|
| 30 |
```python
|
| 31 |
-
from transformers import AutoProcessor,
|
| 32 |
|
| 33 |
# Requires transformers>=5.3.0
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
)
|
| 37 |
-
|
| 38 |
```
|
| 39 |
|
| 40 |
## Training Details
|
|
|
|
| 25 |
| **Fine-tuned** | **0.5521** | **0.4748** | **0.6880** | **0.5716** |
|
| 26 |
| Delta | +0.8% | +24.2% | +22.5% | +15.0% |
|
| 27 |
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
### Transformers
|
| 31 |
|
| 32 |
```python
|
| 33 |
+
from transformers import AutoProcessor, AutoModelForImageTextToText
|
| 34 |
|
| 35 |
# Requires transformers>=5.3.0
|
| 36 |
+
model_id = "OpenMed/Qwen3.5-2B-MedVL"
|
| 37 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
| 38 |
+
model = AutoModelForImageTextToText.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
|
| 39 |
+
|
| 40 |
+
messages = [
|
| 41 |
+
{
|
| 42 |
+
"role": "user",
|
| 43 |
+
"content": [
|
| 44 |
+
{"type": "image", "url": "https://example.com/xray.jpg"},
|
| 45 |
+
{"type": "text", "text": "What are the key findings in this chest X-ray?"},
|
| 46 |
+
],
|
| 47 |
+
}
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt").to(model.device)
|
| 51 |
+
output = model.generate(**inputs, max_new_tokens=512)
|
| 52 |
+
print(processor.decode(output[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
### vLLM
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
from vllm import LLM, SamplingParams
|
| 59 |
+
|
| 60 |
+
llm = LLM(model="OpenMed/Qwen3.5-2B-MedVL", max_model_len=4096, limit_mm_per_prompt={"image": 1})
|
| 61 |
+
|
| 62 |
+
messages = [{"role": "user", "content": [
|
| 63 |
+
{"type": "image_url", "image_url": {"url": "https://example.com/xray.jpg"}},
|
| 64 |
+
{"type": "text", "text": "What are the key findings in this chest X-ray?"},
|
| 65 |
+
]}]
|
| 66 |
+
|
| 67 |
+
output = llm.chat(messages, SamplingParams(temperature=0, max_tokens=512))
|
| 68 |
+
print(output[0].outputs[0].text)
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
### SGLang
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
+
# Launch server
|
| 75 |
+
python -m sglang.launch_server --model-path OpenMed/Qwen3.5-2B-MedVL --port 8000
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
from openai import OpenAI
|
| 80 |
+
|
| 81 |
+
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
|
| 82 |
+
response = client.chat.completions.create(
|
| 83 |
+
model="OpenMed/Qwen3.5-2B-MedVL",
|
| 84 |
+
messages=[{"role": "user", "content": [
|
| 85 |
+
{"type": "image_url", "image_url": {"url": "https://example.com/xray.jpg"}},
|
| 86 |
+
{"type": "text", "text": "What are the key findings in this chest X-ray?"},
|
| 87 |
+
]}],
|
| 88 |
+
max_tokens=512,
|
| 89 |
)
|
| 90 |
+
print(response.choices[0].message.content)
|
| 91 |
```
|
| 92 |
|
| 93 |
## Training Details
|