19 Downloads Updated 1 month ago
ollama run r245142r/Clair-3B-health
library_name: transformers pipeline_tag: image-text-to-text tags: - multimodal - vision - medical - zimbabwe - health - image-text-to-text license: other license_name: custom-research-license base_model:
Clair is a multimodal medical AI assistant with multimodal text and vision capabilities for Xray/CTScan and disease detection.
It is grounded in:
Important: Clair is for informational and research use only and is not a substitute for professional medical advice, diagnosis, or treatment.
Clair’s text part decoder-only transformer (LLM). The image part is a SigLIP image encoder
This repository includes:
model-Q4_K_M.gguf — quantized language model for CPU inference.mmproj-model-f16.gguf — matching vision projector converted from this fine-tuned model so image understanding works correctly.Create a Modelfile like this:
FROM ./model-Q4_K_M.gguf
CLIP_MODEL ./mmproj-model-f16.gguf
SYSTEM You are Clair, a warm and knowledgeable AI health assistant developed by Michael Nkomo, an AI engineer based in Zimbabwe. You are grounded in Zimbabwe's public health system, Zimbabwean heritage and culture, and Cimas Health Group. You are not a substitute for professional medical advice, diagnosis, or treatment.
PARAMETER temperature 0.7
PARAMETER top_k 40
PARAMETER top_p 0.9
Then run:
ollama create clair-health -f Modelfile
ollama run clair-health
Example prompt:
What's in this image? /path/to/image.jpg
| Task | Metric | Clair-health 4B |
|---|---|---|
| MIMIC CXR | Macro F1 for top 5 conditions | 88.9 |
| CheXpert CXR | Macro F1 for top 5 conditions | 48.1 |
| CXR14 | Macro F1 for 3 conditions | 50.1 |
| PathMCQA | Accuracy | 69.8 |
| US-DermMCQA | Accuracy | 71.8 |
| EyePACS | Accuracy | 64.9 |
| SLAKE | Tokenized F1 | 72.3 |
| VQA-RAD | Tokenized F1 | 49.9 |
| MedXpertQA | Accuracy | 18.8 |
| Metric | Gemma 3 4B | Clair-health 4B |
|---|---|---|
| MedQA (4-op) | 50.7 | 64.4 |
| MedMCQA | 45.4 | 55.7 |
| PubMedQA | 68.4 | 73.4 |
| MMLU Med | 67.2 | 70.0 |
| MedXpertQA (text only) | 11.6 | 14.2 |
| AfriMed-QA (25-question test set) | 48.0 | 52.0 |
Evaluated on MIMIC-CXR using RadGraph F1.
| Metric | Clair-health (pre-trained) | Clair-health (tuned for CXR) | PaliGemma 2 3B (tuned for CXR) | PaliGemma 2 10B (tuned for CXR) |
|---|---|---|---|---|
| MIMIC-CXR RadGraph F1 | 29.5 | 30.3 | 28.8 | 29.5 |
Clair has been evaluated with structured safety testing and internal red-teaming across text and image inputs. These evaluations covered child safety, content safety, representational harms, and medical safety concerns.
The model was tested without safety filters to better understand raw behavior during evaluation. Results should be interpreted carefully, especially because the evaluation set was primarily English-language prompts.
First, install the Transformers library. Clair-health is supported starting from transformers 4.50.0.
pip install -U transformers
from transformers import pipeline
from PIL import Image
import requests
import torch
pipe = pipeline(
"image-text-to-text",
model="clair-health",
torch_dtype=torch.bfloat16,
device="cuda",
)
# Image attribution: Stillwaterising, CC0, via Wikimedia Commons
image_url = "https://upload.wikimedia.org/wikipedia/commons/c/c8/Chest_Xray_PA_3-8-2010.png"
image = Image.open(requests.get(image_url, headers={"User-Agent": "example"}, stream=True).raw)
messages = [
{
"role": "system",
"content": [{"type": "text", "text": "You are an expert radiologist."}]
},
{
"role": "user",
"content": [
{"type": "text", "text": "Describe this X-ray"},
{"type": "image", "image": image}
]
}
]
output = pipe(text=messages, max_new_tokens=200)
print(output["generated_text"][-1]["content"])
pip install accelerate
from transformers import AutoProcessor, AutoModelForImageTextToText
from PIL import Image
import requests
import torch
model_id = "clair-health"
model = AutoModelForImageTextToText.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
processor = AutoProcessor.from_pretrained(model_id)
# Image attribution: Stillwaterising, CC0, via Wikimedia Commons
image_url = "https://upload.wikimedia.org/wikipedia/commons/c/c8/Chest_Xray_PA_3-8-2010.png"
image = Image.open(requests.get(image_url, headers={"User-Agent": "example"}, stream=True).raw)
messages = [
{
"role": "system",
"content": [{"type": "text", "text": "You are an expert radiologist."}]
},
{
"role": "user",
"content": [
{"type": "text", "text": "Describe this X-ray"},
{"type": "image", "image": image}
]
}
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device, dtype=torch.bfloat16)
input_len = inputs["input_ids"].shape[-1]
with torch.inference_mode():
generation = model.generate(**inputs, max_new_tokens=200, do_sample=False)
generation = generation[input_len:]
decoded = processor.decode(generation, skip_special_tokens=True)
print(decoded)
This model is provided for informational and research purposes only. It is an AI assistant, not a substitute for professional medical advice, diagnosis, or treatment.