medGemma 1.5 Multimodal (Y khoa)

Model y khoa multimodal chính thức từ Google. Hỗ trợ text + image input. Chuyên biệt cho phân tích hình ảnh y khoa (X-quang, CT, MRI) và trả lời câu hỏi lâm sàng. vLLM backend trực tiếp (không qua FastAPI proxy).

Hoạt động Thử nghiệm
Giới thiệu: Google medGemma 1.5 (4B tham số) là mô hình ngôn ngữ lớn chuyên biệt y khoa, được huấn luyện trên dữ liệu lâm sàng và hình ảnh y tế. Hỗ trợ multimodal: phân tích ảnh X-quang, CT, MRI, siêu âm, ảnh da liễu; trả lời câu hỏi lâm sàng; hỗ trợ chẩn đoán. Chạy trên GPU RTX 5060 Ti 16GB (CVD=1) với vLLM 0.19.1.
~8
Tốc độ (tokens/s)
4B
Parameters (bfloat16)
8K
Context Window (config 4K)
Multimodal (image+text)

Base URL

https://pnt.badt.vn/medgemma/
Lưu ý: medGemma dùng vLLM trực tiếp (OpenAI-compatible API), không có FastAPI proxy riêng. Tất cả endpoint chuẩn OpenAI đều khả dụng.

API Endpoints

POST /medgemma/v1/chat/completions OpenAI Compatible Recommended

Chat completion hỗ trợ cả text-only và multimodal (image+text).

Parameters

ParamTypeRequiredDefaultDescription
messagesarrayYesMảng message với {role, content}. content có thể là string hoặc array (multimodal)
modelstringYesmedgemma-1.5-4b-it
temperaturefloatNo0.70.0 - 2.0
max_tokensintNo10241 - 4096
top_pfloatNo0.95Nucleus sampling
streamboolNofalseStreaming SSE
POST /medgemma/v1/chat/completions Text-only

Ví dụ cURL (Text)

curl -X POST "https://pnt.badt.vn/medgemma/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "medgemma-1.5-4b-it",
    "messages": [
      {"role": "user", "content": "Mô tả triệu chứng đau ngực"}
    ],
    "temperature": 0.7,
    "max_tokens": 500
  }'
POST /medgemma/v1/chat/completions Multimodal Image+Text
Multimodal: Gửi ảnh y khoa (X-quang, CT, MRI, siêu âm, da liễu) dưới dạng base64 data URL.

Ví dụ cURL (Image + Text)

# Ảnh base64
IMAGE_BASE64="…base64_encoded_image…"

curl -X POST "https://pnt.badt.vn/medgemma/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "medgemma-1.5-4b-it",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "Phân tích hình ảnh X-quang này"},
          {
            "type": "image_url",
            "image_url": {
              "url": "data:image/png;base64,'"${IMAGE_BASE64}"'"
            }
          }
        ]
      }
    ],
    "max_tokens": 500
  }'

Ví dụ Python (Multimodal)

import base64, requests

# Encode image to base64
with open("xquang.png", "rb") as f:
    b64 = base64.b64encode(f.read()).decode()

response = requests.post(
    "https://pnt.badt.vn/medgemma/v1/chat/completions",
    json={
        "model": "medgemma-1.5-4b-it",
        "messages": [{
            "role": "user",
            "content": [
                {"type": "text", "text": "Describe this chest X-ray"},
                {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}}
            ]
        }],
        "max_tokens": 500
    }
)
print(response.json()["choices"][0]["message"]["content"])

Yêu cầu ảnh

PropertyGiá trị
FormatPNG, JPG, WEBP
EncodingBase64 data URL (data:image/png;base64,...)
Max size50 MB (nginx limit)
Image tokens~280 tokens / ảnh (tự động)
GET /medgemma/v1/models Utility

Liệt kê model đang phục vụ.

GET /medgemma/health Utility

Health check vLLM backend.

Use Cases Y khoa

Lĩnh vựcVí dụ prompt
Phân tích X-quang"Describe this chest X-ray. Are there any abnormalities?"
CT/MRI"Mô tả hình ảnh CT scan não này"
Da liễu"What condition does this skin lesion suggest?"
Siêu âm"Phân tích hình ảnh siêu âm ổ bụng"
Chẩn đoán"Bệnh nhân đau ngực trái, khó thở. Chẩn đo;án phân biệt?"
Giải thích"Giải thích kết quả xét nghiệm máu này"

Mã lỗi

StatusÝ nghĩaXử lý
400Bad RequestSai schema request (thiếu model, messages)
500Internal ErrorvLLM engine error (vision tower, OOM)
502Bad GatewayvLLM chưa sẵn sàng hoặc đã chết

Thông số kỹ thuật

ModelGoogle medGemma 1.5 4B (bfloat16)
ArchitectureGemma3ForConditionalGeneration
vLLM namemedgemma-1.5-4b-it
Parameters~4B (bfloat16)
Context8192 (config 4096)
vLLM Port8094
GPUCVD=1 RTX 5060 Ti 16GB
VRAM~8 GB model + ~3 GB KV cache
MultimodalBase64 image (PNG/JPG/WEBP)
Notes--skip-mm-profiling --enforce-eager