Image-Text-to-Text
Transformers
GGUF
gemma3
medical
radiology
clinical-reasoning
dermatology
pathology
ophthalmology
chest-x-ray
conversational
Instructions to use second-state/medgemma-4b-it-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use second-state/medgemma-4b-it-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="second-state/medgemma-4b-it-GGUF") 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("second-state/medgemma-4b-it-GGUF") model = AutoModelForMultimodalLM.from_pretrained("second-state/medgemma-4b-it-GGUF") - llama-cpp-python
How to use second-state/medgemma-4b-it-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="second-state/medgemma-4b-it-GGUF", filename="medgemma-4b-it-Q2_K.gguf", )
llm.create_chat_completion( 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" } } ] } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use second-state/medgemma-4b-it-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf second-state/medgemma-4b-it-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf second-state/medgemma-4b-it-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf second-state/medgemma-4b-it-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf second-state/medgemma-4b-it-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf second-state/medgemma-4b-it-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf second-state/medgemma-4b-it-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf second-state/medgemma-4b-it-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf second-state/medgemma-4b-it-GGUF:Q4_K_M
Use Docker
docker model run hf.co/second-state/medgemma-4b-it-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use second-state/medgemma-4b-it-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "second-state/medgemma-4b-it-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "second-state/medgemma-4b-it-GGUF", "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/second-state/medgemma-4b-it-GGUF:Q4_K_M
- SGLang
How to use second-state/medgemma-4b-it-GGUF 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 "second-state/medgemma-4b-it-GGUF" \ --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": "second-state/medgemma-4b-it-GGUF", "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 "second-state/medgemma-4b-it-GGUF" \ --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": "second-state/medgemma-4b-it-GGUF", "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" } } ] } ] }' - Ollama
How to use second-state/medgemma-4b-it-GGUF with Ollama:
ollama run hf.co/second-state/medgemma-4b-it-GGUF:Q4_K_M
- Unsloth Studio
How to use second-state/medgemma-4b-it-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for second-state/medgemma-4b-it-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for second-state/medgemma-4b-it-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for second-state/medgemma-4b-it-GGUF to start chatting
- Atomic Chat new
- Docker Model Runner
How to use second-state/medgemma-4b-it-GGUF with Docker Model Runner:
docker model run hf.co/second-state/medgemma-4b-it-GGUF:Q4_K_M
- Lemonade
How to use second-state/medgemma-4b-it-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull second-state/medgemma-4b-it-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.medgemma-4b-it-GGUF-Q4_K_M
List all available models
lemonade list
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: google/medgemma-4b-it
|
| 3 |
+
inference: false
|
| 4 |
+
library_name: transformers
|
| 5 |
+
license: other
|
| 6 |
+
license_name: health-ai-developer-foundations
|
| 7 |
+
license_link: https://developers.google.com/health-ai-developer-foundations/terms
|
| 8 |
+
model_creator: Google
|
| 9 |
+
model_name: medgemma-4b-it
|
| 10 |
+
quantized_by: Second State Inc.
|
| 11 |
+
pipeline_tag: image-text-to-text
|
| 12 |
+
tags:
|
| 13 |
+
- medical
|
| 14 |
+
- radiology
|
| 15 |
+
- clinical-reasoning
|
| 16 |
+
- dermatology
|
| 17 |
+
- pathology
|
| 18 |
+
- ophthalmology
|
| 19 |
+
- chest-x-ray
|
| 20 |
---
|
| 21 |
+
|
| 22 |
+
<!-- header start -->
|
| 23 |
+
<!-- 200823 -->
|
| 24 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
| 25 |
+
<img src="https://github.com/LlamaEdge/LlamaEdge/raw/dev/assets/logo.svg" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
| 26 |
+
</div>
|
| 27 |
+
<hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
|
| 28 |
+
<!-- header end -->
|
| 29 |
+
|
| 30 |
+
# medgemma-4b-it-GGUF
|
| 31 |
+
|
| 32 |
+
## Original Model
|
| 33 |
+
|
| 34 |
+
[google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it)
|
| 35 |
+
|
| 36 |
+
## Run with LlamaEdge
|
| 37 |
+
|
| 38 |
+
- LlamaEdge version: [v0.18.5](https://github.com/LlamaEdge/LlamaEdge/releases/tag/0.18.5) and above
|
| 39 |
+
|
| 40 |
+
- Prompt template
|
| 41 |
+
|
| 42 |
+
- Prompt type: `gemma-3`
|
| 43 |
+
|
| 44 |
+
- Prompt string
|
| 45 |
+
|
| 46 |
+
```text
|
| 47 |
+
<bos><start_of_turn>user
|
| 48 |
+
{user_message}<end_of_turn>
|
| 49 |
+
<start_of_turn>model
|
| 50 |
+
{model_message}<end_of_turn>model
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
- Context size: `128000`
|
| 54 |
+
|
| 55 |
+
- Run as LlamaEdge service
|
| 56 |
+
|
| 57 |
+
- Chat
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
wasmedge --dir .:. --nn-preload default:GGML:AUTO:medgemma-4b-it-Q5_K_M.gguf \
|
| 61 |
+
llama-api-server.wasm \
|
| 62 |
+
--prompt-template gemma-3 \
|
| 63 |
+
--ctx-size 128000 \
|
| 64 |
+
--model-name medgemma-4b
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
- Images
|
| 68 |
+
|
| 69 |
+
**Note that input images are required to be normalized to 896 x 896 resolution and encoded to 256 tokens each**
|
| 70 |
+
|
| 71 |
+
```bash
|
| 72 |
+
wasmedge --dir .:. --nn-preload default:GGML:AUTO:medgemma-4b-it-Q5_K_M.gguf \
|
| 73 |
+
llama-api-server.wasm \
|
| 74 |
+
--prompt-template gemma-3 \
|
| 75 |
+
--llava-mmproj medgemma-4b-it-mmproj-f16.gguf \
|
| 76 |
+
--ctx-size 128000 \
|
| 77 |
+
--model-name medgemma-4b
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
- Run as LlamaEdge command app
|
| 81 |
+
|
| 82 |
+
```bash
|
| 83 |
+
wasmedge --dir .:. \
|
| 84 |
+
--nn-preload default:GGML:AUTO:medgemma-4b-it-Q5_K_M.gguf \
|
| 85 |
+
llama-chat.wasm \
|
| 86 |
+
--prompt-template gemma-3 \
|
| 87 |
+
--ctx-size 128000
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
## Quantized GGUF Models
|
| 91 |
+
|
| 92 |
+
| Name | Quant method | Bits | Size | Use case |
|
| 93 |
+
| ---- | ---- | ---- | ---- | ----- |
|
| 94 |
+
| [medgemma-4b-it-Q2_K.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q2_K.gguf) | Q2_K | 2 | 1.73 GB| smallest, significant quality loss - not recommended for most purposes |
|
| 95 |
+
| [medgemma-4b-it-Q3_K_L.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q3_K_L.gguf) | Q3_K_L | 3 | 2.24 GB| small, substantial quality loss |
|
| 96 |
+
| [medgemma-4b-it-Q3_K_M.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q3_K_M.gguf) | Q3_K_M | 3 | 2.10 GB| very small, high quality loss |
|
| 97 |
+
| [medgemma-4b-it-Q3_K_S.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q3_K_S.gguf) | Q3_K_S | 3 | 1.94 GB| very small, high quality loss |
|
| 98 |
+
| [medgemma-4b-it-Q4_0.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q4_0.gguf) | Q4_0 | 4 | 2.36 GB| legacy; small, very high quality loss - prefer using Q3_K_M |
|
| 99 |
+
| [medgemma-4b-it-Q4_K_M.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q4_K_M.gguf) | Q4_K_M | 4 | 2.49 GB| medium, balanced quality - recommended |
|
| 100 |
+
| [medgemma-4b-it-Q4_K_S.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q4_K_S.gguf) | Q4_K_S | 4 | 2.38 GB| small, greater quality loss |
|
| 101 |
+
| [medgemma-4b-it-Q5_0.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q5_0.gguf) | Q5_0 | 5 | 2.76 GB| legacy; medium, balanced quality - prefer using Q4_K_M |
|
| 102 |
+
| [medgemma-4b-it-Q5_K_M.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q5_K_M.gguf) | Q5_K_M | 5 | 2.83 GB| large, very low quality loss - recommended |
|
| 103 |
+
| [medgemma-4b-it-Q5_K_S.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q5_K_S.gguf) | Q5_K_S | 5 | 2.76 GB| large, low quality loss - recommended |
|
| 104 |
+
| [medgemma-4b-it-Q6_K.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q6_K.gguf) | Q6_K | 6 | 3.19 GB| very large, extremely low quality loss |
|
| 105 |
+
| [medgemma-4b-it-Q8_0.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-Q8_0.gguf) | Q8_0 | 8 | 4.13 GB| very large, extremely low quality loss - not recommended |
|
| 106 |
+
| [medgemma-4b-it-f16.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-f16.gguf) | f16 | 16 | 7.77 GB| |
|
| 107 |
+
| [medgemma-4b-it-mmproj-f16.gguf](https://huggingface.co/second-state/medgemma-4b-it-GGUF/blob/main/medgemma-4b-it-mmproj-f16.gguf) | f16 | 16 | 851 MB| |
|
| 108 |
+
|
| 109 |
+
*Quantized with llama.cpp b5452*
|