File size: 21,124 Bytes
6eff5e7
 
 
 
 
4bea31b
b1499f3
 
05a7bdc
6eff5e7
 
 
 
 
7269ffa
580aef7
6eff5e7
 
 
580aef7
6eff5e7
 
 
580aef7
6eff5e7
 
 
 
300debd
7269ffa
6eff5e7
649e53c
7269ffa
b5a0311
05a7bdc
 
6eff5e7
 
81ca652
7269ffa
81ca652
6eff5e7
 
300debd
7269ffa
0532283
81ca652
6eff5e7
 
 
 
a3a8d41
6eff5e7
 
b5a0311
648fab4
6eff5e7
 
81ca652
6eff5e7
 
 
 
 
 
 
81ca652
6eff5e7
e16ae7e
05a7bdc
649e53c
 
963bf46
7269ffa
05a7bdc
 
6eff5e7
 
091bb76
3448819
0532283
091bb76
0532283
 
 
648fab4
0532283
 
091bb76
 
0532283
5b4e16a
0532283
 
5b4e16a
091bb76
0532283
b5a0311
0532283
 
300debd
0532283
091bb76
3448819
 
0532283
091bb76
05a7bdc
649e53c
 
091bb76
b5a0311
 
091bb76
 
 
 
 
6eff5e7
091bb76
 
 
 
 
648fab4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b5a0311
091bb76
648fab4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
091bb76
648fab4
091bb76
81ca652
091bb76
300debd
648fab4
 
 
 
 
 
 
 
 
300debd
649e53c
 
 
091bb76
b5a0311
 
 
091bb76
 
648fab4
649e53c
0532283
648fab4
 
 
091bb76
 
 
 
0532283
6eff5e7
649e53c
 
 
 
6eff5e7
 
 
963bf46
6eff5e7
 
b5a0311
6eff5e7
b5a0311
 
 
6eff5e7
 
 
 
 
 
b5a0311
 
 
 
 
 
3448819
4068146
648fab4
48d609e
0532283
e16ae7e
 
 
4068146
b5a0311
6eff5e7
a6756ef
2fad322
a6756ef
2fad322
 
648fab4
2fad322
648fab4
 
2fad322
648fab4
 
4068146
648fab4
4068146
648fab4
4068146
648fab4
 
 
4068146
6eff5e7
 
 
648fab4
6eff5e7
 
648fab4
6eff5e7
648fab4
6eff5e7
 
300debd
 
 
649e53c
091bb76
 
 
 
 
648fab4
 
dedd4f7
091bb76
 
3448819
091bb76
3448819
091bb76
 
dedd4f7
091bb76
 
 
 
 
 
 
 
dedd4f7
091bb76
 
 
 
 
 
300debd
 
 
 
 
091bb76
 
 
 
3448819
091bb76
3448819
091bb76
 
dedd4f7
091bb76
 
 
 
81ca652
091bb76
 
 
dedd4f7
091bb76
 
 
 
81ca652
091bb76
81ca652
300debd
 
 
 
81ca652
091bb76
 
 
3448819
091bb76
3448819
091bb76
 
dedd4f7
091bb76
 
 
 
81ca652
091bb76
 
 
dedd4f7
091bb76
 
 
 
81ca652
091bb76
 
 
 
648fab4
963bf46
 
648fab4
 
 
 
 
 
 
091bb76
e16ae7e
 
 
 
 
0532283
e16ae7e
6eff5e7
963bf46
e16ae7e
6eff5e7
3448819
6eff5e7
48d609e
0532283
e16ae7e
091bb76
6eff5e7
 
 
 
 
 
 
 
 
 
 
649e53c
963bf46
 
649e53c
 
 
 
 
 
091bb76
6eff5e7
 
 
 
b5a0311
 
6eff5e7
091bb76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b5a0311
648fab4
300debd
 
649e53c
300debd
7269ffa
 
 
091bb76
 
 
 
 
648fab4
6eff5e7
648fab4
e16ae7e
6eff5e7
e16ae7e
0532283
6eff5e7
091bb76
6eff5e7
963bf46
6eff5e7
 
0532283
 
b5a0311
 
0532283
6eff5e7
 
e16ae7e
963bf46
e16ae7e
 
b5a0311
 
 
 
e16ae7e
 
 
0532283
 
e16ae7e
 
4f8ef7b
 
 
 
7269ffa
4f8ef7b
 
0532283
6eff5e7
dedd4f7
7269ffa
dedd4f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
import gradio as gr
import os
from transformers import AutoTokenizer, AutoModel
from sentence_transformers import SentenceTransformer
import pickle
import nltk
nltk.download('punkt') # tokenizer
nltk.download('averaged_perceptron_tagger') # postagger
import time

from input_format import *
from score import *

# load document scoring model
#torch.cuda.is_available = lambda : False  # uncomment to test with CPU only
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
pretrained_model = 'allenai/specter'
tokenizer = AutoTokenizer.from_pretrained(pretrained_model)
doc_model = AutoModel.from_pretrained(pretrained_model) 
doc_model.to(device)

# load sentence model 
sent_model = SentenceTransformer('sentence-transformers/gtr-t5-base')
sent_model.to(device)

def get_similar_paper(
    abstract_text_input, 
    author_id_input, 
    results={}, # this state variable will be updated and returned
    #progress=gr.Progress()
):
    
    progress = gr.Progress()
    num_papers_show = 10 # number of top papers to show from the reviewer
    print('retrieving similar papers...')
    start = time.time()
    input_sentences = sent_tokenize(abstract_text_input)
    
    # Get author papers from id
    #progress(0.1, desc="Retrieving reviewer papers ...")
    name, papers = get_text_from_author_id(author_id_input)
    
    # Compute Doc-level affinity scores for the Papers 
    # print('computing document scores...') 
    #progress(0.5, desc="Computing document scores...")
    # TODO detect duplicate papers?
    titles, abstracts, paper_urls, doc_scores = compute_document_score(
        doc_model, 
        tokenizer,
        abstract_text_input, 
        papers,
        batch=10
    )
    
    results = {
        'name': name,
        'titles': titles,
        'abstracts': abstracts,
        'urls': paper_urls,
        'doc_scores': doc_scores
    }
    
    # Select top K choices of papers to show
    titles = titles[:num_papers_show]
    abstracts = abstracts[:num_papers_show]
    doc_scores = doc_scores[:num_papers_show]
    paper_urls = paper_urls[:num_papers_show]
    
    display_title = ['[ %0.3f ] %s'%(s, t) for t, s in zip(titles, doc_scores)]
    end = time.time()
    retrieval_time = end - start
    print('paper retrieval complete in [%0.2f] seconds'%(retrieval_time))
    
    progress(0.9, desc="Obtaining relevant information from the papers...")
    print('obtaining highlights..')
    start = time.time()
    input_sentences = sent_tokenize(abstract_text_input)
    num_sents = len(input_sentences)
    
    for aa, (tt, ab, ds, url) in enumerate(zip(titles, abstracts, doc_scores, paper_urls)):
        # Compute sent-level and phrase-level affinity scores for each papers
        sent_ids, sent_scores, info, top_pairs_info = get_highlight_info(
            sent_model, 
            abstract_text_input, 
            ab,
            K=2 # top two sentences from the candidate 
        )
        
        # get scores for each word in the format for Gradio Interpretation component
        word_scores = dict()
        for i in range(num_sents):
            ww, ss = remove_spaces(info['all_words'], info[i]['scores'])
            word_scores[str(i)] = {
                "original": ab,
                "interpretation": list(zip(ww, ss))
            }

        results[display_title[aa]] = {
            'title': tt,
            'abstract': ab,
            'doc_score': '%0.3f'%ds,
            'source_sentences': input_sentences,
            'highlight': word_scores,
            'top_pairs': top_pairs_info,
            'url': url
        }
       
    end = time.time()
    highlight_time = end - start
    print('done in [%0.2f] seconds'%(highlight_time)) 
    
    ## Set up output elements
    
    # set up elements to show 
    out = [
        gr.update(choices=display_title, interactive=True, visible=False), # set of papers (radio)
        gr.update(choices=input_sentences, interactive=True, visible=False) # submission sentences 
    ]
    
    # set up elements to visualize upfront
    top_papers_show = 3 # number of top papers to show upfront
    top_num_info_show = 2 # number of sentence pairs from each paper to show upfront
    summary_out = []
    for i in range(top_papers_show):
        if i == 0:
            out_tmp = [
                gr.update(value="""<a href="%s" target="_blank"><h4>%s</h4></a>"""%(paper_urls[i], titles[i]), visible=True),
                gr.update(value="""#### Affinity Score: %0.3f 
                          <div class="help-tip">
                                <p>Measures how similar the paper's abstract is to the submission abstract.</p>
                          </div>
                          """%doc_scores[i],  
                          visible=True) # document affinity
            ]
        else:
            out_tmp = [
                gr.update(value="""<a href="%s" target="_blank"><h4>%s</h4></a>"""%(paper_urls[i], titles[i]), visible=True),
                gr.update(value='#### Affinity Score: %0.3f'%doc_scores[i], visible=True) # document affinity
            ]
        tp = results[display_title[i]]['top_pairs']
        for j in range(top_num_info_show):
            if i == 0 and j == 0:
                out_tmp += [
                    gr.update(value="""Sentence Relevance:\n%0.3f
                            <div class="help-tip">
                                <p>Measures how similar the sentence pairs are.</p>
                            </div>"""%tp[j]['score'], visible=True), # sentence relevance
                    tp[j]['query']['original'],
                    tp[j]['query'],
                    tp[j]['candidate']['original'],
                    tp[j]['candidate']
                ]
            else:
                out_tmp += [
                    gr.update(value='Sentence Relevance:\n%0.3f'%tp[j]['score'], visible=True), # sentence relevance
                    tp[j]['query']['original'],
                    tp[j]['query'],
                    tp[j]['candidate']['original'],
                    tp[j]['candidate']
                ]
        summary_out += out_tmp

    # add updates to the show more button
    out = out + summary_out + [gr.update(visible=True)] # make show more button visible
    assert(len(out) == (top_num_info_show * 5 + 2) * top_papers_show + 3)

    out += [gr.update(value="""
                            <h3>Top three relevant papers by the reviewer <a href="%s" target="_blank">%s</a></h3>
                            
                            For each paper, two sentence pairs (one from the submission, one from the paper) with the highest relevance scores are shown.
                            
                            **<span style="color:black;background-color:#65B5E3;">Blue highlights</span>**: phrases that appear in both sentences.
                            """%(author_id_input, results['name']),
                            visible=True)] # result 1 description

    out += [gr.update(visible=True), gr.update(visible=True)] # demarcation line between results

    # progress status
    out += [gr.update(value='Done (in %0.1f seconds)'%(retrieval_time+highlight_time), visible=True)]
    
    # add the search results to pass on to the Gradio State varaible
    out += [results]
    
    return tuple(out)
        
def show_more(info):
    # show the interactive part of the app
    return (
        gr.update(value="""
            ### Click on different papers by %s below (sorted by their affinity scores) to see other relevant parts!
            """%info['name'], visible=True), # description
        gr.update(visible=True), # set of papers
        gr.update(visible=True), # submission sentences
        gr.update(visible=True), # title row
        gr.update(visible=True), # abstract row
    )

def show_status():
    # show search status field when search button is clicked
    return gr.update(visible=True)

def update_name(author_id_input):
    # update the name of the author based on the id input
    name, _ = get_text_from_author_id(author_id_input)
    
    return gr.update(value=name)

def change_output_highlight(selected_papers_radio, source_sent_choice, info={}):
    # change the output highlight based on the sentence selected from the submission
    if len(info.keys()) != 0: # if the info is not empty
        source_sents = info[selected_papers_radio]['source_sentences']
        highlights = info[selected_papers_radio]['highlight']
        for i, s in enumerate(source_sents):
            if source_sent_choice == s:
                return highlights[str(i)]
    else:
        return

def change_paper(selected_papers_radio, info={}):
    if len(info.keys()) != 0: # if the info is not empty
        title = info[selected_papers_radio]['title']
        abstract = info[selected_papers_radio]['abstract']
        aff_score = info[selected_papers_radio]['doc_score']
        highlights = info[selected_papers_radio]['highlight']
        url = info[selected_papers_radio]['url']
        title_out = """<a href="%s" target="_blank"><h4>%s</h4></a>"""%(url, title)
        aff_score_out = '#### Affinity Score: %s'%aff_score
        return title_out, abstract, aff_score_out, highlights['0']

    else:
        return

with gr.Blocks(css='style.css') as demo:
    info = gr.State({})  # cached search results as a State variable shared throughout
    
    # Text description about the app and disclaimer
    ### TEXT Description
    # TODO add instruction video link
    gr.Markdown(
        """
# R2P2: Matching Reviewers to Papers in Peer Review

#### Who is R2P2 for?
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. 

#### How does it help?
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. 

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. 

Check out [this video]() for a quick demo of what R2P2 is, and how it can help!

-------
        """
    ) 
    
    ### INPUT
    with gr.Row() as input_row:
        with gr.Column():
            abstract_text_input = gr.Textbox(label='Submission Abstract', info='Paste in the abstract of the submission.')
        with gr.Column():
            with gr.Row():
                author_id_input = gr.Textbox(label='Reviewer Profile Link (Semantic Scholar)', info="Paste in the reviewer's Semantic Scholar link")
            with gr.Row():
                name = gr.Textbox(label='Confirm Reviewer Name', info='This will be automatically updated based on the reviewer profile link above', interactive=False)
                author_id_input.change(fn=update_name, inputs=author_id_input, outputs=name)
    with gr.Row():
        compute_btn = gr.Button('What Makes This a Good Match?') 

    with gr.Row():
        search_status = gr.Textbox(label='Search Status', interactive=False, visible=False)
        
    ### OVERVIEW
    # Paper title, score, and top-ranking sentence pairs -- two sentence pairs per paper, three papers
    ## ONE BLOCK OF INFO FOR A SINGLE PAPER
    ## PAPER1 
    with gr.Row():
        result1_desc = gr.Markdown(value='', visible=False)
    # TODO hovering instructions
    with gr.Row():
        with gr.Column(scale=3):
            paper_title1 = gr.Markdown(value='', visible=False)
        with gr.Column(scale=1):
            affinity1 = gr.Markdown(value='', visible=False)
    with gr.Row() as rel1_1:
        with gr.Column(scale=1):
            sent_pair_score1_1 = gr.Markdown(interactive=False, value='', visible=False)
        with gr.Column(scale=4):
            sent_pair_source1_1 = gr.Textbox(label='Sentence from Submission', visible=False)
            sent_pair_source1_1_hl = gr.components.Interpretation(sent_pair_source1_1)
        with gr.Column(scale=4):
            sent_pair_candidate1_1 = gr.Textbox(label='Sentence from Paper', visible=False)
            sent_pair_candidate1_1_hl = gr.components.Interpretation(sent_pair_candidate1_1)
    with gr.Row() as rel1_2:
        with gr.Column(scale=1):
            sent_pair_score1_2 = gr.Markdown(interactive=False, value='', visible=False)
        with gr.Column(scale=4):
            sent_pair_source1_2 = gr.Textbox(label='Sentence from Submission', visible=False)
            sent_pair_source1_2_hl = gr.components.Interpretation(sent_pair_source1_2)
        with gr.Column(scale=4):
            sent_pair_candidate1_2 = gr.Textbox(label='Sentence from Paper', visible=False)
            sent_pair_candidate1_2_hl = gr.components.Interpretation(sent_pair_candidate1_2)
    
    with gr.Row(visible=False) as demarc1:
        gr.Markdown(
            """---"""
        )
            
    ## PAPER 2
    with gr.Row():
        with gr.Column(scale=3):
            paper_title2 = gr.Markdown(value='', visible=False)
        with gr.Column(scale=1):
            affinity2 = gr.Markdown(value='', visible=False)
    with gr.Row() as rel2_1:
        with gr.Column(scale=1):
            sent_pair_score2_1 = gr.Markdown(interactive=False, value='', visible=False)
        with gr.Column(scale=4):
            sent_pair_source2_1 = gr.Textbox(label='Sentence from Submission', visible=False)
            sent_pair_source2_1_hl = gr.components.Interpretation(sent_pair_source2_1)
        with gr.Column(scale=4):
            sent_pair_candidate2_1 = gr.Textbox(label='Sentence from Paper', visible=False)
            sent_pair_candidate2_1_hl = gr.components.Interpretation(sent_pair_candidate2_1)
    with gr.Row() as rel2_2:
        with gr.Column(scale=1):
            sent_pair_score2_2 = gr.Markdown(interactive=False, value='', visible=False)
        with gr.Column(scale=4):
            sent_pair_source2_2 = gr.Textbox(label='Sentence from Submission', visible=False)
            sent_pair_source2_2_hl = gr.components.Interpretation(sent_pair_source2_2)
        with gr.Column(scale=4):
            sent_pair_candidate2_2 = gr.Textbox(label='Sentence from Paper', visible=False)
            sent_pair_candidate2_2_hl = gr.components.Interpretation(sent_pair_candidate2_2)
            
    with gr.Row(visible=False) as demarc2:
        gr.Markdown(
            """---"""
        )
    
    ## PAPER 3 
    with gr.Row():
        with gr.Column(scale=3):
            paper_title3 = gr.Markdown(value='', visible=False)
        with gr.Column(scale=1):
            affinity3 = gr.Markdown(value='', visible=False)
    with gr.Row() as rel3_1:
        with gr.Column(scale=1):
            sent_pair_score3_1 = gr.Markdown(interactive=False, value='', visible=False)
        with gr.Column(scale=4):
            sent_pair_source3_1 = gr.Textbox(label='Sentence from Submission', visible=False)
            sent_pair_source3_1_hl = gr.components.Interpretation(sent_pair_source3_1)
        with gr.Column(scale=4):
            sent_pair_candidate3_1 = gr.Textbox(label='Sentence from Paper', visible=False)
            sent_pair_candidate3_1_hl = gr.components.Interpretation(sent_pair_candidate3_1)
    with gr.Row() as rel3_2:
        with gr.Column(scale=1):
            sent_pair_score3_2 = gr.Markdown(interactive=False, value='', visible=False)
        with gr.Column(scale=4):
            sent_pair_source3_2 = gr.Textbox(label='Sentence from Submission', visible=False)
            sent_pair_source3_2_hl = gr.components.Interpretation(sent_pair_source3_2)
        with gr.Column(scale=4):
            sent_pair_candidate3_2 = gr.Textbox(label='Sentence from Paper', visible=False)
            sent_pair_candidate3_2_hl = gr.components.Interpretation(sent_pair_candidate3_2)

    ## Show more button
    with gr.Row():
        see_more_rel_btn = gr.Button('Explore more in other papers', visible=False)
    
    ### PAPER INFORMATION
    
    # Description
    with gr.Row():
        result2_desc = gr.Markdown(
            value=''
            ,visible=False
        )

    # show multiple papers in radio check box to select from
    with gr.Row():
        selected_papers_radio = gr.Radio(
            choices=[], # will be udpated with the button click
            visible=False, # also will be updated with the button click
            label='Top Relevant Papers from the Reviewer'
        )
    
    # selected paper information 
    with gr.Row(visible=False) as title_row:
        with gr.Column(scale=3):
            paper_title = gr.Markdown(value='')
        with gr.Column(scale=1):
            affinity = gr.Markdown(value='')
    with gr.Row():
        paper_abstract = gr.Textbox(label='Abstract', interactive=False, visible=False)
         
    ### RELEVANT PARTS (HIGHLIGHTS)
    with gr.Row(): 
        with gr.Column(scale=2): # text from submission
            source_sentences = gr.Radio(
                choices=[], 
                visible=False, 
                label='Sentences from Submission Abstract',
            )
        with gr.Column(scale=3): # highlighted text from paper
            highlight = gr.components.Interpretation(paper_abstract) 
    
    
    ### EVENT LISTENERS
    
    compute_btn.click(
        fn=show_status,
        inputs=[],
        outputs=search_status
    )
    
    # retrieve similar papers and show top results
    compute_btn.click(
        fn=get_similar_paper,
        inputs=[
            abstract_text_input, 
            author_id_input,
            info
        ],
        outputs=[
            selected_papers_radio,
            source_sentences,
            paper_title1, # paper info
            affinity1,
            sent_pair_score1_1,
            sent_pair_source1_1,
            sent_pair_source1_1_hl,
            sent_pair_candidate1_1,
            sent_pair_candidate1_1_hl,
            sent_pair_score1_2,
            sent_pair_source1_2,
            sent_pair_source1_2_hl,
            sent_pair_candidate1_2,
            sent_pair_candidate1_2_hl,
            paper_title2,
            affinity2,
            sent_pair_score2_1,
            sent_pair_source2_1,
            sent_pair_source2_1_hl,
            sent_pair_candidate2_1,
            sent_pair_candidate2_1_hl,
            sent_pair_score2_2,
            sent_pair_source2_2,
            sent_pair_source2_2_hl,
            sent_pair_candidate2_2,
            sent_pair_candidate2_2_hl,
            paper_title3,
            affinity3, 
            sent_pair_score3_1, 
            sent_pair_source3_1,
            sent_pair_source3_1_hl,
            sent_pair_candidate3_1,
            sent_pair_candidate3_1_hl,
            sent_pair_score3_2,
            sent_pair_source3_2,
            sent_pair_source3_2_hl,
            sent_pair_candidate3_2,
            sent_pair_candidate3_2_hl,
            see_more_rel_btn,
            result1_desc,
            demarc1,
            demarc2,
            search_status,
            info,
        ],
        show_progress=True,
        scroll_to_output=True
    )      
    
    # Get more info (move to more interactive portion)
    see_more_rel_btn.click(
        fn=show_more,
        inputs=info,
        outputs=[
            result2_desc,
            selected_papers_radio,
            source_sentences,
            title_row,
            paper_abstract
        ]
    )
    
    # change highlight based on selected sentences from submission
    source_sentences.change(
        fn=change_output_highlight,
        inputs=[
            selected_papers_radio,
            source_sentences,
            info
        ],
        outputs=highlight
    )
    
    # change paper to show based on selected papers
    selected_papers_radio.change(
        fn=change_paper,
        inputs=[
            selected_papers_radio,
            info,
        ],
        outputs= [
            paper_title,
            paper_abstract,
            affinity,
            highlight
        ]
    )
    
    gr.Markdown(
        """
        ---------
        **Disclaimer.** This tool and its output should not serve as the sole justification for confirming a match for the submission. It is intended as a supplementary tool that the users may use at their discretion; the correctness of the output of the tool is not guaranteed. The search results may be improved by updating the internal models used to compute the affinity scores and sentence relevance, which may require additional independent research. The tool does not compromise the privacy of the reviewers --- it relies only on their publicly-available information (e.g., names and list of previously published papers). All input information will only be temporarily used for internal computation, will not be saved externally, and will be removed when the session is refreshed or closed.
        """
    )
    
if __name__ == "__main__":
    #demo.queue().launch(share=True) 
    demo.queue().launch() 
    # TODO how to disable dark mode?