Views
No views yet
[!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.
1{
2 "r": 16, # LoRA rank
3 "lora_alpha": 32, # LoRA alpha
4 "lora_dropout": 0.05, # Dropout
5 "bias": "none",
6 "task_type": "CAUSAL_LM",
7 "target_modules": [
8 "q_proj", "k_proj", "v_proj", "o_proj",
9 "gate_proj", "up_proj", "down_proj"
10 ]
11}| 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% |
1{
2 "label_class": "operate_now", // or "watch_wait", "avoid"
3 "trajectory": "deteriorating", // or "stable", "improving"
4 "red_flag_triggered": true,
5 "red_flags": ["peritonitis", "sepsis_suspected"],
6 "peritonitis": true,
7 "imaging_free_fluid": false,
8 "hb_drop": false,
9 "source_control": true,
10 "ed": false
11}pip install transformers peft torch1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4
5# Load base model
6base_model = "google/medgemma-27b-text-it"
7model = AutoModelForCausalLM.from_pretrained(
8 base_model,
9 torch_dtype=torch.bfloat16,
10 device_map="auto"
11)
12tokenizer = AutoTokenizer.from_pretrained(base_model)
13
14# Load adapter
15model = PeftModel.from_pretrained(
16 model,
17 "bobby07007/surgicalcopilot-phase1b-27b"
18)
19
20# System prompt
21system_prompt = (
22 'You are a surgical triage AI. Output ONLY a single raw JSON object — '
23 'no markdown, no code fences, no explanation. '
24 'The JSON must contain the key "label_class" with value '
25 '"operate_now", "watch_wait", or "avoid".'
26)
27
28# Example case
29case_text = """
3062M POD1 laparoscopic cholecystectomy.
31Vitals: HR 115, BP 90/60, Temp 38.9°C, RR 22, SpO2 94%
32Labs: WBC 18k, Lactate 3.2, Cr 1.4
33Exam: Abdominal distension++, guarding, absent bowel sounds
34Imaging: CT shows free fluid and pneumoperitoneum
35"""
36
37# Build chat
38messages = [
39 {"role": "system", "content": system_prompt},
40 {"role": "user", "content": case_text}
41]
42
43prompt = tokenizer.apply_chat_template(
44 messages,
45 tokenize=False,
46 add_generation_prompt=True
47)
48
49# Generate
50inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
51outputs = model.generate(
52 **inputs,
53 max_new_tokens=512,
54 do_sample=False,
55 pad_token_id=tokenizer.pad_token_id
56)
57
58# Decode
59response = tokenizer.decode(
60 outputs[0][inputs['input_ids'].shape[1]:],
61 skip_special_tokens=True
62)
63print(response)1{
2 "label_class": "operate_now",
3 "trajectory": "deteriorating",
4 "red_flag_triggered": true,
5 "red_flags": ["peritonitis", "sepsis_suspected", "source_control"],
6 "peritonitis": true,
7 "imaging_free_fluid": true,
8 "hb_drop": false,
9 "source_control": true,
10 "ed": false
11}1@misc{surgicalcopilot2024,
2 title={SurgicalCopilot: Autonomous Post-Surgical Monitoring with MedGemma Multi-Adapter AI},
3 author={Aayush},
4 year={2026},
5 publisher={Hugging Face},
6 howpublished={\url{https://huggingface.co/bobby07007/surgicalcopilot-phase1b-27b}},
7 note={LoRA adapter for MedGemma-27B}
8}