Instructions to use icdevelop/pai1-medgemma-4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use icdevelop/pai1-medgemma-4b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="icdevelop/pai1-medgemma-4b") 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("icdevelop/pai1-medgemma-4b") model = AutoModelForMultimodalLM.from_pretrained("icdevelop/pai1-medgemma-4b", 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 icdevelop/pai1-medgemma-4b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "icdevelop/pai1-medgemma-4b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "icdevelop/pai1-medgemma-4b", "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/icdevelop/pai1-medgemma-4b
- SGLang
How to use icdevelop/pai1-medgemma-4b 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 "icdevelop/pai1-medgemma-4b" \ --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": "icdevelop/pai1-medgemma-4b", "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 "icdevelop/pai1-medgemma-4b" \ --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": "icdevelop/pai1-medgemma-4b", "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 icdevelop/pai1-medgemma-4b with Docker Model Runner:
docker model run hf.co/icdevelop/pai1-medgemma-4b
license: other
license_name: health-ai-developer-foundations
license_link: https://developers.google.com/health-ai-developer-foundations/terms
base_model: google/medgemma-4b-it
pipeline_tag: image-text-to-text
library_name: transformers
language:
- th
- en
tags:
- medical
- pharmacy
- thai
- medgemma
- gemma3
- lora
- rag
extra_gated_prompt: >-
You must read and accept the Access Agreement before downloading. This model
is not a medical device and must be operated under the supervision of a
licensed pharmacist. By accepting, you acknowledge that: (1) it is not for
diagnosis or treatment and all output must be reviewed by a licensed
pharmacist; (2) part of the drug knowledge base is AI-generated and not yet
pharmacist-reviewed, so it may contain inaccuracies; (3) you accept the risk
and responsibility of your own use, and the developer accepts no liability for
resulting harm; (4) you are bound by the HAI-DEF Terms
(https://developers.google.com/health-ai-developer-foundations/terms); (5)
clinical use on real patients without a supervising pharmacist or physician is
prohibited.
extra_gated_fields:
I acknowledge this is not a medical device and requires licensed-pharmacist supervision: checkbox
I accept the risk and the HAI-DEF Terms: checkbox
Organization / User: text
pai1-medgemma-4b β Thai Pharmacy Assistant (RAG, standard tier)
β οΈ This model MUST be used with RAG + the Knowledge Base
Read before use
This model is not a self-contained drug knowledge store. If it is served on its own and queried
directly without retrieved context, it will generate inaccurate drug information. For every query
you must retrieve real drug facts from the knowledge base (icdevelop/thai-pharma-kb) and inject
them into the prompt. See rag_example.py.
| Usage | Lookup (brand/route/interaction) | Deliberation |
|---|---|---|
| Model alone (no RAG) | 33.0% | β |
| + RAG (required) | 55.0% | 37.5% |
| previous release (v1.3) + RAG | 52.0% | 22.5% |
| base-4b + RAG (not usable) | 40.5% | β |
What's new in this version: a +15-point jump in deliberation (22.5% β 37.5%) β the model now reasons like a clinician (rules out a drug contraindicated for the patient, recommends a safe alternative, asks for history when information is insufficient) instead of reciting the retrieved record. Lookup+RAG also improved (52% β 55%). Trade-off: standalone no-RAG recall dropped (42% β 33%), acceptable because this model must always be used with RAG.
DRAFT card β pharmacist and legal review required before public release. The KB is not yet pharmacist-reviewed.
A Thai community-pharmacy assistant (4B) fine-tuned from google/medgemma-4b-it by I C Develop Co., Ltd.
This is the small, fast, economical tier (the larger tier is pai1-medgemma-27b).
Use with RAG only β and for the 4B tier, use this fine-tuned model, not the base
Deterministic benchmark results (especially important for 4B):
Usage Lookup Deliberation This model alone (no RAG) 33.0% β This model + RAG 55.0% 37.5% base-4b + RAG (reference) 40.5% β Difference from the 27B tier: the base 4B is too small to read retrieved context on its own. This fine-tuned model was trained to use context (RAG-aware) and to deliberate, reaching 55% lookup / 37.5% deliberation with RAG β so this model must be used rather than the base 4B.
Not a medical device
- Not a medical device. All output must be reviewed by a licensed pharmacist before real-world use.
- Thai community-pharmacy domain only. Image input = medicine boxes / labels / prescriptions; it does not read X-rays or lab films.
How to use (RAG β see rag_example.py)
vllm serve icdevelop/pai1-medgemma-4b --dtype bfloat16 --max-model-len 8192 \
--served-model-name pai --seed 0 --enforce-eager
huggingface-cli download icdevelop/thai-pharma-kb --repo-type dataset
Retrieve real drug facts from the TMT registry / KB and inject them into the prompt on every call
(same format as the 27B tier β see rag_example.py). The reference block and question are written in
Thai, since the model is purpose-built for Thai.
Data provenance & review status
| Source | Count | Status |
|---|---|---|
| TMT drug registry (Thai MoPH) | 31,034 products | Official government data |
| Ingredient KB | 1,918 ingredients | AI-generated β not yet pharmacist-reviewed (534 flagged for review) |
RAG knowledge cutoff (data freshness)
The knowledge available to this model is bounded by the RAG knowledge base, not the model weights.
- Knowledge base:
icdevelop/thai-pharma-kbv16 Β· knowledge cutoff: 2026-07-23 - TMT drug registry snapshot: 2026-07-20 (Thai MoPH)
- Ingredient KB generated: up to 2026-07-23
Drugs, brands, supplements, or regulatory changes registered after 2026-07-23 are not reflected.
To advance the cutoff, re-pull the TMT registry and rebuild the KB, then update the thai-pharma-kb dataset.
Benchmark
thai_pharma_bench_v2(lookup) β 200 held-out cases, ground truth from TMT + KB.deliberation_bench_v1β 120 held-out cases where the obvious/top retrieved drug is contraindicated for the patient's disclosed profile; an LLM judge scores whether the model rules it out and recommends a safe alternative (reasoning, not recitation).
Both deterministic (--enforce-eager, --seed 0).
Limitations & safety
- Must always be used with RAG. The model alone recalls drug information poorly (33%).
- 4B < 27B β use the 27B tier for tasks requiring higher accuracy.
- Not a medical device. Requires pharmacist review. The KB is not yet reviewed and may be inaccurate.
License (HAI-DEF)
A Model Derivative of google/medgemma-4b-it under the Health AI Developer Foundations Terms.
Redistribution requires: attaching the Terms + the Β§3.2 use restrictions + the NOTICE + a modification notice.
Not a medical device; not for clinical use without a licensed pharmacist. Contact: I C Develop Co., Ltd.