Spaces:
Sleeping
Sleeping
kz209
commited on
Commit
•
252caca
1
Parent(s):
f961a8f
update rendering
Browse files- pages/batch_evaluation.py +10 -5
pages/batch_evaluation.py
CHANGED
@@ -2,6 +2,7 @@ from dotenv import load_dotenv
|
|
2 |
import gradio as gr
|
3 |
|
4 |
import json
|
|
|
5 |
|
6 |
import numpy as np
|
7 |
|
@@ -22,6 +23,10 @@ def display_results(response_list):
|
|
22 |
summary = item['summary']
|
23 |
response = item['response']
|
24 |
rouge_score = item['metric_score']['rouge_score']
|
|
|
|
|
|
|
|
|
25 |
|
26 |
html_output += f"""
|
27 |
<details>
|
@@ -29,20 +34,20 @@ def display_results(response_list):
|
|
29 |
<div style="display: flex; justify-content: space-between;">
|
30 |
<div style="width: 30%;">
|
31 |
<h3>Dialogue</h3>
|
32 |
-
{dialogue}
|
33 |
</div>
|
34 |
<div style="width: 30%;">
|
35 |
<h3>Summary</h3>
|
36 |
-
{summary}
|
37 |
</div>
|
38 |
<div style="width: 30%;">
|
39 |
<h3>Response</h3>
|
40 |
-
{response}
|
41 |
</div>
|
42 |
</div>
|
43 |
</details>
|
44 |
"""
|
45 |
-
|
46 |
return html_output
|
47 |
|
48 |
def process(model_selection, prompt, num=10):
|
@@ -50,7 +55,7 @@ def process(model_selection, prompt, num=10):
|
|
50 |
with open("test_samples/test_data.json", "r") as file:
|
51 |
json_data = file.read()
|
52 |
dataset = json.loads(json_data)
|
53 |
-
|
54 |
for data in dataset:
|
55 |
dialogue = data['dialogue']
|
56 |
format = data['format']
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
import json
|
5 |
+
import html
|
6 |
|
7 |
import numpy as np
|
8 |
|
|
|
23 |
summary = item['summary']
|
24 |
response = item['response']
|
25 |
rouge_score = item['metric_score']['rouge_score']
|
26 |
+
|
27 |
+
dialogue = html.escape(item['dialogue']).replace('\n', '<br>')
|
28 |
+
summary = html.escape(item['summary']).replace('\n', '<br>')
|
29 |
+
response = html.escape(item['response']).replace('\n', '<br>')
|
30 |
|
31 |
html_output += f"""
|
32 |
<details>
|
|
|
34 |
<div style="display: flex; justify-content: space-between;">
|
35 |
<div style="width: 30%;">
|
36 |
<h3>Dialogue</h3>
|
37 |
+
<pre style="white-space: pre-wrap; word-wrap: break-word;">{dialogue}</pre>
|
38 |
</div>
|
39 |
<div style="width: 30%;">
|
40 |
<h3>Summary</h3>
|
41 |
+
<pre style="white-space: pre-wrap; word-wrap: break-word;">{summary}</pre>
|
42 |
</div>
|
43 |
<div style="width: 30%;">
|
44 |
<h3>Response</h3>
|
45 |
+
<pre style="white-space: pre-wrap; word-wrap: break-word;">{response}</pre>
|
46 |
</div>
|
47 |
</div>
|
48 |
</details>
|
49 |
"""
|
50 |
+
|
51 |
return html_output
|
52 |
|
53 |
def process(model_selection, prompt, num=10):
|
|
|
55 |
with open("test_samples/test_data.json", "r") as file:
|
56 |
json_data = file.read()
|
57 |
dataset = json.loads(json_data)
|
58 |
+
|
59 |
for data in dataset:
|
60 |
dialogue = data['dialogue']
|
61 |
format = data['format']
|