Instructions to use unsloth/medgemma-27b-it-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/medgemma-27b-it-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="unsloth/medgemma-27b-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 AutoModel model = AutoModel.from_pretrained("unsloth/medgemma-27b-it-GGUF", dtype="auto") - llama-cpp-python
How to use unsloth/medgemma-27b-it-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="unsloth/medgemma-27b-it-GGUF", filename="BF16/medgemma-27b-it-BF16-00001-of-00002.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 unsloth/medgemma-27b-it-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: llama-cli -hf unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: llama-cli -hf unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
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 unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: ./llama-cli -hf unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
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 unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: ./build/bin/llama-cli -hf unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
Use Docker
docker model run hf.co/unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
- LM Studio
- Jan
- vLLM
How to use unsloth/medgemma-27b-it-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/medgemma-27b-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": "unsloth/medgemma-27b-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/unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
- SGLang
How to use unsloth/medgemma-27b-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 "unsloth/medgemma-27b-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": "unsloth/medgemma-27b-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 "unsloth/medgemma-27b-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": "unsloth/medgemma-27b-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 unsloth/medgemma-27b-it-GGUF with Ollama:
ollama run hf.co/unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
- Unsloth Studio
How to use unsloth/medgemma-27b-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 unsloth/medgemma-27b-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 unsloth/medgemma-27b-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 unsloth/medgemma-27b-it-GGUF to start chatting
- Docker Model Runner
How to use unsloth/medgemma-27b-it-GGUF with Docker Model Runner:
docker model run hf.co/unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
- Lemonade
How to use unsloth/medgemma-27b-it-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull unsloth/medgemma-27b-it-GGUF:UD-Q4_K_XL
Run and chat with the model
lemonade run user.medgemma-27b-it-GGUF-UD-Q4_K_XL
List all available models
lemonade list
Vision seems broken
I've downloaded medgemma-27b-it-UD-Q8_K_XL.gguf, and it is not able to deal with images when served via Ollama. For reference, Gemma27b works.
Here is is docker compose I used to start it on my system:
- RTX 4090D with 48GB VRAM:
- Intel Xeon W5-3525
services:
llama-small:
image: ghcr.io/ggml-org/llama.cpp:full-cuda
container_name: medgemma
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: [gpu]
ports:
- 0.0.0.0:37000:37000
volumes:
- /home/slavik/.cache:/root/.cache
entrypoint: ["./llama-server"]
# https://github.com/ggml-org/llama.cpp/tree/master/tools/server
command: >
--hf-repo unsloth/medgemma-27b-it-GGUF:UD-Q8_K_XL --hf-token hf_l****
--alias "medgemma-27b"
--ctx-size 65536
--n-gpu-layers 999
--jinja
--flash-attn
--host 0.0.0.0 --port 37000
Everything works for me. Vision works.
I see these files downloaded:
ls -hl .cache/llama.cpp/
total 31G
-rw-r--r-- 1 root root 1.4K Aug 10 02:56 'manifest=unsloth_medgemma-27b-it-GGUF=UD-Q8_K_XL.json'
-rw-r--r-- 1 root root 30G Aug 10 03:01 unsloth_medgemma-27b-it-GGUF_medgemma-27b-it-UD-Q8_K_XL.gguf
-rw-r--r-- 1 root root 221 Aug 10 03:01 unsloth_medgemma-27b-it-GGUF_medgemma-27b-it-UD-Q8_K_XL.gguf.json
-rw-r--r-- 1 root root 819M Aug 10 03:02 unsloth_medgemma-27b-it-GGUF_mmproj-F16.gguf
-rw-r--r-- 1 root root 205 Aug 10 03:02 unsloth_medgemma-27b-it-GGUF_mmproj-F16.gguf.json
I see 39GB of VRAM used.
medgemma-4090D | prompt eval time = 138.12 ms / 122 tokens ( 1.13 ms per token, 883.26 tokens per second)
medgemma-4090D | eval time = 11226.62 ms / 295 tokens ( 38.06 ms per token, 26.28 tokens per second)
I also wasn't able to get vision working properly. Yes, it loads, yes gemma "see something". But something is clearly wrong. Uploaded few xray photos - 4B medgemma had no problems describing issues, 122B qwen had no problems, this one completely hallucinated (recognized which part of body it but that's all).