Image-Text-to-Text
Transformers
Safetensors
gemma3
int8
w8a8
compressed-tensors
llm-compressor
vllm
medical
healthcare
conversational
text-generation-inference
8-bit precision
Instructions to use Demondiablo/medgemma-4b-it-int8-w8a8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Demondiablo/medgemma-4b-it-int8-w8a8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Demondiablo/medgemma-4b-it-int8-w8a8") 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("Demondiablo/medgemma-4b-it-int8-w8a8") model = AutoModelForMultimodalLM.from_pretrained("Demondiablo/medgemma-4b-it-int8-w8a8", 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 Demondiablo/medgemma-4b-it-int8-w8a8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Demondiablo/medgemma-4b-it-int8-w8a8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Demondiablo/medgemma-4b-it-int8-w8a8", "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/Demondiablo/medgemma-4b-it-int8-w8a8
- SGLang
How to use Demondiablo/medgemma-4b-it-int8-w8a8 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 "Demondiablo/medgemma-4b-it-int8-w8a8" \ --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": "Demondiablo/medgemma-4b-it-int8-w8a8", "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 "Demondiablo/medgemma-4b-it-int8-w8a8" \ --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": "Demondiablo/medgemma-4b-it-int8-w8a8", "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" } } ] } ] }' - Docker Model Runner
How to use Demondiablo/medgemma-4b-it-int8-w8a8 with Docker Model Runner:
docker model run hf.co/Demondiablo/medgemma-4b-it-int8-w8a8
MedGemma 4B-IT (INT8 W8A8 Dynamic)
This is an INT8 W8A8 Quantized version of google/medgemma-4b-it optimized for high-throughput, low-latency deployment with vLLM and compatible serving engines across all modern GPU architectures.
Quantization Details
- Base Model:
google/medgemma-4b-it - Quantization Method: llm-compressor
- Quantization Scheme:
W8A8(Weights in INT8 per-channel symmetric, activations in dynamic INT8 per-token) - Format:
compressed-tensors(native vLLM format) - Excluded Modules:
lm_head,embed_tokens,multi_modal_projector, and vision tower linear layers preserved for clinical accuracy. - Quantized On: NVIDIA RTX PRO 6000 Blackwell Server Edition
Deployment & Usage
1. High-Performance Inference with vLLM (Recommended)
from vllm import LLM, SamplingParams
model_name = "Demondiablo/medgemma-4b-it-int8-w8a8"
llm = LLM(
model=model_name,
trust_remote_code=True,
max_model_len=4096,
)
sampling_params = SamplingParams(
temperature=0.2,
max_tokens=2048,
)
prompt = "You are a clinical AI. Summarize the following prescription: Tablet Thyronorm 50 mcg OD."
outputs = llm.generate([prompt], sampling_params)
print(outputs[0].outputs[0].text)
2. Inference with Transformers
import torch
from transformers import AutoProcessor, AutoModelForImageTextToText
model_name = "Demondiablo/medgemma-4b-it-int8-w8a8"
processor = AutoProcessor.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
prompt = "Extract medications: Capsule Desula 21 HS, Thyronorm 50 mg OD."
inputs = processor(text=prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=512)
print(processor.decode(outputs[0], skip_special_tokens=True))
Hardware Compatibility
INT8 W8A8 acceleration is supported across virtually all modern NVIDIA architectures:
- NVIDIA Turing (T4, RTX 2080 Ti)
- NVIDIA Ampere (A100, A10, RTX 3090, A6000)
- NVIDIA Ada Lovelace (RTX 4090, L4, L40S, RTX 6000 Ada)
- NVIDIA Hopper (H100, H200)
- NVIDIA Blackwell (RTX PRO 6000 Blackwell, B100, B200)
- Downloads last month
- 17