You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`uv run python inference_demo.py` executes a small batch of complaints through the shared interface and prints
251
-
latency/throughput stats. Useful for quick smoke tests after retraining.
318
+
```bash
319
+
uv run python inference_demo.py
320
+
```
321
+
322
+
Runs a few sample complaints through the classifier and shows the full DSPy prompt/response for each using `dspy.inspect_history()`. Useful for demos and understanding how DSPy translates to actual LLM requests.
Copy file name to clipboardExpand all lines: artifacts/ozempic_classifier_ae-category_optimized.json
+4-28Lines changed: 4 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -2,32 +2,9 @@
2
2
"classify.predict": {
3
3
"traces": [],
4
4
"train": [],
5
-
"demos": [
6
-
{
7
-
"augmented": true,
8
-
"complaint": "I've had recurrent attacks of gallbladder pain. It feels like a vice grip under my ribs. An ultrasound showed my gallbladder is full of sludge and small stones. The gastroenterologist says the medication caused the rapid weight loss which led to the stones. I'm scheduled for a laparoscopic cholecystectomy next month to remove the gallbladder.",
9
-
"reasoning": "The patient reports recurrent gallbladder pain, ultrasound evidence of sludge and small stones in the gallbladder, and a physician linking the rapid weight loss (likely from medication) to stone formation, culminating in scheduled surgical removal of the gallbladder. These findings pertain directly to pathology of the gallbladder.",
"justification": "The complaint describes gallbladder pain, ultrasound findings of sludge/stones, medication\u2011related rapid weight loss leading to stones, and surgical intervention\u2014all characteristic of gallbladder disease."
12
-
},
13
-
{
14
-
"augmented": true,
15
-
"complaint": "My heart feels like it's racing all the time. My resting pulse is over 100 beats per minute. I feel jittery and anxious, like I've had too much caffeine. My doctor did an EKG and confirmed sinus tachycardia. He thinks it's a side effect of the Ozempic stimulating my heart.",
16
-
"reasoning": "The patient describes a racing heart, elevated resting pulse (>100 bpm), jitteriness, and confirmed sinus tachycardia, which the doctor attributes to a side effect of Ozempic stimulating the heart. These symptoms pertain to cardiac function and are directly related to the medication\u2019s cardiovascular effects.",
17
-
"classification": "Cardiovascular signs",
18
-
"justification": "The complaint involves tachycardia and related cardiac symptoms, which fall under the \u201cCardiovascular signs\u201d category."
19
-
},
20
-
{
21
-
"complaint": "My retina is bleeding. I see red streaks in my vision. The doctor says I have proliferative diabetic eye disease. It got worse after I started Ozempic. I need urgent laser surgery to stop the bleeding.",
"complaint": "The nausea is bad. I can't eat. I'm losing weight. I feel sick. I want to stop the drug. It's too much.",
26
-
"classification": "Gastrointestinal disorders"
27
-
}
28
-
],
5
+
"demos": [],
29
6
"signature": {
30
-
"instructions": "Given a free\u2011text complaint describing a medication\u2011related adverse event, generate a step\u2011by\u2011step reasoning trace, then output:\n\n1. **Reasoning** \u2013 a brief chain\u2011of\u2011thought explaining how the clinical details point to a specific adverse event type. \n2. **Classification** \u2013 a label selected from the predefined medical categories (e.g., \u201cPancreatitis\u201d, \u201cEye disorders (Diabetic retinopathy complications)\u201d, \u201cHepatobiliary (gallbladder) disease\u201d, etc.). \n3. **Justification** \u2013 a concise explanation linking the reasoning steps to the chosen classification.\n\nThe output should be presented in the order: reasoning, classification, justification, and must be ready for use as a prompt for a language model performing this classification task.",
7
+
"instructions": "Classify adverse events into specific categories.",
Copy file name to clipboardExpand all lines: artifacts/ozempic_classifier_ae-pc_optimized.json
+5-32Lines changed: 5 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -2,35 +2,9 @@
2
2
"classify.predict": {
3
3
"traces": [],
4
4
"train": [],
5
-
"demos": [
6
-
{
7
-
"augmented": true,
8
-
"complaint": "I was doing my usual check of the pen before using it and noticed that the lot number printed on the actual pen body is really smudged, like the ink was smeared or something. I can maybe make out a couple digits but most of it is completely unreadable. And then I looked for the expiration date on the device itself and it's just not there at all. Like, it's missing entirely from the pen body. The outer carton has all the information - lot number, expiration date, everything is printed clearly on the box - but the device itself doesn't have readable traceability information. My understanding is that this information is supposed to be on both the carton and the device for safety reasons, so you can always verify what you're using even if you throw away the box. I need to be able to track which specific pen I'm using in case there's ever a recall or quality issue, and right now I can't do that because the pen itself can't be verified or traced. I contacted the pharmacy to let them know, and they're documenting this issue. They confirmed the lot number from the carton for my records, but this seems like a labeling defect that should be reported.",
9
-
"reasoning": "The patient reports a labeling defect on the medication delivery device: the lot number is smudged and the expiration date is missing from the pen body itself, making it impossible to verify product identity for safety and recall purposes. This is a concern about the physical presentation and traceability of the product, not a description of a medical symptom or physiological reaction to semaglutide. Therefore, it reflects an issue with the product's labeling rather than an adverse health reaction.",
10
-
"classification": "Product Complaint",
11
-
"justification": "The complaint pertains to a labeling defect (unreadable lot number and missing expiration date on the device) that impacts product traceability and safety verification, which is characteristic of a product complaint rather than an adverse medical event."
12
-
},
13
-
{
14
-
"augmented": true,
15
-
"complaint": "When I press the button to inject, the plunger doesn't move forward. I can hear the clicking sound, but the dose counter stays at 0.5 mg and no liquid comes out of the needle. The internal mechanism seems to be disconnected.",
16
-
"reasoning": "The complaint describes a malfunction of the injection device (plunger not moving, no liquid expelled), which pertains to the product's mechanical function rather than a physiological side effect.",
17
-
"classification": "Product Complaint",
18
-
"justification": "The issue is a device defect, not a reported adverse medical reaction to semaglutide; it concerns the injector mechanism itself."
19
-
},
20
-
{
21
-
"augmented": true,
22
-
"complaint": "My heart feels like it's doing flip-flops in my chest. I get these sudden episodes where my pulse spikes to 130 and I feel lightheaded and short of breath. It happens when I'm just sitting at my desk. It makes me feel incredibly anxious. My cardiologist ruled out other causes and believes it's a side effect of the medication increasing my sympathetic nervous system tone.",
23
-
"reasoning": "The patient describes specific cardiac symptoms (palpitations, tachycardia, lightheadedness, shortness of breath) that began after dose escalation of semaglutide and are attributed by the cardiologist to a medication\u2011induced increase in sympathetic nervous system activity. These are physiological adverse reactions directly linked to the drug, rather than a general dissatisfaction with the product.",
24
-
"classification": "Adverse Event",
25
-
"justification": "The complaint details a clinically observed, drug\u2011related side effect (cardiovascular symptoms) that aligns with known adverse events of semaglutide, indicating an adverse event rather than a mere product complaint."
26
-
},
27
-
{
28
-
"complaint": "I injected the full dose but I felt nothing. Usually it stings a little. My blood sugar didn't change at all. I wonder if it's just saline in the pen.",
29
-
"classification": "Product Complaint"
30
-
}
31
-
],
5
+
"demos": [],
32
6
"signature": {
33
-
"instructions": "Classify an Ozempic\u2011related complaint as either **Adverse Event** or **Product Complaint**. \n- First, use chain\u2011of\u2011thought reasoning to determine whether the complaint describes a harmful medical reaction (e.g., side effects, injury, hospitalization) \u2013 which should be labeled *Adverse Event* \u2013 or a problem with the product\u2019s performance, potency, packaging, or suspected defect \u2013 which should be labeled *Product Complaint*. \n- Then output two fields: \n 1. **classification** \u2013 the chosen label exactly as \u201cAdverse Event\u201d or \u201cProduct Complaint\u201d. \n 2. **justification** \u2013 a concise explanation (1\u20112 sentences) summarizing why the complaint fits that category. \n\nRespond only with the two fields above.",
7
+
"instructions": "Classify Ozempic-related complaints as Adverse Event or Product Complaint.",
34
8
"fields": [
35
9
{
36
10
"prefix": "Complaint:",
@@ -42,7 +16,7 @@
42
16
},
43
17
{
44
18
"prefix": "Classification:",
45
-
"description": "Either 'Adverse Event' or 'Product Complaint'"
0 commit comments