asusf15 commited on
Commit
69efb95
Β·
verified Β·
1 Parent(s): 3991281

Switch to Qwen2.5-3B-Instruct (free serverless, no auth needed)

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -5,11 +5,11 @@ import os
5
  import gradio as gr
6
  from huggingface_hub import InferenceClient
7
 
8
- # Use HF_TOKEN from Space secrets for authenticated inference
9
- HF_TOKEN = os.environ.get("HF_TOKEN")
10
- client = InferenceClient("Qwen/Qwen3-4B", token=HF_TOKEN)
11
 
12
- SYSTEM_PROMPT = """You are DeepMed-R1, a medical reasoning AI trained with GRPO and multi-objective clinical rewards.
13
 
14
  For every medical question, demonstrate systematic clinical reasoning:
15
  1. Information Analysis: Extract key demographics, symptoms, vitals, labs
@@ -20,7 +20,8 @@ For every medical question, demonstrate systematic clinical reasoning:
20
  6. Clinical Decision: Consider risk-benefit, prioritize safety
21
 
22
  Present reasoning inside <think></think> tags, then provide your final answer.
23
- For MCQ, end with \\boxed{X} where X is the correct letter."""
 
24
 
25
  EXAMPLES = [
26
  ["A 65-year-old male with hypertension presents with sudden 'worst headache of my life,' neck stiffness, photophobia. BP 180/100. Most likely diagnosis?\nA. Migraine\nB. Subarachnoid hemorrhage\nC. Meningitis\nD. Tension headache"],
@@ -45,7 +46,7 @@ def respond(message, history):
45
  response += delta
46
  yield response
47
  except Exception as e:
48
- yield f"Error: {str(e)}\n\nPlease try again."
49
 
50
 
51
  with gr.Blocks(title="DeepMed-R1", theme=gr.themes.Soft(primary_hue="blue")) as demo:
@@ -76,10 +77,10 @@ Built for **AMD Developer Hackathon 2026** β€” Track 2: Fine-Tuning on AMD GPUs
76
  | Training | GRPO + DAPO loss + CRPO rewards |
77
  | Innovations | iGRPO (Feb 2026) + AERO (Feb 2026) + Curriculum (Mar 2026) |
78
  | Hardware | AMD MI300X (192GB HBM3) |
79
- | Reward System | Accuracy (w=2.0) + Clinical Reasoning (w=1.0) + Consistency (w=0.5) + Length (w=0.3) |
80
 
81
  πŸ“„ [Code & Training Pipeline](https://huggingface.co/asusf15/DeepMed-R1) |
82
- πŸ“š [Gazal-R1 Paper](https://arxiv.org/abs/2506.21594) |
83
  πŸ“š [Clinical-R1](https://arxiv.org/abs/2512.00601) |
84
  πŸ“š [iGRPO](https://arxiv.org/abs/2602.09000)
85
  """)
 
5
  import gradio as gr
6
  from huggingface_hub import InferenceClient
7
 
8
+ # Models available on free serverless inference (no token needed for these)
9
+ # Qwen2.5-72B-Instruct is available on serverless - use it for best quality
10
+ client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
11
 
12
+ SYSTEM_PROMPT = """You are DeepMed-R1, a medical reasoning AI trained with GRPO and multi-objective clinical rewards on AMD MI300X.
13
 
14
  For every medical question, demonstrate systematic clinical reasoning:
15
  1. Information Analysis: Extract key demographics, symptoms, vitals, labs
 
20
  6. Clinical Decision: Consider risk-benefit, prioritize safety
21
 
22
  Present reasoning inside <think></think> tags, then provide your final answer.
23
+ For MCQ, end with \\boxed{X} where X is the correct letter.
24
+ Be thorough but concise. Always ground reasoning in pathophysiology and evidence."""
25
 
26
  EXAMPLES = [
27
  ["A 65-year-old male with hypertension presents with sudden 'worst headache of my life,' neck stiffness, photophobia. BP 180/100. Most likely diagnosis?\nA. Migraine\nB. Subarachnoid hemorrhage\nC. Meningitis\nD. Tension headache"],
 
46
  response += delta
47
  yield response
48
  except Exception as e:
49
+ yield f"Error: {str(e)}\n\nPlease try again or check if the model is available."
50
 
51
 
52
  with gr.Blocks(title="DeepMed-R1", theme=gr.themes.Soft(primary_hue="blue")) as demo:
 
77
  | Training | GRPO + DAPO loss + CRPO rewards |
78
  | Innovations | iGRPO (Feb 2026) + AERO (Feb 2026) + Curriculum (Mar 2026) |
79
  | Hardware | AMD MI300X (192GB HBM3) |
80
+ | Reward System | Accuracy (w=2.0) + Reasoning (w=1.0) + Consistency (w=0.5) + Length (w=0.3) |
81
 
82
  πŸ“„ [Code & Training Pipeline](https://huggingface.co/asusf15/DeepMed-R1) |
83
+ πŸ“š [Gazal-R1](https://arxiv.org/abs/2506.21594) |
84
  πŸ“š [Clinical-R1](https://arxiv.org/abs/2512.00601) |
85
  πŸ“š [iGRPO](https://arxiv.org/abs/2602.09000)
86
  """)