Spaces:
Sleeping
Sleeping
Commit
·
25f7781
1
Parent(s):
c145ae6
Bugs fixed. Updated Readme.md
Browse files- README.md +39 -0
- app.py +6 -4
- backend.py +9 -5
- tmp/answer.xlsx +0 -0
README.md
CHANGED
|
@@ -11,3 +11,42 @@ license: mit
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 14 |
+
|
| 15 |
+
## Instructions
|
| 16 |
+
|
| 17 |
+
### Generate Results
|
| 18 |
+
* There are mainly two way of using this demo: The Online way and the Offline way
|
| 19 |
+
|
| 20 |
+
#### The Online way
|
| 21 |
+
|
| 22 |
+
* You need to have the OpenAI's API key (DM me or email me if you can't find it) and the paper to be processed.
|
| 23 |
+
|
| 24 |
+
* Once you enter the API key and update the file, you should click `Submit`.
|
| 25 |
+
|
| 26 |
+
* Wait about 1-2 minute, you will be able to see the results on Output part.
|
| 27 |
+
|
| 28 |
+
#### The Offline way
|
| 29 |
+
|
| 30 |
+
* You can browser the generated result before head by ChatGPT without waiting just by clicking `Show Answers`
|
| 31 |
+
|
| 32 |
+
### Correct Results
|
| 33 |
+
|
| 34 |
+
* You need to judge whether the Generated Answer and Reference Correct.
|
| 35 |
+
|
| 36 |
+
* If correct, you just need to click the `Correct` button.
|
| 37 |
+
|
| 38 |
+
* If incorrect, you need to first click the `Incorrect` button then provide the correct answer in the text box below.
|
| 39 |
+
|
| 40 |
+
* You can click `Last Question` or `Next Question` in the Output area to change questions of a passage.
|
| 41 |
+
|
| 42 |
+
* Or click `Last passage` or `Next passage` to change the passages.
|
| 43 |
+
|
| 44 |
+
### Download Results
|
| 45 |
+
|
| 46 |
+
* Onece finish judging all questions of all passage. You can download the answers and judgements
|
| 47 |
+
|
| 48 |
+
* If you just want to download the answer generated by LLMs, you can click `Download original LLM answers` then click on the right side to download the excel file.
|
| 49 |
+
|
| 50 |
+
* If you want to download the answer and the judgements, you can click `Download corrected LLM answers` then click on the right side to download the excel file.
|
| 51 |
+
|
| 52 |
+
#### If you have further questions, please email me: oliverwang15@outlook.com
|
app.py
CHANGED
|
@@ -7,8 +7,6 @@ import pandas as pd
|
|
| 7 |
|
| 8 |
from backend import Backend_offline
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
QUESTIONS = [
|
| 13 |
"Animal Type",
|
| 14 |
"Exposure Age",
|
|
@@ -20,8 +18,13 @@ QUESTIONS = [
|
|
| 20 |
|
| 21 |
with gr.Blocks(theme="dark") as demo:
|
| 22 |
backend = Backend_offline()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
with gr.Row():
|
| 24 |
with gr.Row():
|
|
|
|
| 25 |
# Update
|
| 26 |
with gr.Group():
|
| 27 |
gr.Markdown(f'<center><h1>Input</h1></center>')
|
|
@@ -93,8 +96,7 @@ with gr.Blocks(theme="dark") as demo:
|
|
| 93 |
corrected_file = gr.File(label='Download corrected data', file_types=['.xlsx'])
|
| 94 |
btn_download_corrected = gr.Button(value='Download corrected LLM answers')
|
| 95 |
# btn_download_corrected.style(full_width=True)
|
| 96 |
-
|
| 97 |
-
|
| 98 |
with gr.Row():
|
| 99 |
highlighted_text = gr.HTML(label="Highlighted Text")
|
| 100 |
# reset = gr.Button(value='Reset')
|
|
|
|
| 7 |
|
| 8 |
from backend import Backend_offline
|
| 9 |
|
|
|
|
|
|
|
| 10 |
QUESTIONS = [
|
| 11 |
"Animal Type",
|
| 12 |
"Exposure Age",
|
|
|
|
| 18 |
|
| 19 |
with gr.Blocks(theme="dark") as demo:
|
| 20 |
backend = Backend_offline()
|
| 21 |
+
with gr.Row():
|
| 22 |
+
gr.Markdown(f'<center> <h1> <b> DAN_AI </b> </h1> </center>\
|
| 23 |
+
<center> <h4> Please follow the Instruction <a href="https://huggingface.co/spaces/oliverwang15/DAN_AI/blob/main/README.md">HERE</a> </h4> </center>')
|
| 24 |
+
|
| 25 |
with gr.Row():
|
| 26 |
with gr.Row():
|
| 27 |
+
|
| 28 |
# Update
|
| 29 |
with gr.Group():
|
| 30 |
gr.Markdown(f'<center><h1>Input</h1></center>')
|
|
|
|
| 96 |
corrected_file = gr.File(label='Download corrected data', file_types=['.xlsx'])
|
| 97 |
btn_download_corrected = gr.Button(value='Download corrected LLM answers')
|
| 98 |
# btn_download_corrected.style(full_width=True)
|
| 99 |
+
|
|
|
|
| 100 |
with gr.Row():
|
| 101 |
highlighted_text = gr.HTML(label="Highlighted Text")
|
| 102 |
# reset = gr.Button(value='Reset')
|
backend.py
CHANGED
|
@@ -269,7 +269,10 @@ class Backend:
|
|
| 269 |
os.makedirs(path, exist_ok = True)
|
| 270 |
path = os.path.join(path, name)
|
| 271 |
# self.ori_answer_df['questions'] = self.questions
|
| 272 |
-
self
|
|
|
|
|
|
|
|
|
|
| 273 |
|
| 274 |
return path
|
| 275 |
|
|
@@ -277,7 +280,10 @@ class Backend:
|
|
| 277 |
os.makedirs(path, exist_ok = True)
|
| 278 |
path = os.path.join(path, name)
|
| 279 |
# self.answer_df['questions'] = self.questions
|
| 280 |
-
self
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
return path
|
| 283 |
|
|
@@ -302,9 +308,7 @@ class Backend:
|
|
| 302 |
return self.highlighted_out
|
| 303 |
else:
|
| 304 |
return "No answer yet, you need to submit the document first"
|
| 305 |
-
|
| 306 |
|
| 307 |
-
class Backend_offline(Backend):
|
| 308 |
def phase_df(self, df):
|
| 309 |
df = json.loads(df.T.to_json())
|
| 310 |
res_list = []
|
|
@@ -397,4 +401,4 @@ class Backend_offline(Backend):
|
|
| 397 |
|
| 398 |
file_name = self.filename_list[self.current_passage]
|
| 399 |
|
| 400 |
-
return file_name, question, self.answer, self.highlighted_out, highlighted_out_html, self.answer, self.highlighted_out
|
|
|
|
| 269 |
os.makedirs(path, exist_ok = True)
|
| 270 |
path = os.path.join(path, name)
|
| 271 |
# self.ori_answer_df['questions'] = self.questions
|
| 272 |
+
if not hasattr(self, 'ori_answer_df'):
|
| 273 |
+
raise gr.Error("You need to submit the document first")
|
| 274 |
+
else:
|
| 275 |
+
self.ori_answer_df.to_excel(path, index = False)
|
| 276 |
|
| 277 |
return path
|
| 278 |
|
|
|
|
| 280 |
os.makedirs(path, exist_ok = True)
|
| 281 |
path = os.path.join(path, name)
|
| 282 |
# self.answer_df['questions'] = self.questions
|
| 283 |
+
if not hasattr(self, 'answer_df'):
|
| 284 |
+
raise gr.Error("You need to submit the document first")
|
| 285 |
+
else:
|
| 286 |
+
self.answer_df.to_excel(path, index = False)
|
| 287 |
|
| 288 |
return path
|
| 289 |
|
|
|
|
| 308 |
return self.highlighted_out
|
| 309 |
else:
|
| 310 |
return "No answer yet, you need to submit the document first"
|
|
|
|
| 311 |
|
|
|
|
| 312 |
def phase_df(self, df):
|
| 313 |
df = json.loads(df.T.to_json())
|
| 314 |
res_list = []
|
|
|
|
| 401 |
|
| 402 |
file_name = self.filename_list[self.current_passage]
|
| 403 |
|
| 404 |
+
return file_name, question, self.answer, self.highlighted_out, highlighted_out_html, self.answer, self.highlighted_out
|
tmp/answer.xlsx
ADDED
|
Binary file (33.1 kB). View file
|
|
|