You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

ต้องอ่านและยอมรับก่อนดาวน์โหลด / You must read and accept before downloading.

โมเดลและข้อมูลนี้ ไม่ใช่เครื่องมือแพทย์ ไม่ใช่แพทย์หรือเภสัชกร และไม่ใช่คำแนะนำทางการแพทย์ ข้อมูลบางส่วนสร้างโดย AI และ ยังไม่ได้รับการตรวจสอบโดยเภสัชกร (อยู่ระหว่างการตรวจสอบ) จึงอาจมีความคลาดเคลื่อน ผู้ใช้ต้องให้ผู้เชี่ยวชาญ (เภสัชกร/แพทย์) ตรวจสอบข้อมูลก่อนนำโมเดลนี้หรือข้อมูลนี้ไปใช้ และผลลัพธ์ทุกอย่างต้องผ่านการตรวจสอบโดยเภสัชกรที่มีใบอนุญาต ห้ามใช้กับผู้ป่วยจริงโดยไม่มีเภสัชกร/แพทย์กำกับดูแล

This model/data is not a medical device, not a doctor or pharmacist, and not medical advice. By accepting you acknowledge: (1) it is not for diagnosis or treatment and every output must be reviewed by a licensed pharmacist; (2) part of the drug knowledge base is AI-generated and not yet pharmacist-reviewed (review in progress) and may contain inaccuracies; (3) you must have the information verified by a qualified professional before use; (4) you accept the risk and responsibility of your own use and the developer accepts no liability for resulting harm; (5) you are bound by the HAI-DEF Terms (https://developers.google.com/health-ai-developer-foundations/terms); (6) clinical use on real patients without a supervising pharmacist or physician is prohibited.

Log in or Sign Up to review the conditions and access this model content.

pai1-medgemma-4b — Thai Pharmacy Assistant (v25-DPO, standard tier)

⚠️ DRAFT — pharmacist & legal review pending. The drug knowledge base is AI-generated and not yet pharmacist-reviewed (review in progress). Released under an acknowledge-before-download gate. All output must be verified by a licensed pharmacist before real use.

A Thai community-pharmacy assistant (4B) fine-tuned from google/medgemma-4b-it by I C Develop Co., Ltd. — the small, fast, economical tier (premium tier: icdevelop/pai1-medgemma-27b).

⚠️ This model MUST be used with RAG + the Knowledge Base

It is not a self-contained drug store. Queried alone it will generate inaccurate drug info. For every query, retrieve real facts from icdevelop/thai-pharma-kb and inject them into the prompt. See rag_example.py. The 4B base is too small to read context on its own — use this fine-tuned model, not the base.

Benchmarks (deterministic, seed 0; verified case counts 200/200/120)

Usage lookup lookup + RAG deliberation
v25-DPO (this release) alone (no RAG) 37.5%
v25-DPO + RAG (intended use) 64.0% 48.3%
v24-DPO + RAG 62.5% 40.0%
v24 SFT + RAG 53.0% 44.2%
v20 + RAG (previous) 55.0% 37.5%

What's new in v25-DPO: SFT on the improved deliberation set (deliberate_v2) followed by a DPO (Direct Preference Optimization) refinement stage. This release beats v20 on all three axes and has the best 4B lookup+RAG score yet (55% → 62.5%) — RAG-grounded is the production setting. Deliberation lineage: v13 22.5% → v20 37.5% → v24-SFT 44.2% → v25-DPO 40.0% (DPO traded ~4 pt of pure deliberation to recover lookup/RAG well beyond v20). Use RAG always; deliberation stays clinician-style (rules out a contraindicated drug, recommends a safe alternative, asks for history when info is insufficient).

How it was trained (for reproducibility & trust)

  • Base: google/medgemma-4b-it (Google MedGemma, Gemma-3 multimodal). Fine-tuned by I C Develop Co., Ltd.
  • Method: LoRA (rank 64) via LLaMA-Factory. Vision tower + multi-modal projector frozen (text-only adaptation). Two stages: SFT (thai_pharma_v24, 33,760 examples, 2 epochs, LR 1e-4) then a combined DPO (preference set dpo_v25 = 2,872 OTC-accuracy pairs + 3,776 deliberation pairs, sigmoid loss, β 0.1, LR 5e-6). The deliberation pairs (chosen = deliberates, rejected = recites the contraindicated drug) reward reasoning directly, so deliberation rises instead of drifting down.
  • Training corpus (thai_pharma_v24): curated Thai pharmacy dialogues — brand/route/interaction lookup, supplement & vitamin guidance, professional-register Q&A, TMT product grounding, drug-interaction cases, and the deliberation set below. Exact + MinHash-LSH dedup, then decontaminated against every eval set (train/test leakage removed → honest scores).
  • Deliberation data (deliberate_v2): multi-turn dialogues where ≥1 retrieved candidate is contraindicated for the customer's disclosed profile. The teacher takes history → rules out the unsafe option with a reason → recommends a safe alternative → gives dose/cautions from facts → refers on red flags, and asks for more history when info is insufficient. A verifier rejects any turn that hard-diagnoses, impersonates a physician, or merely recites — enforcing the design goal: reason like a clinician internally, present as a pharmacy assistant externally (legally required in Thailand).

How the benchmark was run (why these scores mean something)

Deterministic — served on vLLM with --seed 0 --enforce-eager, scored by an LLM judge (0-10; "pass" = judge ≥ threshold), held-out and decontaminated from training.

  • thai_pharma_bench_v2 (lookup, 200): brand/route/interaction facts; ground truth = TMT + KB.
  • thai_pharma_bench_v2_rag (lookup+RAG, 200): same, with real KB facts retrieved into the prompt — the production setting.
  • deliberation_bench_v1 (120): the top retrieved drug is contraindicated for the patient; judge scores whether the model rules it out and recommends a safe alternative (reasoning, not recitation).

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

On every call, retrieve real drug facts from the TMT registry / KB and inject them into the prompt (Thai reference block + Thai question). For maximum benefit: always ground with RAG, keep the retrieved facts in the prompt, and let the model take history before recommending. See rag_example.py.

Data provenance & review status

Source Count Status
TMT drug registry (Thai MoPH) ~31,000 products Official government data
Ingredient KB 1,918 ingredients AI-generated — not yet pharmacist-reviewed (534 flagged)

RAG knowledge cutoff (data freshness)

Knowledge is bounded by the RAG knowledge base, not the weights.

  • Knowledge base: icdevelop/thai-pharma-kb · knowledge cutoff: July 2026
  • Drugs/brands/regulatory changes after that date are not reflected.

Limitations & safety

  • Must always be used with RAG. The model alone recalls drug info poorly.
  • Not a medical device. Every output must be reviewed by a licensed pharmacist. The KB is not yet pharmacist-reviewed and may be inaccurate (534 flagged). Thai community-pharmacy domain only; image input = medicine boxes / labels / prescriptions — not X-rays or lab films.

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.

Downloads last month
150
Safetensors
Model size
4B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for icdevelop/pai1-medgemma-4b

Adapter
(111)
this model

Collection including icdevelop/pai1-medgemma-4b