jijivski commited on
Commit
3a0a132
1 Parent(s): 9882e38

wait for soft plotly

Browse files
app.py CHANGED
@@ -60,10 +60,13 @@ def get_text(ids_list=[0.1,0.7], tokenizer=None):
60
  # # 这里只是简单地返回 IDs 和损失值,但是可以根据实际需求添加颜色或其他样式
61
  # return [1, 2], [0.1, 0.7]
62
 
63
- def harness_eval(question, choices, answer_index, model=None,tokenizer=None):
64
  '''
65
  use harness to test one question, can specify the model, (extract or ppl)
66
  '''
 
 
 
67
  # TODO add the model and its score
68
  # torch.nn.functional.softmax(output.logits, dim=0)
69
  # topk = torch.topk(output.logits, 5)
@@ -73,7 +76,7 @@ def harness_eval(question, choices, answer_index, model=None,tokenizer=None):
73
 
74
 
75
 
76
- def plotly_plot():#(df, x, y, color,title, x_title, y_title):
77
  # plotly_plot(sample_df, 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl')
78
  df=pd.read_csv('./data/tmp.csv')
79
  df['date'] = pd.to_datetime(df['date'])
@@ -91,6 +94,24 @@ def plotly_plot():#(df, x, y, color,title, x_title, y_title):
91
  # fig.update_layout()
92
  return fig
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  # def plotly_plot(df, x, y, color, title, x_title, y_title):
95
  # fig = px.line(df, x=x, y=y, color=color, title=title)
96
  # fig.update_xaxes(title_text=x_title)
@@ -165,9 +186,14 @@ def color_pipeline(texts=["Hi","FreshEval","!"], model=None):
165
 
166
 
167
  # TODO can this be global ? maybe need session to store info of the user
 
168
 
169
  # 创建 Gradio 界面
170
  with gr.Blocks() as demo:
 
 
 
 
171
  with gr.Tab("color your text"):
172
  with gr.Row():
173
  text_input = gr.Textbox(label="input text", placeholder="input your text here...")
@@ -175,7 +201,7 @@ with gr.Blocks() as demo:
175
  # TODO craw and drop the file
176
 
177
  # loss_input = gr.Number(label="loss")
178
- model_input = gr.Textbox(label="model name", placeholder="input your model name here... now I am trying phi-2...")#TODO make a choice here
179
  output_box=gr.HighlightedText(label="colored text")#,interactive=True
180
 
181
  gr.Examples(
@@ -219,7 +245,46 @@ with gr.Blocks() as demo:
219
  '''
220
  question=gr.Textbox(label="input question", placeholder='input your question here...')
221
  answer_index=gr.Textbox(label="right answer index", placeholder='index for right anser here, start with 0')#TODO add multiple choices,
222
- choices=gr.Textbox(placeholder='input your other choices here...')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
 
224
  # test_button=gr.Button('test').click(harness_eval())# TODO figure out the input and output
225
 
@@ -227,15 +292,20 @@ with gr.Blocks() as demo:
227
  #TODO add the model and its score
228
  answer_label=gr.Label('the answers\'s detail')# RETURN the answer and its score,in the form of dic{str: float}
229
 
230
- test_question_button=gr.Button('test question').click(harness_eval,inputs=[question, choices, answer_index ,answer_type],outputs=[answer_label])
231
 
232
  forecast_q='A Ukrainian counteroffensive began in 2023, though territorial gains by November 2023 were limited (Economist, BBC, Newsweek). The question will be suspended on 31 July 2024 and the outcome determined using data as reported in the Brookings Institution\'s "Ukraine Index" (Brookings Institution - Ukraine Index, see "Percentage of Ukraine held by Russia" chart). If there is a discrepancy between the chart data and the downloaded data (see "Get the data" within the "NET TERRITORIAL GAINS" chart border), the downloaded data will be used for resolution.'
233
- answer_list=['Less than 5%','At least 5%, but less than 10%','At least 10%, but less than 15%','At least 15%, but less than 20%','20% or more' ]
 
234
 
 
 
 
 
235
  gr.Examples([
236
- [forecast_q, '&&&&&&'.join(answer_list), '0']
237
- ],
238
- [question, choices, answer_index])
239
 
240
  date_time_input = gr.Textbox(label="the date when the text is generated")#TODO add date time input
241
  description_input = gr.Textbox(label="description of the text")
@@ -259,20 +329,20 @@ with gr.Blocks() as demo:
259
  # load the json file with time,
260
 
261
  # sample_df=pd.DataFrame({'time':pd.date_range('2021-01-01', periods=6), 'ppl': [1,2,3,4,5,6]})
262
- pd_df=pd.read_csv('./data/tmp.csv')
263
- pd_df['date'] = pd.to_datetime(pd_df['date'])
264
- print(pd_df.head)
265
- # gr_df=gr.Dataframe(pd_df)
266
- gr_df=pd_df
267
 
268
 
269
  # print(gr_df.head)
270
- print('done')
271
  # sample
272
  plot=gr.Plot(label='model text ppl')
273
  # plotly_plot(gr_df, 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl')
274
  # draw_pic_button=gr.Button('draw the pic').click(plotly_plot,inputs=['gr_df', 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl'],outputs=[plot])
275
- draw_pic_button=gr.Button('draw the pic').click(plotly_plot,inputs=[],outputs=[plot])
276
 
277
 
278
 
@@ -280,7 +350,23 @@ with gr.Blocks() as demo:
280
  '''
281
  see the matplotlib example, to see ppl with time, select the models
282
  '''
283
- #
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
 
286
  with gr.Tab("hot questions"):
@@ -295,50 +381,3 @@ with gr.Blocks() as demo:
295
 
296
  demo.launch(debug=True)
297
 
298
-
299
-
300
-
301
-
302
- # import gradio as gr
303
- # import os
304
- # os.system('python -m spacy download en_core_web_sm')
305
- # import spacy
306
- # from spacy import displacy
307
-
308
- # nlp = spacy.load("en_core_web_sm")
309
-
310
- # def text_analysis(text):
311
- # doc = nlp(text)
312
- # html = displacy.render(doc, style="dep", page=True)
313
- # html = (
314
- # "<div style='max-width:100%; max-height:360px; overflow:auto'>"
315
- # + html
316
- # + "</div>"
317
- # )
318
- # pos_count = {
319
- # "char_count": len(text),
320
- # "token_count": 0,
321
- # }
322
- # pos_tokens = []
323
-
324
- # for token in doc:
325
- # pos_tokens.extend([(token.text, token.pos_), (" ", None)])
326
-
327
- # return pos_tokens, pos_count, html
328
-
329
- # demo = gr.Interface(
330
- # text_analysis,
331
- # gr.Textbox(placeholder="Enter sentence here..."),
332
- # ["highlight", "json", "html"],
333
- # examples=[
334
- # ["What a beautiful morning for a walk!"],
335
- # ["It was the best of times, it was the worst of times."],
336
- # ],
337
- # )
338
-
339
- # demo.launch()
340
-
341
-
342
-
343
- # # lm-eval
344
- # # lm-evaluation-harness
 
60
  # # 这里只是简单地返回 IDs 和损失值,但是可以根据实际需求添加颜色或其他样式
61
  # return [1, 2], [0.1, 0.7]
62
 
63
+ def harness_eval(question, answer_index, answer_type, model=None,*choices,):
64
  '''
65
  use harness to test one question, can specify the model, (extract or ppl)
66
  '''
67
+ # print(f'question,choices,answer_index,model,tokenizer: {question,choices,answer_index,model,tokenizer}')
68
+ print(f'type of choices: {type(choices)} and type of choices[0]: {type(choices[0])}')
69
+ print(f'choices: {choices}')
70
  # TODO add the model and its score
71
  # torch.nn.functional.softmax(output.logits, dim=0)
72
  # topk = torch.topk(output.logits, 5)
 
76
 
77
 
78
 
79
+ def plotly_plot_text():#(df, x, y, color,title, x_title, y_title):
80
  # plotly_plot(sample_df, 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl')
81
  df=pd.read_csv('./data/tmp.csv')
82
  df['date'] = pd.to_datetime(df['date'])
 
94
  # fig.update_layout()
95
  return fig
96
 
97
+ def plotly_plot_question():#(df, x, y, color,title, x_title, y_title):
98
+ # plotly_plot(sample_df, 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl')
99
+ df=pd.read_csv('./data/meta_gjo_df.csv')
100
+ df['date'] = pd.to_datetime(df['End Time'])
101
+ # sort by date
102
+ df.sort_values(by='date', inplace=True)
103
+
104
+ # use a dic to filter the dataframe
105
+ # df = df[df['file_name'] == 'arxiv_computer_science']
106
+
107
+ x,y,color,title, x_title, y_title='date', 'Right Possibility', 'model','Right Possibility with time', 'time', 'Right Possibility'
108
+
109
+ fig = px.line(df, x=x, y=y, color=color,title=title)
110
+ fig.update_xaxes(title_text=x_title)
111
+ fig.update_yaxes(title_text=y_title)
112
+ # fig.update_layout()
113
+ return fig
114
+
115
  # def plotly_plot(df, x, y, color, title, x_title, y_title):
116
  # fig = px.line(df, x=x, y=y, color=color, title=title)
117
  # fig.update_xaxes(title_text=x_title)
 
186
 
187
 
188
  # TODO can this be global ? maybe need session to store info of the user
189
+ # visible_btn_num = 4
190
 
191
  # 创建 Gradio 界面
192
  with gr.Blocks() as demo:
193
+ # visible_btn_num = 4
194
+ model_input = gr.Textbox(label="model name", placeholder="input your model name here... now I am trying phi-2...")#TODO make a choice here
195
+
196
+
197
  with gr.Tab("color your text"):
198
  with gr.Row():
199
  text_input = gr.Textbox(label="input text", placeholder="input your text here...")
 
201
  # TODO craw and drop the file
202
 
203
  # loss_input = gr.Number(label="loss")
204
+ # model_input = gr.Textbox(label="model name", placeholder="input your model name here... now I am trying phi-2...")#TODO make a choice here
205
  output_box=gr.HighlightedText(label="colored text")#,interactive=True
206
 
207
  gr.Examples(
 
245
  '''
246
  question=gr.Textbox(label="input question", placeholder='input your question here...')
247
  answer_index=gr.Textbox(label="right answer index", placeholder='index for right anser here, start with 0')#TODO add multiple choices,
248
+ # model_input = gr.Textbox(label="model name", placeholder="input your model name here... now I am trying phi-2...")#TODO make a choice here
249
+
250
+ btn_list = []
251
+
252
+ # choices=gr.Textbox(placeholder='input your other choices here...')
253
+
254
+ button_limit=10
255
+ # global visible_btn_num
256
+ visible_btn_num = 4
257
+
258
+ from gradio_samples.add_components import add_one_btn, remove_one_btn, get_text_content
259
+
260
+ # use partial function
261
+ from functools import partial
262
+ add_one_btn=partial(add_one_btn,button_limit=button_limit,)#visible_btn_num = visible_btn_num)
263
+ remove_one_btn=partial(remove_one_btn,button_limit=button_limit,)#visible_btn_num = visible_btn_num)
264
+
265
+ # with gr.Blocks() as demo:
266
+ with gr.Row():
267
+ for i in range(button_limit):
268
+ if i<visible_btn_num:
269
+ btn = gr.Textbox(visible=True)
270
+ else:
271
+ btn = gr.Textbox(visible=False)
272
+ btn_list.append(btn)
273
+ b = gr.Button("add_one_choice(make sure every existing choice is filled)")
274
+ print(f'len(btn_list): {len(btn_list)}')
275
+ b.click(add_one_btn, btn_list, btn_list)
276
+ b = gr.Button("remove_one_choice")
277
+ b.click(remove_one_btn, btn_list, btn_list)
278
+
279
+ # # print(f'len(btn_list): {len(btn_list)}')
280
+
281
+ # print('btn_list is ',type(btn_list),btn_list)
282
+
283
+
284
+ # b = gr.Button("Get Text Content")
285
+ # output = gr.Textbox()
286
+ # b.click(get_text_content, btn_list, output)
287
+
288
 
289
  # test_button=gr.Button('test').click(harness_eval())# TODO figure out the input and output
290
 
 
292
  #TODO add the model and its score
293
  answer_label=gr.Label('the answers\'s detail')# RETURN the answer and its score,in the form of dic{str: float}
294
 
295
+ test_question_button=gr.Button('test question').click(harness_eval,inputs=[question, answer_index ,model_input,answer_type,*btn_list],outputs=[answer_label])
296
 
297
  forecast_q='A Ukrainian counteroffensive began in 2023, though territorial gains by November 2023 were limited (Economist, BBC, Newsweek). The question will be suspended on 31 July 2024 and the outcome determined using data as reported in the Brookings Institution\'s "Ukraine Index" (Brookings Institution - Ukraine Index, see "Percentage of Ukraine held by Russia" chart). If there is a discrepancy between the chart data and the downloaded data (see "Get the data" within the "NET TERRITORIAL GAINS" chart border), the downloaded data will be used for resolution.'
298
+ # answer_list=['Less than 5%','At least 5%, but less than 10%','At least 10%, but less than 15%','At least 15%, but less than 20%','20% or more' ]
299
+ answer_list=['Less than 5%','At least 5%, but less than 10%','At least 10%, but less than 15%','15% or more' ]
300
 
301
+ # gr.Examples([
302
+ # [forecast_q, '&&&&&&'.join(answer_list), '0']
303
+ # ],
304
+ # [question, choices, answer_index])
305
  gr.Examples([
306
+ [forecast_q, answer_list[0],answer_list[1],answer_list[2],answer_list[3], '0']
307
+ ],
308
+ [question,btn_list[0],btn_list[1],btn_list[2],btn_list[3], answer_index])
309
 
310
  date_time_input = gr.Textbox(label="the date when the text is generated")#TODO add date time input
311
  description_input = gr.Textbox(label="description of the text")
 
329
  # load the json file with time,
330
 
331
  # sample_df=pd.DataFrame({'time':pd.date_range('2021-01-01', periods=6), 'ppl': [1,2,3,4,5,6]})
332
+ # pd_df=pd.read_csv('./data/tmp.csv')
333
+ # pd_df['date'] = pd.to_datetime(pd_df['date'])
334
+ # print(pd_df.head)
335
+ # # gr_df=gr.Dataframe(pd_df)
336
+ # gr_df=pd_df
337
 
338
 
339
  # print(gr_df.head)
340
+ # print('done')
341
  # sample
342
  plot=gr.Plot(label='model text ppl')
343
  # plotly_plot(gr_df, 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl')
344
  # draw_pic_button=gr.Button('draw the pic').click(plotly_plot,inputs=['gr_df', 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl'],outputs=[plot])
345
+ draw_pic_button=gr.Button('draw the pic').click(plotly_plot_text,inputs=[],outputs=[plot])
346
 
347
 
348
 
 
350
  '''
351
  see the matplotlib example, to see ppl with time, select the models
352
  '''
353
+
354
+ # pd_df=pd.read_csv('./data/meta_gjo_df.csv')
355
+ # pd_df['date'] = pd.to_datetime(pd_df['end_date'])
356
+ # print(pd_df.head)
357
+ # gr_df=gr.Dataframe(pd_df)
358
+ # gr_df=pd_df
359
+
360
+
361
+ # print(gr_df.head)
362
+ # print('done')
363
+ # sample
364
+ plot=gr.Plot(label='question acc with time')
365
+ # plotly_plot(gr_df, 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl')
366
+ # draw_pic_button=gr.Button('draw the pic').click(plotly_plot,inputs=['gr_df', 'date', 'loss_mean_at_1000', 'model','ppl with time', 'time', 'ppl'],outputs=[plot])
367
+ draw_pic_button=gr.Button('draw the pic').click(plotly_plot_question,inputs=[],outputs=[plot])
368
+
369
+
370
 
371
 
372
  with gr.Tab("hot questions"):
 
381
 
382
  demo.launch(debug=True)
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
get_loss/get_loss_hf.py CHANGED
@@ -128,7 +128,8 @@ def load_hf_model(path, cache_path):
128
  hf_model = AutoModelForCausalLM.from_pretrained(path,
129
  device_map=device,
130
  trust_remote_code=True,
131
- cache_dir=cache_path).eval()
 
132
  # output_attentions=True)
133
  else:
134
  hf_model = AutoModelForCausalLM.from_pretrained(path,
 
128
  hf_model = AutoModelForCausalLM.from_pretrained(path,
129
  device_map=device,
130
  trust_remote_code=True,
131
+ cache_dir=cache_path,
132
+ output_attentions=True).eval()
133
  # output_attentions=True)
134
  else:
135
  hf_model = AutoModelForCausalLM.from_pretrained(path,
gradio_samples/add_components.py CHANGED
@@ -32,37 +32,91 @@
32
 
33
  import gradio as gr
34
 
35
- def words():
36
- sentence = "A test of Gradio"
37
- words = sentence.split()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  update_show = [gr.Textbox(visible=True, value=w,interactive=True) for w in words]
39
- update_hide = [gr.Textbox(visible=False, value="",interactive=True) for _ in range(10-len(words))]
40
- return update_show + update_hide
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
 
43
  def get_text_content(*btn_list):
44
- # make all the input as a list
45
- # merge_list
46
- # rtn =[w.value for w in btn_list if w.visible]
47
-
48
  rtn =' '.join([w for w in btn_list ])
49
 
50
  print(rtn)
51
  return rtn
52
 
53
 
54
- btn_list = []
55
-
56
- with gr.Blocks() as demo:
57
- with gr.Row():
58
- for i in range(10):
59
- btn = gr.Textbox(visible=False)
60
- btn_list.append(btn)
61
- b = gr.Button("Run")
62
- b.click(words, None, btn_list)
63
-
64
- b = gr.Button("Get Text Content")
65
- output = gr.Textbox()
66
- b.click(get_text_content, btn_list, output)
67
 
68
- demo.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  import gradio as gr
34
 
35
+
36
+
37
+ def add_one_btn(*btn_list,button_limit=10):
38
+ print(f'input is {btn_list},type is {type(btn_list)},len is {len(btn_list)},type[0] is {type(btn_list[0])}')
39
+ # global visible_btn_num
40
+ # global button_limit
41
+ # visible_btn_num = sum([1 for btn in btn_list if btn.visible])
42
+ visible_btn_num = sum([1 for btn in btn_list if len(btn)>0])
43
+ print(f'visible_btn_num: {visible_btn_num}')
44
+
45
+
46
+ if visible_btn_num<button_limit:
47
+ visible_btn_num += 1
48
+ else:
49
+ print(f'button limit {button_limit} reached')
50
+ print(f'len(btn_list): {len(btn_list)}')
51
+ words = btn_list[:visible_btn_num]#sentence.split()
52
  update_show = [gr.Textbox(visible=True, value=w,interactive=True) for w in words]
53
+ update_hide = [gr.Textbox(visible=False, value="",interactive=True) for _ in range(button_limit-len(words))]
54
+ # update_hide = [gr.Textbox(visible=False, value="",interactive=True) for _ in range(10-len(words))]
55
+ rtn_list=update_show + update_hide
56
+ # print(f'len(rtn_list): {len(rtn_list)}')
57
+ return rtn_list
58
+
59
+ def remove_one_btn(*btn_list,button_limit=10):
60
+ # global visible_btn_num
61
+ # count the visible btn in the btn_list
62
+ # visible_btn_num = sum([1 for btn in btn_list if btn.visible])
63
+ visible_btn_num = sum([1 for btn in btn_list if len(btn)>0])
64
+ print(f'visible_btn_num: {visible_btn_num}')
65
+
66
+ # global button_limit
67
+ if visible_btn_num>0:
68
+ visible_btn_num -= 1
69
+ else:
70
+ print(f'button limit {button_limit} reached')
71
+ # print(f'len(btn_list): {len(btn_list)}')
72
+ words = btn_list[:visible_btn_num]#sentence.split()
73
+ update_show = [gr.Textbox(visible=True, value=w,interactive=True) for w in words]
74
+ update_hide = [gr.Textbox(visible=False, value="",interactive=True)for _ in range(button_limit-len(words))]
75
+ # update_hide = [gr.Textbox(visible=False, value="",interactive=True) for _ in range(10-len(words))]
76
+ rtn_list=update_show + update_hide
77
+ print(f'len(rtn_list): {len(rtn_list)}')
78
+ return rtn_list
79
 
80
 
81
  def get_text_content(*btn_list):
82
+ print(f'input is {btn_list}')
 
 
 
83
  rtn =' '.join([w for w in btn_list ])
84
 
85
  print(rtn)
86
  return rtn
87
 
88
 
89
+
90
+
91
+ if __name__ == '__main__':
92
+ button_limit=10
93
+ visible_btn_num = 4
94
+ btn_list = []
95
+ from functools import partial
96
+ add_one_btn_partial = partial(add_one_btn, button_limit=button_limit)#, visible_btn_num=visible_btn_num)
97
+ remove_one_btn_partial = partial(remove_one_btn, button_limit=button_limit)#, visible_btn_num=visible_btn_num)
 
 
 
 
98
 
99
+ with gr.Blocks() as demo:
100
+ with gr.Row():
101
+ for i in range(button_limit):
102
+ if i<visible_btn_num:
103
+ btn = gr.Textbox(visible=True)
104
+ else:
105
+ btn = gr.Textbox(visible=False)
106
+ btn_list.append(btn)
107
+ b = gr.Button("add_one_choice")
108
+ print(f'len(btn_list): {len(btn_list)}')
109
+ b.click(add_one_btn_partial, btn_list, btn_list)
110
+ b = gr.Button("remove_one_choice")
111
+ b.click(remove_one_btn_partial, btn_list, btn_list)
112
+
113
+ # print(f'len(btn_list): {len(btn_list)}')
114
+
115
+ print(btn_list)
116
+
117
+
118
+ b = gr.Button("Get Text Content")
119
+ output = gr.Textbox()
120
+ b.click(get_text_content, btn_list, output)
121
+
122
+ demo.launch(debug=True)
gradio_samples/draft.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''
2
+ use extract, or use ppl
3
+ '''
4
+ question=gr.Textbox(label="input question", placeholder='input your question here...')
5
+ answer_index=gr.Textbox(label="right answer index", placeholder='index for right anser here, start with 0')#TODO add multiple choices,
6
+ # choices=gr.Textbox(placeholder='input your other choices here...')
7
+
8
+ btn_list=[]
9
+ button_limit=10
10
+ with gr.Row():
11
+ for i in range(button_limit):
12
+ btn = gr.Textbox(visible=True)
13
+ # btn = gr.Textbox(visible=False)
14
+ btn_list.append(btn)
15
+ b = gr.Button("add_one_choice")
16
+
17
+ print(f'len(btn_list): {len(btn_list)},btn_list:{btn_list}')
18
+
19
+
20
+ # test_button=gr.Button('test').click(harness_eval())# TODO figure out the input and output
21
+
22
+ answer_type=gr.Dropdown(label="answer type", choices=['extract', 'ppl'])
23
+ #TODO add the model and its score
24
+ answer_label=gr.Label('the answers\'s detail')# RETURN the answer and its score,in the form of dic{str: float}
25
+
26
+ # test_question_button=gr.Button('test question').click(harness_eval,inputs=[question, '&&&&&&'.join(btn_list), answer_index ,answer_type],outputs=[answer_label])
27
+ test_question_button=gr.Button('test question').click(harness_eval,inputs=[question, *btn_list, answer_index ,answer_type],outputs=[answer_label])
28
+
29
+ forecast_q='A Ukrainian counteroffensive began in 2023, though territorial gains by November 2023 were limited (Economist, BBC, Newsweek). The question will be suspended on 31 July 2024 and the outcome determined using data as reported in the Brookings Institution\'s "Ukraine Index" (Brookings Institution - Ukraine Index, see "Percentage of Ukraine held by Russia" chart). If there is a discrepancy between the chart data and the downloaded data (see "Get the data" within the "NET TERRITORIAL GAINS" chart border), the downloaded data will be used for resolution.'
30
+ answer_list=['Less than 5%','At least 5%, but less than 10%','At least 10%, but less than 15%','At least 15%, but less than 20%','20% or more' ]
31
+
32
+ gr.Examples([
33
+ [forecast_q, '0']
34
+ ],
35
+ [question, answer_index])
36
+
37
+ date_time_input = gr.Textbox(label="the date when the text is generated")#TODO add date time input
38
+ description_input = gr.Textbox(label="description of the text")
39
+ submit_button = gr.Button("submit a post or record").click()
40
+
41
+ #TODO add the model and its score