Downloads · 30 days
3
6% of all-time downloads
shivam909067/gemma-2-9b-it-medical-surgeon
gemma-2-9b-it-medical-surgeon is a text generation model from shivam909067. Use it when you need the model to write or continue text. It is set up for peft.
<p align="center" <img src="https://img.shields.io/badge/ModelType-LoRAAdapter-blue?style=for-the-badge&logo=huggingface" alt="Model Type"/ <img src="https://img.shields.io/badge/Framework-Unsloth/PEFT-orange?style=fo…
Downloads · 30 days
3
6% of all-time downloads
All-time downloads
51
Public
Repo size
—
Likes
0
Public
Click a slice to open those files.
.safetensors216 MB · 85%
From the Hugging Face model README
This repository contains the LoRA adapters for Gemma-2-9B Medical Ultimate, a highly specialized medical assistant model fine-tuned on clinical dialogue, medical inquiry, and diagnostic reasoning datasets. Optimized with Unsloth for ultra-low latency and maximum context length (up to 4096 tokens).
<start_of_turn> and <end_of_turn> for seamless alignment.You can load and run inference on this adapter using Unsloth (recommended for speed) or standard PEFT/Transformers.
from unsloth import FastLanguageModel
import torch
# 1. Load the base model and adapter
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="your-username/gemma-2-9b-medical-ultimate-lora", # Replace with your HF repo ID
max_seq_length=4096,
load_in_4bit=True, # Set to False for 16-bit
)
FastLanguageModel.for_inference(model) # Enable 2x faster inference
# 2. Format clinical prompt
messages = [
{"role": "user", "content": "Explain the symptoms, causes, and treatment options for type 2 diabetes."}
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to("cuda")
# 3. Generate response
outputs = model.generate(input_ids=inputs, max_new_tokens=512, use_cache=True)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model_name = "unsloth/gemma-2-9b-it"
adapter_name = "your-username/gemma-2-9b-medical-ultimate-lora"
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
model = AutoModelForCausalLM.from_pretrained(
base_model_name,
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(model, adapter_name)
# Run standard generation...
The model was fine-tuned on medical_pro_dataset.jsonl, which features multi-turn clinician-patient conversations and curated Q&A pairs designed for rigorous clinical instruction.
| Parameter | Value | Details |
|---|---|---|
| Base Model | unsloth/gemma-2-9b-it | Official instruction-tuned base |
| Max Sequence Length | 4,096 tokens | Upgraded context window |
| Precision | Bfloat16 / Float16 | Hardware dependent |
| LoRA Rank (R) | 16 | Standard structural low-rank |
| LoRA Alpha | 16 | Scaling factor |
| Optimizer | AdamW (8-bit) | VRAM optimized optimizer |
| Learning Rate | 5e-5 | Linear warmup & decay |
| Target Modules | All linear layers | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
[!WARNING] This model is for research, educational, and informational purposes only. It should not be used as a replacement for professional medical advice, diagnosis, or treatment. Always consult a qualified physician or healthcare provider for any medical concerns.