kz209 commited on
Commit
5f3eeaf
1 Parent(s): 51259f2
pages/arena.py CHANGED
@@ -40,7 +40,10 @@ Once the streaming is complete, you can choose the best response.\u2764\ufe0f"""
40
  with gr.Row():
41
  columns = [gr.Textbox(label=f"Prompt {i+1}", lines=10) for i in range(len(prompts))]
42
 
43
- content_list = [prompt + '\n{' + data_textbox.value + '}\n\nsummary:' for prompt in prompts]
 
 
 
44
  model = get_model_batch_generation("Qwen/Qwen2-1.5B-Instruct")
45
 
46
  def start_streaming():
 
40
  with gr.Row():
41
  columns = [gr.Textbox(label=f"Prompt {i+1}", lines=10) for i in range(len(prompts))]
42
 
43
+ random.shuffle(prompts)
44
+ prompts = prompts[:3]
45
+
46
+ content_list = [prompt['prompt'] + '\n{' + data_textbox.value + '}\n\nsummary:' for prompt in prompts]
47
  model = get_model_batch_generation("Qwen/Qwen2-1.5B-Instruct")
48
 
49
  def start_streaming():
pages/leaderboard.py CHANGED
@@ -1,16 +1,22 @@
 
 
1
  import gradio as gr
2
  import pandas as pd
3
 
4
  from pages.summarization_playground import custom_css
5
 
6
- # Sample data for the leaderboard
 
 
 
 
 
7
  data = {
8
- 'Rank': [1, 2, 3, 4, 5],
9
- 'Methods': ['METHOD1_PLACEHOLDER', 'METHOD2_PLACEHOLDER', 'METHOD3_PLACEHOLDER', 'METHOD4_PLACEHOLDER', 'METHOD5_PLACEHOLDER'],
10
- 'METRIC1_PLACEHOLDER Score': [1287, 1272, 1267, 1262, 1258],
11
- 'METRIC2_PLACEHOLDER Score': [56905, 24913, 42981, 49828, 55567],
12
- 'METRIC3_PLACEHOLDER Score': [3423, 3423, 2152, 4353, 2342],
13
- 'Authors': ['AUTHOR1_PLACEHOLDER', 'AUTHOR2_PLACEHOLDER', 'AUTHOR3_PLACEHOLDER', 'AUTHOR4_PLACEHOLDER', 'AUTHOR5_PLACEHOLDER'],
14
  }
15
 
16
  df = pd.DataFrame(data)
@@ -43,7 +49,7 @@ def create_leaderboard():
43
 
44
  sort_by = gr.Dropdown(list(df.columns), label="Sort by", value="Rank")
45
 
46
- gr.Markdown("**Performance**\n\n**methods**: 4, **questions**: 150")
47
 
48
  leaderboard = gr.HTML(update_leaderboard("Rank"), elem_id="leaderboard")
49
 
 
1
+ import json
2
+
3
  import gradio as gr
4
  import pandas as pd
5
 
6
  from pages.summarization_playground import custom_css
7
 
8
+ with open("prompt/prompt.json", "r") as file:
9
+ json_data = file.read()
10
+ prompts = json.loads(json_data)# Sample data for the leaderboard
11
+
12
+ winning_rate = [prompt['metric']['winning_number'] for prompt in prompts]
13
+ winning_rate = [num / sum(winning_rate) for num in winning_rate]
14
  data = {
15
+ 'Rank': [i+1 for i in range(len(prompts))],
16
+ 'Methods': [prompt['id'] for prompt in prompts],
17
+ 'Rouge Score': [prompt['metric']['Rouge'] for prompt in prompts],
18
+ 'Winning Rate': winning_rate,
19
+ 'Authors': [prompt['author'] for prompt in prompts]
 
20
  }
21
 
22
  df = pd.DataFrame(data)
 
49
 
50
  sort_by = gr.Dropdown(list(df.columns), label="Sort by", value="Rank")
51
 
52
+ gr.Markdown("**Performance**\n\n**methods**: 5, **questions**: 15")
53
 
54
  leaderboard = gr.HTML(update_leaderboard("Rank"), elem_id="leaderboard")
55
 
prompt/prompt.ipynb CHANGED
@@ -2,18 +2,155 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 1,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
  "import json\n",
10
  "\n",
11
  "prompts = [\n",
12
- " \"\"\"Please summarize the following conversation by highlighting the key points and main topics discussed. Include any important conclusions or decisions made during the conversation.\n",
13
- "Conversation:\"\"\",\n",
14
- " \"\"\"Generate a concise summary of the conversation below. Focus on the main arguments, the flow of the discussion, and any significant outcomes or agreements reached. Make sure to capture the essence of the dialogue without including extraneous details.\n",
15
- "Conversation:\"\"\",\n",
16
- " \"\"\"Provide a brief overview of the conversation provided. Summarize the main ideas exchanged, the context of the discussion, and any resolutions or actions decided. Ensure the summary is clear and easy to understand for someone who wasn't part of the conversation\"\"\"\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  "]"
18
  ]
19
  },
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 2,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
  "import json\n",
10
  "\n",
11
  "prompts = [\n",
12
+ " {\n",
13
+ " \"id\": \"id_0\",\n",
14
+ " \"prompt\": \"\"\"You are a proficient assistant tasked with summarizing medical dialogue between a doctor and a patient. Provide a careful and accurate summary based solely on the conversation. Each word is important, and missing any crucial information could have serious consequences. Use only the information from the conversation, and if something is unclear or cannot be accurately summarized, indicate it with \"N/A.\" Follow a step-by-step approach to ensure completeness .\"\"\",\n",
15
+ " \"author\": \"Shunxi Wu\",\n",
16
+ " \"metric\": {\n",
17
+ " \"Rouge\": 0.14,\n",
18
+ " \"winning_number\": 10\n",
19
+ " }\n",
20
+ " },\n",
21
+ " {\n",
22
+ " \"id\": \"id_1\",\n",
23
+ " \"prompt\": \"\"\"You are a proficient assistant that helps summarize medical dialogue after the communication between the doctor and the patient, Think step by step and strictly follow the form of the example provided, structure the summary into:\n",
24
+ "1.CHIEF COMPLAINT:\n",
25
+ "<leave blank row>\n",
26
+ "<fill in> \n",
27
+ "<leave blank row>\n",
28
+ "2. HISTORY OF PRESENT ILLNESS: \n",
29
+ "<leave blank row>\n",
30
+ "<fill in> \n",
31
+ "<leave blank row>\n",
32
+ "3. MEDICAL HISTORY: \n",
33
+ "<leave blank row>\n",
34
+ "<fill in> \n",
35
+ "<leave blank row>\n",
36
+ "4. PHYSICAL EXAM: \n",
37
+ "<leave blank row>\n",
38
+ "<fill in> \n",
39
+ "<leave blank row>\n",
40
+ "5. RESULTS: \n",
41
+ "<leave blank row>\n",
42
+ "<fill in> \n",
43
+ "<leave blank row>\n",
44
+ "6. ASSESSMENT: \n",
45
+ "<leave blank row>\n",
46
+ "<fill in> \n",
47
+ "<leave blank row>\n",
48
+ "\n",
49
+ "You are autoregressive and carefully provide summarization based on the conversation. Since you are autoregressive, each token of the conversation should be considered important, and you cannot lose any important information. \n",
50
+ "Use only the information from the conversation, and if something is unclear or cannot be accurately summarized, indicate it with \"\"N/A.\"\" Follow a step-by-step approach to ensure completeness and adhere strictly to the provided example format.\"\"\",\n",
51
+ " \"author\": \"Shunxi Wu\",\n",
52
+ " \"metric\": {\n",
53
+ " \"Rouge\": 0.14,\n",
54
+ " \"winning_number\": 12\n",
55
+ " }\n",
56
+ " },\n",
57
+ " {\n",
58
+ " \"id\": \"id_2\",\n",
59
+ " \"prompt\": \"Summarize this conversation. Tell me about the Patient's history, current condition, and treatment plan\",\n",
60
+ " \"author\": \"Taru Mishra\",\n",
61
+ " \"metric\": {\n",
62
+ " \"Rouge\": 0.15,\n",
63
+ " \"winning_number\": 3\n",
64
+ " }\n",
65
+ " },\n",
66
+ " {\n",
67
+ " \"id\": \"id_3\",\n",
68
+ " \"prompt\": \"\"\"Here is a dialogue:\n",
69
+ "DR: You mentioned having a cough for 2 days and a\n",
70
+ "fever since last night along with being short of breath.\n",
71
+ "Is that correct?\n",
72
+ "PT: yes , correct\n",
73
+ "DR: I appreciate your concern for preventing spread. Do\n",
74
+ "you feel like you are unable to move around as usual?\n",
75
+ "PT: I’m definitely weaker and low energy the fever\n",
76
+ "went down to 99 this morning\n",
77
+ "DR: Have you taken any medications or tried anything\n",
78
+ "else to help you with your symptoms?\n",
79
+ "PT: lots of fluids and vitamin c. lozenges to minimize\n",
80
+ "coughing\n",
81
+ "DR: do you have any medical conditions or have you\n",
82
+ "been on any medications\n",
83
+ "PT: no, none\n",
84
+ "DR: alright. When you had a fever, did you take\n",
85
+ "medicine like tylenol to bring the fever down?\n",
86
+ "PT: I didn’t\n",
87
+ "First, important details from the text are extracted. The important facts that the patient states are that they had a cough for 2 days, a fever since last night, shortness of breath, weaker and low energy, fever going down to 99, lots of fluid and vitamin c taken to minimize coughing, no medical conditions, and didn't take medicine like tylenol to bring the fever down.\n",
88
+ "Next, they are synthesized into a summary with the important details directly copied word-for-word from the text. In this case, we copy \"\"cough for 2 days\"\", \"\"a fever since last night\"\", \"\"short of breath\"\", \"\"weaker and low energy\"\", \"\"fever went down to 99 this morning\"\", \"\"lots of fluids and vitamin c lozenges to minimize coughing\"\", and \"\"take medicine like tylenol to bring the fever down\"\". We add connecting words, and we arrive at the summary:\n",
89
+ "The patient mentioned having a cough for 2 days and a fever since last night with being short of breath. The patient is weaker and low energy, and their fever went down to 99 this morning. The patient took lots of fluids and vitamin c lozenges to minimize coughing. The patient does not have any medical conditions or medications. The patient didn't take medicine like tylenol to bring the fever down.\n",
90
+ "Here is a dialogue, apply the same process but only output the summary:\"\"\",\n",
91
+ " \"author\": \"Eric Chen\",\n",
92
+ " \"metric\": {\n",
93
+ " \"Rouge\": 0.11,\n",
94
+ " \"winning_number\": 8\n",
95
+ " }\n",
96
+ " },\n",
97
+ " {\n",
98
+ " \"id\": \"id_4\",\n",
99
+ " \"prompt\": \"\"\"Here is a dialogue:\n",
100
+ "DR: You mentioned having a cough for 2 days and a\n",
101
+ "fever since last night along with being short of breath.\n",
102
+ "Is that correct?\n",
103
+ "PT: yes , correct\n",
104
+ "DR: I appreciate your concern for preventing spread. Do\n",
105
+ "you feel like you are unable to move around as usual?\n",
106
+ "PT: I’m definitely weaker and low energy the fever\n",
107
+ "went down to 99 this morning\n",
108
+ "DR: Have you taken any medications or tried anything\n",
109
+ "else to help you with your symptoms?\n",
110
+ "PT: lots of fluids and vitamin c. lozenges to minimize\n",
111
+ "coughing\n",
112
+ "DR: do you have any medical conditions or have you\n",
113
+ "been on any medications\n",
114
+ "PT: no, none\n",
115
+ "DR: alright. When you had a fever, did you take\n",
116
+ "medicine like tylenol to bring the fever down?\n",
117
+ "PT: I didn’t\n",
118
+ "DR: ok alright let me do a quick physical exam now with a thermometer, it seems like your temperature is 98 now\n",
119
+ "PT: okay \n",
120
+ "DR: it seems like your infection is going away, just make sure to keep resting\n",
121
+ "PT: okay\n",
122
+ "First, important details from the text are extracted. The important facts that the patient states are that they had a cough for 2 days, a fever since last night, shortness of breath, weaker and low energy, fever going down to 99, lots of fluid and vitamin c taken to minimize coughing, no medical conditions, and didn't take medicine like tylenol to bring the fever down.\n",
123
+ "Next, they are synthesized into a summary with the important details directly copied word-for-word from the text. In this case, we copy \"\"cough for 2 days\"\", \"\"a fever since last night\"\", \"\"short of breath\"\", \"\"weaker and low energy\"\", \"\"fever went down to 99 this morning\"\", \"\"lots of fluids and vitamin c lozenges to minimize coughing\"\", \"\"take medicine like tylenol to bring the fever down\"\", \"\"thermometer\"\", \"\"temperature is 98 now\"\", \"\"infection is going away\"\", and \"\"make sure to keep resting\"\".\n",
124
+ "Then, we sort these details into the categories that they are relevant to. There are five categories, CHIEF COMPLAINT, HISTORY OF PRESENT ILLNESS, PHYSICAL EXAM, RESULTS, and ASSESSMENT. Details are split if they belong to multiple categories. Sorted they are CHIEF COMPLAINT: cough, fever, HISTORY OF PRESENT ILLNESS: cough for 2 days, a fever since last night, short of breath, weaker and low energy, fever went to 99 this morning, lots of fluids and vitamin c lozenges to minimize coughing, didn't take tylenol to bring the fever down, PHYSICAL EXAM: thermometer, RESULTS: temperature is 98, ASSESSMENT: infection is going away, make sure to keep resting.\n",
125
+ "Finally, we add connecting words, and add the relevant section headers and we arrive at the summary:\n",
126
+ "\n",
127
+ "CHIEF COMPLAINT\n",
128
+ "\n",
129
+ "The patient has a cough and a fever.\n",
130
+ "\n",
131
+ "HISTORY OF PRESENT ILLNESS\n",
132
+ "\n",
133
+ "The patient has had a cough for 2 days, a fever since last night, and is weaker, low energy, and short of breath. The patient's fever went down to 99 this morning. The patient has taken lots of fluids and vitamin c lozenges to minimize coughing. The patient didn't take tylenol to bring the fever down.\n",
134
+ "\n",
135
+ "PHYSICAL EXAM\n",
136
+ "\n",
137
+ "The doctor used a thermometer to test the patient's temperature.\n",
138
+ "\n",
139
+ "RESULTS\n",
140
+ "\n",
141
+ "The patient's temperature is 98 degrees.\n",
142
+ "\n",
143
+ "ASSESSMENT\n",
144
+ "\n",
145
+ "The patient's infection is going away and the patient needs to rest.\n",
146
+ "\n",
147
+ "Here is a dialogue, apply the same process but only output the summary:\"\"\",\n",
148
+ " \"author\": \"Eric Chen\",\n",
149
+ " \"metric\": {\n",
150
+ " \"Rouge\": 0.2,\n",
151
+ " \"winning_number\": 13\n",
152
+ " }\n",
153
+ " },\n",
154
  "]"
155
  ]
156
  },
prompt/prompt.json CHANGED
@@ -1 +1 @@
1
- ["Please summarize the following conversation by highlighting the key points and main topics discussed. Include any important conclusions or decisions made during the conversation.\nConversation:", "Generate a concise summary of the conversation below. Focus on the main arguments, the flow of the discussion, and any significant outcomes or agreements reached. Make sure to capture the essence of the dialogue without including extraneous details.\nConversation:", "Provide a brief overview of the conversation provided. Summarize the main ideas exchanged, the context of the discussion, and any resolutions or actions decided. Ensure the summary is clear and easy to understand for someone who wasn't part of the conversation"]
 
1
+ [{"id": "id_0", "prompt": "You are a proficient assistant tasked with summarizing medical dialogue between a doctor and a patient. Provide a careful and accurate summary based solely on the conversation. Each word is important, and missing any crucial information could have serious consequences. Use only the information from the conversation, and if something is unclear or cannot be accurately summarized, indicate it with \"N/A.\" Follow a step-by-step approach to ensure completeness .", "author": "Shunxi Wu", "metric": {"Rouge": 0.14, "winning_number": 10}}, {"id": "id_1", "prompt": "You are a proficient assistant that helps summarize medical dialogue after the communication between the doctor and the patient, Think step by step and strictly follow the form of the example provided, structure the summary into:\n1.CHIEF COMPLAINT:\n<leave blank row>\n<fill in> \n<leave blank row>\n2. HISTORY OF PRESENT ILLNESS: \n<leave blank row>\n<fill in> \n<leave blank row>\n3. MEDICAL HISTORY: \n<leave blank row>\n<fill in> \n<leave blank row>\n4. PHYSICAL EXAM: \n<leave blank row>\n<fill in> \n<leave blank row>\n5. RESULTS: \n<leave blank row>\n<fill in> \n<leave blank row>\n6. ASSESSMENT: \n<leave blank row>\n<fill in> \n<leave blank row>\n\nYou are autoregressive and carefully provide summarization based on the conversation. Since you are autoregressive, each token of the conversation should be considered important, and you cannot lose any important information. \nUse only the information from the conversation, and if something is unclear or cannot be accurately summarized, indicate it with \"\"N/A.\"\" Follow a step-by-step approach to ensure completeness and adhere strictly to the provided example format.", "author": "Shunxi Wu", "metric": {"Rouge": 0.14, "winning_number": 12}}, {"id": "id_2", "prompt": "Summarize this conversation. Tell me about the Patient's history, current condition, and treatment plan", "author": "Taru Mishra", "metric": {"Rouge": 0.15, "winning_number": 3}}, {"id": "id_3", "prompt": "Here is a dialogue:\nDR: You mentioned having a cough for 2 days and a\nfever since last night along with being short of breath.\nIs that correct?\nPT: yes , correct\nDR: I appreciate your concern for preventing spread. Do\nyou feel like you are unable to move around as usual?\nPT: I\u2019m definitely weaker and low energy the fever\nwent down to 99 this morning\nDR: Have you taken any medications or tried anything\nelse to help you with your symptoms?\nPT: lots of fluids and vitamin c. lozenges to minimize\ncoughing\nDR: do you have any medical conditions or have you\nbeen on any medications\nPT: no, none\nDR: alright. When you had a fever, did you take\nmedicine like tylenol to bring the fever down?\nPT: I didn\u2019t\nFirst, important details from the text are extracted. The important facts that the patient states are that they had a cough for 2 days, a fever since last night, shortness of breath, weaker and low energy, fever going down to 99, lots of fluid and vitamin c taken to minimize coughing, no medical conditions, and didn't take medicine like tylenol to bring the fever down.\nNext, they are synthesized into a summary with the important details directly copied word-for-word from the text. In this case, we copy \"\"cough for 2 days\"\", \"\"a fever since last night\"\", \"\"short of breath\"\", \"\"weaker and low energy\"\", \"\"fever went down to 99 this morning\"\", \"\"lots of fluids and vitamin c lozenges to minimize coughing\"\", and \"\"take medicine like tylenol to bring the fever down\"\". We add connecting words, and we arrive at the summary:\nThe patient mentioned having a cough for 2 days and a fever since last night with being short of breath. The patient is weaker and low energy, and their fever went down to 99 this morning. The patient took lots of fluids and vitamin c lozenges to minimize coughing. The patient does not have any medical conditions or medications. The patient didn't take medicine like tylenol to bring the fever down.\nHere is a dialogue, apply the same process but only output the summary:", "author": "Eric Chen", "metric": {"Rouge": 0.11, "winning_number": 8}}, {"id": "id_4", "prompt": "Here is a dialogue:\nDR: You mentioned having a cough for 2 days and a\nfever since last night along with being short of breath.\nIs that correct?\nPT: yes , correct\nDR: I appreciate your concern for preventing spread. Do\nyou feel like you are unable to move around as usual?\nPT: I\u2019m definitely weaker and low energy the fever\nwent down to 99 this morning\nDR: Have you taken any medications or tried anything\nelse to help you with your symptoms?\nPT: lots of fluids and vitamin c. lozenges to minimize\ncoughing\nDR: do you have any medical conditions or have you\nbeen on any medications\nPT: no, none\nDR: alright. When you had a fever, did you take\nmedicine like tylenol to bring the fever down?\nPT: I didn\u2019t\nDR: ok alright let me do a quick physical exam now with a thermometer, it seems like your temperature is 98 now\nPT: okay \nDR: it seems like your infection is going away, just make sure to keep resting\nPT: okay\nFirst, important details from the text are extracted. The important facts that the patient states are that they had a cough for 2 days, a fever since last night, shortness of breath, weaker and low energy, fever going down to 99, lots of fluid and vitamin c taken to minimize coughing, no medical conditions, and didn't take medicine like tylenol to bring the fever down.\nNext, they are synthesized into a summary with the important details directly copied word-for-word from the text. In this case, we copy \"\"cough for 2 days\"\", \"\"a fever since last night\"\", \"\"short of breath\"\", \"\"weaker and low energy\"\", \"\"fever went down to 99 this morning\"\", \"\"lots of fluids and vitamin c lozenges to minimize coughing\"\", \"\"take medicine like tylenol to bring the fever down\"\", \"\"thermometer\"\", \"\"temperature is 98 now\"\", \"\"infection is going away\"\", and \"\"make sure to keep resting\"\".\nThen, we sort these details into the categories that they are relevant to. There are five categories, CHIEF COMPLAINT, HISTORY OF PRESENT ILLNESS, PHYSICAL EXAM, RESULTS, and ASSESSMENT. Details are split if they belong to multiple categories. Sorted they are CHIEF COMPLAINT: cough, fever, HISTORY OF PRESENT ILLNESS: cough for 2 days, a fever since last night, short of breath, weaker and low energy, fever went to 99 this morning, lots of fluids and vitamin c lozenges to minimize coughing, didn't take tylenol to bring the fever down, PHYSICAL EXAM: thermometer, RESULTS: temperature is 98, ASSESSMENT: infection is going away, make sure to keep resting.\nFinally, we add connecting words, and add the relevant section headers and we arrive at the summary:\n\nCHIEF COMPLAINT\n\nThe patient has a cough and a fever.\n\nHISTORY OF PRESENT ILLNESS\n\nThe patient has had a cough for 2 days, a fever since last night, and is weaker, low energy, and short of breath. The patient's fever went down to 99 this morning. The patient has taken lots of fluids and vitamin c lozenges to minimize coughing. The patient didn't take tylenol to bring the fever down.\n\nPHYSICAL EXAM\n\nThe doctor used a thermometer to test the patient's temperature.\n\nRESULTS\n\nThe patient's temperature is 98 degrees.\n\nASSESSMENT\n\nThe patient's infection is going away and the patient needs to rest.\n\nHere is a dialogue, apply the same process but only output the summary:", "author": "Eric Chen", "metric": {"Rouge": 0.2, "winning_number": 13}}]