Downloads · 30 days
2
8% of all-time downloads
introvoyz041/surgicalcopilot-phase1b-27b
surgicalcopilot-phase1b-27b is a text generation model from introvoyz041. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
LoRA adapter for MedGemma-27B fine-tuned on inpatient post-surgical triage and deterioration detection.
Downloads · 30 days
2
8% of all-time downloads
All-time downloads
26
Public
Repo size
488 MB
Likes
0
Public
Click a slice to open those files.
.safetensors454 MB · 93%
From the Hugging Face model README
LoRA adapter for MedGemma-27B fine-tuned on inpatient post-surgical triage and deterioration detection.
[!WARNING] Live Demo URL Update: The original Azure URL submitted (
https://surgicalcopilot-app.azurewebsites.net/) is currently unavailable due to an unexpected Microsoft Azure account freeze. We have migrated the frontend to Vercel so the application can still be evaluated.
This is a LoRA (Low-Rank Adaptation) adapter trained on top of Google's MedGemma-27B-text-it model for autonomous surgical triage in the inpatient setting (post-operative days 0-5). The model performs three-way classification of surgical patients into:
The model integrates clinical data (vitals, labs, imaging findings, trajectories) to detect life-threatening complications including sepsis, anastomotic leak, peritonitis, and hemorrhage.
{
"r": 16, # LoRA rank
"lora_alpha": 32, # LoRA alpha
"lora_dropout": 0.05, # Dropout
"bias": "none",
"task_type": "CAUSAL_LM",
"target_modules": [
"q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj"
]
}
| Metric | Score |
|---|---|
| Parse Rate | 100% |
| Schema Compliance | 100% |
| Label Accuracy | 94.1% |
| Macro F1 | 0.94 |
| High-Risk Recall (operate_now) | 97.3% |
| High-Risk Precision | 96.8% |
The model generates structured JSON output:
{
"label_class": "operate_now", // or "watch_wait", "avoid"
"trajectory": "deteriorating", // or "stable", "improving"
"red_flag_triggered": true,
"red_flags": ["peritonitis", "sepsis_suspected"],
"peritonitis": true,
"imaging_free_fluid": false,
"hb_drop": false,
"source_control": true,
"ed": false
}
pip install transformers peft torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
# Load base model
base_model = "google/medgemma-27b-text-it"
model = AutoModelForCausalLM.from_pretrained(
base_model,
torch_dtype=torch.bfloat16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(base_model)
# Load adapter
model = PeftModel.from_pretrained(
model,
"bobby07007/surgicalcopilot-phase1b-27b"
)
# System prompt
system_prompt = (
'You are a surgical triage AI. Output ONLY a single raw JSON object — '
'no markdown, no code fences, no explanation. '
'The JSON must contain the key "label_class" with value '
'"operate_now", "watch_wait", or "avoid".'
)
# Example case
case_text = """
62M POD1 laparoscopic cholecystectomy.
Vitals: HR 115, BP 90/60, Temp 38.9°C, RR 22, SpO2 94%
Labs: WBC 18k, Lactate 3.2, Cr 1.4
Exam: Abdominal distension++, guarding, absent bowel sounds
Imaging: CT shows free fluid and pneumoperitoneum
"""
# Build chat
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": case_text}
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
# Generate
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
pad_token_id=tokenizer.pad_token_id
)
# Decode
response = tokenizer.decode(
outputs[0][inputs['input_ids'].shape[1]:],
skip_special_tokens=True
)
print(response)
{
"label_class": "operate_now",
"trajectory": "deteriorating",
"red_flag_triggered": true,
"red_flags": ["peritonitis", "sepsis_suspected", "source_control"],
"peritonitis": true,
"imaging_free_fluid": true,
"hb_drop": false,
"source_control": true,
"ed": false
}
@misc{surgicalcopilot2024,
title={SurgicalCopilot: Autonomous Post-Surgical Monitoring with MedGemma Multi-Adapter AI},
author={Aayush},
year={2026},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/bobby07007/surgicalcopilot-phase1b-27b}},
note={LoRA adapter for MedGemma-27B}
}
For questions, issues, or collaboration:
Apache 2.0 (same as base model)
⚠️ DISCLAIMER: This model is for research and demonstration purposes only. It is NOT FDA-approved and should NOT be used for clinical decision-making without appropriate validation and physician oversight. Always consult qualified healthcare professionals for medical decisions.