Instructions to use bisonnetworking/medgemma-health-chat-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use bisonnetworking/medgemma-health-chat-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/medgemma-1.5-4b-it") model = PeftModel.from_pretrained(base_model, "bisonnetworking/medgemma-health-chat-lora") - Transformers
How to use bisonnetworking/medgemma-health-chat-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bisonnetworking/medgemma-health-chat-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("bisonnetworking/medgemma-health-chat-lora", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bisonnetworking/medgemma-health-chat-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bisonnetworking/medgemma-health-chat-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": "bisonnetworking/medgemma-health-chat-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/bisonnetworking/medgemma-health-chat-lora
- SGLang
How to use bisonnetworking/medgemma-health-chat-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 "bisonnetworking/medgemma-health-chat-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": "bisonnetworking/medgemma-health-chat-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 "bisonnetworking/medgemma-health-chat-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": "bisonnetworking/medgemma-health-chat-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use bisonnetworking/medgemma-health-chat-lora 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 bisonnetworking/medgemma-health-chat-lora 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 bisonnetworking/medgemma-health-chat-lora to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for bisonnetworking/medgemma-health-chat-lora to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="bisonnetworking/medgemma-health-chat-lora", max_seq_length=2048, ) - Docker Model Runner
How to use bisonnetworking/medgemma-health-chat-lora with Docker Model Runner:
docker model run hf.co/bisonnetworking/medgemma-health-chat-lora
MedGemma Health Chat LoRA Adapter
Model Description
A LoRA adapter fine-tuned on google/medgemma-1.5-4b-it for multi-persona health chat conversations. The model responds as one of six medical personas (primary care, internal medicine, clinical nutritionist, exercise specialist, integrated physician, chronic health specialist) with direct, clinically grounded guidance optimized for mobile display.
Intended Use
- Health chat assistant for patient-facing applications
- Provides clinical guidance in a conversational format
- Designed for mobile-first display (no tables, concise prose)
- Each conversation assigns a persona based on topic relevance
Not intended for: diagnosing conditions, replacing professional medical care, or emergency triage.
Personas
| Persona | File | Specialty |
|---|---|---|
| Primary Care | primary_care_tight.txt |
General practice, common conditions, preventive care |
| Internal Medicine | internal_medicine_tight.txt |
Complex adult medicine, multi-system disorders |
| Clinical Nutritionist | clinical_nutritionist_tight.txt |
Dietary interventions, nutritional therapy |
| Exercise Specialist | exercise_specialist_tight.txt |
Therapeutic exercise, sports performance, rehab |
| Best Doctor | best_doctor.txt |
Cross-specialty integration, OLDCARTS methodology |
| Chronic Health | daveshap_chronic_health_ai.txt |
Chronic illness management, diagnostic mysteries |
Training Data
- Dataset: bisonnetworking/medgemma-health-chat-sft
- Training samples: 49,500 conversations
- Eval samples: 500 conversations
- Format: ShareGPT/conversational JSONL with system (persona prompt) + user + assistant turns
- Health context: Simulated Apple Health data (vitals, labs, medications, conditions) injected into user messages
Training Procedure
LoRA Configuration
- Rank (r): 32
- Alpha: 64
- Dropout: 0
- Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
- Trainable parameters: 65,576,960 (1.50% of 4,365,656,432 total)
Training Hyperparameters
- Epochs: 2
- Batch size: 8 (per-device)
- Learning rate: 2e-4 (cosine scheduler)
- Warmup ratio: 0.03
- Optimizer: adamw_8bit
- Weight decay: 0.01
- Max sequence length: 2048
- Precision: bf16
- Packing: True
Training Results
- Total steps: 12,376
- Final training loss: 0.7981
- Best eval loss: 0.8779 (step 12,000)
- Final eval loss: 0.8779
Compute Infrastructure
- Hardware: NVIDIA H100 80GB (Modal serverless)
- Software: Unsloth 2025.7.8, Transformers 4.54.0, TRL 0.19.1, PEFT 0.16.0
- Training time: ~3 hours
- Framework: Modal
How to Use
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model = "google/medgemma-1.5-4b-it"
adapter_model = "bisonnetworking/medgemma-health-chat-lora"
# Load base model
model = AutoModelForCausalLM.from_pretrained(
base_model, torch_dtype=torch.float16, trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(base_model)
# Load LoRA adapter
model = PeftModel.from_pretrained(model, adapter_model)
model = model.merge_and_unload()
# Generate
messages = [
{"role": "system", "content": "You are a board-certified Primary Care Physician..."},
{"role": "user", "content": "I've had a sore throat for 3 days. What should I do?"},
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
outputs = model.generate(inputs, max_new_tokens=256, temperature=0.7, top_p=0.9)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Merged Model
A pre-merged 16-bit version is available at bisonnetworking/medgemma-health-chat-merged for direct use without loading a separate adapter.
Evaluation
300 test cases (50 per persona) across 6 categories:
- Medical accuracy (14 cases/persona)
- Persona adherence (9 cases/persona)
- Health context usage (10 cases/persona)
- Data integrity / no hallucination (6 cases/persona)
- Safety / emergency recognition (6 cases/persona)
- Formatting / mobile constraints (5 cases/persona)
Limitations
- Fine-tuned on synthetic conversations โ quality depends on the base model's medical knowledge
- Persona prompts enforce style but cannot guarantee clinical accuracy
- No tables in output (mobile constraint) โ may reduce clarity for complex comparisons
- Not a substitute for professional medical advice
Model Card Contact
- Downloads last month
- 25
Model tree for bisonnetworking/medgemma-health-chat-lora
Base model
google/medgemma-1.5-4b-it