Text Generation
Transformers
Safetensors
English
gemma3
image-text-to-text
medgemma
gemma
medical
healthcare
pneumonia
conversational
text-generation-inference
Instructions to use Programmerlb/medgemma1.5-4b-pneumonia-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Programmerlb/medgemma1.5-4b-pneumonia-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Programmerlb/medgemma1.5-4b-pneumonia-lora") 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("Programmerlb/medgemma1.5-4b-pneumonia-lora") model = AutoModelForMultimodalLM.from_pretrained("Programmerlb/medgemma1.5-4b-pneumonia-lora") 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 Programmerlb/medgemma1.5-4b-pneumonia-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Programmerlb/medgemma1.5-4b-pneumonia-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Programmerlb/medgemma1.5-4b-pneumonia-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Programmerlb/medgemma1.5-4b-pneumonia-lora
- SGLang
How to use Programmerlb/medgemma1.5-4b-pneumonia-lora 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 "Programmerlb/medgemma1.5-4b-pneumonia-lora" \ --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": "Programmerlb/medgemma1.5-4b-pneumonia-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Programmerlb/medgemma1.5-4b-pneumonia-lora" \ --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": "Programmerlb/medgemma1.5-4b-pneumonia-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Programmerlb/medgemma1.5-4b-pneumonia-lora with Docker Model Runner:
docker model run hf.co/Programmerlb/medgemma1.5-4b-pneumonia-lora
Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
library_name: transformers
|
| 5 |
+
pipeline_tag: text-generation
|
| 6 |
+
tags:
|
| 7 |
+
- medgemma
|
| 8 |
+
- gemma
|
| 9 |
+
- medical
|
| 10 |
+
- healthcare
|
| 11 |
+
- pneumonia
|
| 12 |
+
base_model: google/medgemma-1.5-4b-it
|
| 13 |
+
widget:
|
| 14 |
+
- text: "I have fever and cough for 3 days. What should I do?"
|
| 15 |
+
- text: "65-year-old with shortness of breath and chest pain. Is this urgent?"
|
| 16 |
+
- text: "What are red flags that should make me seek emergency care?"
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# MedGemma 1.5 4B – Pneumonia (Merged)
|
| 20 |
+
|
| 21 |
+
This repository contains a **merged fine-tuned MedGemma model** focused on pneumonia-related clinical guidance.
|
| 22 |
+
|
| 23 |
+
> ⚠️ **Disclaimer**
|
| 24 |
+
> Educational and research use only. Not for real medical diagnosis or treatment.
|
| 25 |
+
|
| 26 |
+
## Base model
|
| 27 |
+
- google/medgemma-1.5-4b-it
|
| 28 |
+
|
| 29 |
+
## Quickstart (Transformers)
|
| 30 |
+
|
| 31 |
+
```python
|
| 32 |
+
!pip install -U transformers accelerate sentencepiece safetensors
|
| 33 |
+
|
| 34 |
+
import torch
|
| 35 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 36 |
+
|
| 37 |
+
repo_id = "Programmerlb/medgemma1.5-4b-pneumonia-lora"
|
| 38 |
+
|
| 39 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
|
| 40 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 41 |
+
repo_id,
|
| 42 |
+
device_map="auto",
|
| 43 |
+
dtype=torch.float16,
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
prompt = "I have fever and productive cough for 5 days with shortness of breath. What should I do?"
|
| 47 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 48 |
+
output = model.generate(**inputs, max_new_tokens=200)
|
| 49 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|