jskim commited on
Commit
648fab4
1 Parent(s): 4068146

separating instructsion into differen phases, with some style change

Browse files
Files changed (2) hide show
  1. app.py +77 -65
  2. style.css +87 -0
app.py CHANGED
@@ -53,6 +53,7 @@ def get_similar_paper(
53
  )
54
 
55
  results = {
 
56
  'titles': titles,
57
  'abstracts': abstracts,
58
  'urls': paper_urls,
@@ -82,7 +83,7 @@ def get_similar_paper(
82
  sent_model,
83
  abstract_text_input,
84
  ab,
85
- K=2 # top two sentences from the candidate #TODO make this adjustable by the user?
86
  )
87
 
88
  # get scores for each word in the format for Gradio Interpretation component
@@ -121,28 +122,57 @@ def get_similar_paper(
121
  top_num_info_show = 2 # number of sentence pairs from each paper to show upfront
122
  summary_out = []
123
  for i in range(top_papers_show):
124
- out_tmp = [
125
- #gr.update(value=titles[i], visible=True),
126
- gr.update(value="""<a href="%s" target="_blank"><h4>%s</h4></a>"""%(paper_urls[i], titles[i]), visible=True),
127
- #gr.update(value="#### [%s](%s)"%(titles[i], paper_urls[i]), visible=True),
128
- gr.update(value='#### Affinity: %0.3f'%doc_scores[i], visible=True) # document affinity
129
- ]
 
 
 
 
 
 
 
 
 
130
  tp = results[display_title[i]]['top_pairs']
131
  for j in range(top_num_info_show):
132
- out_tmp += [
133
- #gr.update(value='%0.3f'%tp[j]['score'], visible=True), # sentence relevance
134
- gr.update(value='Sentence Relevance:\n%0.3f'%tp[j]['score'], visible=True), # sentence relevance
135
- tp[j]['query']['original'],
136
- tp[j]['query'],
137
- tp[j]['candidate']['original'],
138
- tp[j]['candidate']
139
- ]
 
 
 
 
 
 
 
 
 
 
 
140
  summary_out += out_tmp
141
-
142
  # add updates to the show more button
143
  out = out + summary_out + [gr.update(visible=True)] # make show more button visible
144
  assert(len(out) == (top_num_info_show * 5 + 2) * top_papers_show + 3)
145
 
 
 
 
 
 
 
 
 
 
146
  out += [gr.update(visible=True), gr.update(visible=True)] # demarcation line between results
147
 
148
  # progress status
@@ -153,9 +183,12 @@ def get_similar_paper(
153
 
154
  return tuple(out)
155
 
156
- def show_more():
157
  # show the interactive part of the app
158
  return (
 
 
 
159
  gr.update(visible=True), # set of papers
160
  gr.update(visible=True), # submission sentences
161
  gr.update(visible=True), # title row
@@ -178,7 +211,6 @@ def change_output_highlight(selected_papers_radio, source_sent_choice, info={}):
178
  source_sents = info[selected_papers_radio]['source_sentences']
179
  highlights = info[selected_papers_radio]['highlight']
180
  for i, s in enumerate(source_sents):
181
- #print('changing highlight')
182
  if source_sent_choice == s:
183
  return highlights[str(i)]
184
  else:
@@ -192,8 +224,7 @@ def change_paper(selected_papers_radio, info={}):
192
  highlights = info[selected_papers_radio]['highlight']
193
  url = info[selected_papers_radio]['url']
194
  title_out = """<a href="%s" target="_blank"><h4>%s</h4></a>"""%(url, title)
195
- # title_out = '#### [%s](%s)'%(title, url) # output in format of markdown
196
- aff_score_out = '#### Affinity: %s'%aff_score
197
  return title_out, abstract, aff_score_out, highlights['0']
198
 
199
  else:
@@ -205,60 +236,33 @@ with gr.Blocks(css='style.css') as demo:
205
  # Text description about the app and disclaimer
206
  ### TEXT Description
207
  # TODO add instruction video link
208
- # TODO shorten the instruction and make it clearer
209
  gr.Markdown(
210
  """
211
- # Paper Matching Helper
212
 
213
- This is a tool designed to help match an academic paper (submission) to a potential peer reviewer, by presenting information that may be relevant to the users.
214
- Below we describe how to use the tool. Also feel free to check out [this video]() for a quicker rundown.
215
 
216
- ##### Input
217
- - The tool requires two inputs: (1) an academic paper's abstract in a text format, (2) and a potential reviewer's [Semantic Scholar](https://www.semanticscholar.org/) profile link. Once you put in a valid profile link, the reviewer's name will be displayed.
218
- - Once the name is confirmed, press the `What Makes This a Good Match?` button.
219
- - Based on the input information, the tool will first search for similar papers from the reviewer's previous publications using [Semantic Scholar API](https://www.semanticscholar.org/product/api).
220
- ##### Relevant Parts from Top Papers
221
- - You will be shown three most relevant papers from the reviewer with high **affinity scores** (ranging from 0 to 1) computed using text representations from a [language model](https://github.com/allenai/specter/tree/master/specter).
222
- - For each of the paper, we present relevant pieces of information from the submission and the paper: two pairs of (sentence relevance score, sentence from the submission abstract, sentence from the paper abstract)
223
- - **<span style="color:black;background-color:#65B5E3;">Blue highlights</span>** inidicate phrases that appear in both sentences.
224
- ##### More Relevant Parts
225
- - If the information above is not enough, click `See more relevant parts from other papers` button.
226
- - You will see a list of top 10 similar papers with affinity scores.
227
- - You can select different papers from the list to see the title and the abstract in detail.
228
- - Below the list of papers, we highlight relevant parts from the selected paper to different sentences of the submission abstract.
229
- - On the left, you will see individual sentences from the submission abstract to select from.
230
- - On the right, you will see the abstract of the selected paper, with **highlights** incidating relevant parts to the selected sentence.
231
- - **<span style="color:black;background-color:#DB7262;">Red highlights</span>**: sentences with high semantic similarity to the selected sentence. The darker the color, the higher the similarity.
232
- - **<span style="color:black;background-color:#65B5E3;">Blue highlights</span>**: phrases included in the selected sentence.
233
- - To see relevant parts in a different paper from the reviewer, click on another paper from the list.
234
- -------
235
- """
236
- )
237
-
238
- # gr.HTML(
239
- # """
240
-
241
- # <div class="help-tip">
242
- # <p>This is the same tooltip, but with <b>HTML tags!</b> <a href="http://tutorialzine.com/">And a links!</a> You could do <i><strike>even more</strike></i>!</p>
243
- # </div>
244
 
245
- # <p>This time, the tooltip contains rich text. Try it!</p>
246
 
247
- # <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eu diam consectetur, facilisis lorem in, condimentum est. Etiam at leo quis ligula ullamcorper varius. Vivamus sed risus vestibulum, faucibus nibh sed, eleifend enim. Nulla semper augue sit amet velit ultrices consectetur. Sed tincidunt consectetur fermentum.</p>
248
 
249
- # """,
250
- # visible=True
251
- # )
252
 
253
  ### INPUT
254
  with gr.Row() as input_row:
255
  with gr.Column():
256
- abstract_text_input = gr.Textbox(label='Submission Abstract')
257
  with gr.Column():
258
  with gr.Row():
259
- author_id_input = gr.Textbox(label='Reviewer Link or ID (Semantic Scholar)')
260
  with gr.Row():
261
- name = gr.Textbox(label='Confirm Reviewer Name', interactive=False)
262
  author_id_input.change(fn=update_name, inputs=author_id_input, outputs=name)
263
  with gr.Row():
264
  compute_btn = gr.Button('What Makes This a Good Match?')
@@ -270,6 +274,8 @@ Below we describe how to use the tool. Also feel free to check out [this video](
270
  # Paper title, score, and top-ranking sentence pairs -- two sentence pairs per paper, three papers
271
  ## ONE BLOCK OF INFO FOR A SINGLE PAPER
272
  ## PAPER1
 
 
273
  # TODO hovering instructions
274
  with gr.Row():
275
  with gr.Column(scale=3):
@@ -305,7 +311,6 @@ Below we describe how to use the tool. Also feel free to check out [this video](
305
  with gr.Column(scale=3):
306
  paper_title2 = gr.Markdown(value='', visible=False)
307
  with gr.Column(scale=1):
308
- #affinity2 = gr.Textbox(label='Affinity', interactive=False, value='', visible=False)
309
  affinity2 = gr.Markdown(value='', visible=False)
310
  with gr.Row() as rel2_1:
311
  with gr.Column(scale=1):
@@ -336,7 +341,6 @@ Below we describe how to use the tool. Also feel free to check out [this video](
336
  with gr.Column(scale=3):
337
  paper_title3 = gr.Markdown(value='', visible=False)
338
  with gr.Column(scale=1):
339
- # affinity3 = gr.Textbox(label='Affinity', interactive=False, value='', visible=False)
340
  affinity3 = gr.Markdown(value='', visible=False)
341
  with gr.Row() as rel3_1:
342
  with gr.Column(scale=1):
@@ -359,9 +363,16 @@ Below we describe how to use the tool. Also feel free to check out [this video](
359
 
360
  ## Show more button
361
  with gr.Row():
362
- see_more_rel_btn = gr.Button('See more relevant parts from other papers', visible=False)
363
 
364
  ### PAPER INFORMATION
 
 
 
 
 
 
 
365
 
366
  # show multiple papers in radio check box to select from
367
  with gr.Row():
@@ -376,7 +387,6 @@ Below we describe how to use the tool. Also feel free to check out [this video](
376
  with gr.Column(scale=3):
377
  paper_title = gr.Markdown(value='')
378
  with gr.Column(scale=1):
379
- # affinity= gr.Textbox(label='Affinity', interactive=False, value='')
380
  affinity = gr.Markdown(value='')
381
  with gr.Row():
382
  paper_abstract = gr.Textbox(label='Abstract', interactive=False, visible=False)
@@ -449,6 +459,7 @@ Below we describe how to use the tool. Also feel free to check out [this video](
449
  sent_pair_candidate3_2,
450
  sent_pair_candidate3_2_hl,
451
  see_more_rel_btn,
 
452
  demarc1,
453
  demarc2,
454
  search_status,
@@ -461,8 +472,9 @@ Below we describe how to use the tool. Also feel free to check out [this video](
461
  # Get more info (move to more interactive portion)
462
  see_more_rel_btn.click(
463
  fn=show_more,
464
- inputs=None,
465
  outputs=[
 
466
  selected_papers_radio,
467
  source_sentences,
468
  title_row,
 
53
  )
54
 
55
  results = {
56
+ 'name': name,
57
  'titles': titles,
58
  'abstracts': abstracts,
59
  'urls': paper_urls,
 
83
  sent_model,
84
  abstract_text_input,
85
  ab,
86
+ K=2 # top two sentences from the candidate
87
  )
88
 
89
  # get scores for each word in the format for Gradio Interpretation component
 
122
  top_num_info_show = 2 # number of sentence pairs from each paper to show upfront
123
  summary_out = []
124
  for i in range(top_papers_show):
125
+ if i == 0:
126
+ out_tmp = [
127
+ gr.update(value="""<a href="%s" target="_blank"><h4>%s</h4></a>"""%(paper_urls[i], titles[i]), visible=True),
128
+ gr.update(value="""#### Affinity Score: %0.3f
129
+ <div class="help-tip">
130
+ <p>Measures how similar the paper's abstract is to the submission abstract.</p>
131
+ </div>
132
+ """%doc_scores[i],
133
+ visible=True) # document affinity
134
+ ]
135
+ else:
136
+ out_tmp = [
137
+ gr.update(value="""<a href="%s" target="_blank"><h4>%s</h4></a>"""%(paper_urls[i], titles[i]), visible=True),
138
+ gr.update(value='#### Affinity Score: %0.3f'%doc_scores[i], visible=True) # document affinity
139
+ ]
140
  tp = results[display_title[i]]['top_pairs']
141
  for j in range(top_num_info_show):
142
+ if i == 0 and j == 0:
143
+ out_tmp += [
144
+ gr.update(value="""Sentence Relevance:\n%0.3f
145
+ <div class="help-tip">
146
+ <p>Measures how similar the sentence pairs are.</p>
147
+ </div>"""%tp[j]['score'], visible=True), # sentence relevance
148
+ tp[j]['query']['original'],
149
+ tp[j]['query'],
150
+ tp[j]['candidate']['original'],
151
+ tp[j]['candidate']
152
+ ]
153
+ else:
154
+ out_tmp += [
155
+ gr.update(value='Sentence Relevance:\n%0.3f'%tp[j]['score'], visible=True), # sentence relevance
156
+ tp[j]['query']['original'],
157
+ tp[j]['query'],
158
+ tp[j]['candidate']['original'],
159
+ tp[j]['candidate']
160
+ ]
161
  summary_out += out_tmp
162
+
163
  # add updates to the show more button
164
  out = out + summary_out + [gr.update(visible=True)] # make show more button visible
165
  assert(len(out) == (top_num_info_show * 5 + 2) * top_papers_show + 3)
166
 
167
+ out += [gr.update(value="""
168
+ <h3>Top three relevant papers by the reviewer <a href="%s" target="_blank">%s</a></h3>
169
+
170
+ For each paper, two sentence pairs (one from the submission, one from the paper) with the highest relevance scores are shown.
171
+
172
+ **<span style="color:black;background-color:#65B5E3;">Blue highlights</span>**: phrases that appear in both sentences.
173
+ """%(author_id_input, results['name']),
174
+ visible=True)] # result 1 description
175
+
176
  out += [gr.update(visible=True), gr.update(visible=True)] # demarcation line between results
177
 
178
  # progress status
 
183
 
184
  return tuple(out)
185
 
186
+ def show_more(info):
187
  # show the interactive part of the app
188
  return (
189
+ gr.update(value="""
190
+ ### Click on different papers by %s below (sorted by their affinity scores) to see other relevant parts!
191
+ """%info['name'], visible=True), # description
192
  gr.update(visible=True), # set of papers
193
  gr.update(visible=True), # submission sentences
194
  gr.update(visible=True), # title row
 
211
  source_sents = info[selected_papers_radio]['source_sentences']
212
  highlights = info[selected_papers_radio]['highlight']
213
  for i, s in enumerate(source_sents):
 
214
  if source_sent_choice == s:
215
  return highlights[str(i)]
216
  else:
 
224
  highlights = info[selected_papers_radio]['highlight']
225
  url = info[selected_papers_radio]['url']
226
  title_out = """<a href="%s" target="_blank"><h4>%s</h4></a>"""%(url, title)
227
+ aff_score_out = '#### Affinity Score: %s'%aff_score
 
228
  return title_out, abstract, aff_score_out, highlights['0']
229
 
230
  else:
 
236
  # Text description about the app and disclaimer
237
  ### TEXT Description
238
  # TODO add instruction video link
 
239
  gr.Markdown(
240
  """
241
+ # R2P2: Matching Reviewers to Papers in Peer Review
242
 
243
+ #### Who is R2P2 for?
244
+ It is for meta-reviewers, area chairs, program chairs, or anyone who oversees the submission-reviewer matching process in peer review for acadmeic conferences, journals, and grants.
245
 
246
+ #### How does it help?
247
+ A typical meta-reviewer workflow lacks supportive information on what makes the pre-selected candidate reviewers good fit for the submission. Only the **affinity scores** between the reviewer and the paper are provided, with no additional detail.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
+ R2P2 provide more information about each reviewer. It searches for the most relevant papers among the reviewer's previous publications and highlights relevant parts within them.
250
 
251
+ Check out [this video]() for a quick demo of what R2P2 is, and how it can help!
252
 
253
+ -------
254
+ """
255
+ )
256
 
257
  ### INPUT
258
  with gr.Row() as input_row:
259
  with gr.Column():
260
+ abstract_text_input = gr.Textbox(label='Submission Abstract', info='Paste in the abstract of the submission.')
261
  with gr.Column():
262
  with gr.Row():
263
+ author_id_input = gr.Textbox(label='Reviewer Profile Link (Semantic Scholar)', info="Paste in the reviewer's Semantic Scholar link")
264
  with gr.Row():
265
+ name = gr.Textbox(label='Confirm Reviewer Name', info='This will be automatically updated based on the reviewer profile link above', interactive=False)
266
  author_id_input.change(fn=update_name, inputs=author_id_input, outputs=name)
267
  with gr.Row():
268
  compute_btn = gr.Button('What Makes This a Good Match?')
 
274
  # Paper title, score, and top-ranking sentence pairs -- two sentence pairs per paper, three papers
275
  ## ONE BLOCK OF INFO FOR A SINGLE PAPER
276
  ## PAPER1
277
+ with gr.Row():
278
+ result1_desc = gr.Markdown(value='', visible=False)
279
  # TODO hovering instructions
280
  with gr.Row():
281
  with gr.Column(scale=3):
 
311
  with gr.Column(scale=3):
312
  paper_title2 = gr.Markdown(value='', visible=False)
313
  with gr.Column(scale=1):
 
314
  affinity2 = gr.Markdown(value='', visible=False)
315
  with gr.Row() as rel2_1:
316
  with gr.Column(scale=1):
 
341
  with gr.Column(scale=3):
342
  paper_title3 = gr.Markdown(value='', visible=False)
343
  with gr.Column(scale=1):
 
344
  affinity3 = gr.Markdown(value='', visible=False)
345
  with gr.Row() as rel3_1:
346
  with gr.Column(scale=1):
 
363
 
364
  ## Show more button
365
  with gr.Row():
366
+ see_more_rel_btn = gr.Button('Explore more in other papers', visible=False)
367
 
368
  ### PAPER INFORMATION
369
+
370
+ # Description
371
+ with gr.Row():
372
+ result2_desc = gr.Markdown(
373
+ value=''
374
+ ,visible=False
375
+ )
376
 
377
  # show multiple papers in radio check box to select from
378
  with gr.Row():
 
387
  with gr.Column(scale=3):
388
  paper_title = gr.Markdown(value='')
389
  with gr.Column(scale=1):
 
390
  affinity = gr.Markdown(value='')
391
  with gr.Row():
392
  paper_abstract = gr.Textbox(label='Abstract', interactive=False, visible=False)
 
459
  sent_pair_candidate3_2,
460
  sent_pair_candidate3_2_hl,
461
  see_more_rel_btn,
462
+ result1_desc,
463
  demarc1,
464
  demarc2,
465
  search_status,
 
472
  # Get more info (move to more interactive portion)
473
  see_more_rel_btn.click(
474
  fn=show_more,
475
+ inputs=info,
476
  outputs=[
477
+ result2_desc,
478
  selected_papers_radio,
479
  source_sentences,
480
  title_row,
style.css ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* adapted from https://tutorialzine.com/2014/07/css-inline-help-tips */
2
+
3
+ /*-------------------------
4
+ Inline help tip
5
+ --------------------------*/
6
+
7
+ .help-tip{
8
+ position: absolute;
9
+ top: 18px;
10
+ right: 18px;
11
+ text-align: center;
12
+ background-color: #BCDBEA;
13
+ border-radius: 50%;
14
+ width: 24px;
15
+ height: 24px;
16
+ font-size: 14px;
17
+ line-height: 26px;
18
+ cursor: default;
19
+ }
20
+
21
+ .help-tip:before{
22
+ content:'?';
23
+ font-weight: bold;
24
+ color:#fff;
25
+ }
26
+
27
+ .help-tip:hover p{
28
+ display:block;
29
+ transform-origin: 100% 0%;
30
+
31
+ -webkit-animation: fadeIn 0.3s ease-in-out;
32
+ animation: fadeIn 0.3s ease-in-out;
33
+
34
+ }
35
+
36
+ .help-tip p{
37
+ display: none;
38
+ text-align: right;
39
+ background-color: #e0e7ea;
40
+ padding: 10px;
41
+ width: 500px;
42
+ position: absolute;
43
+ border-radius: 3px;
44
+ box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
45
+ right: -4px;
46
+ color: #FFF;
47
+ font-size: 10px;
48
+ line-height: 1.4;
49
+ }
50
+
51
+ .help-tip p:before{
52
+ position: absolute;
53
+ content: '';
54
+ width:0;
55
+ height: 0;
56
+ border:6px solid transparent;
57
+ border-bottom-color:#1E2021;
58
+ right:10px;
59
+ top:-12px;
60
+ }
61
+
62
+ .help-tip p:after{
63
+ width:100%;
64
+ height:40px;
65
+ content:'';
66
+ position: absolute;
67
+ top:-40px;
68
+ left:0;
69
+ }
70
+
71
+ @-webkit-keyframes fadeIn {
72
+ 0% {
73
+ opacity:0;
74
+ transform: scale(0.6);
75
+ }
76
+
77
+ 100% {
78
+ opacity:100%;
79
+ transform: scale(1);
80
+ }
81
+ }
82
+
83
+ @keyframes fadeIn {
84
+ 0% { opacity:0; }
85
+ 100% { opacity:100%; }
86
+ }
87
+