Spaces:
Runtime error
Runtime error
up-to-date version of gradio. modified dislaimer and instructions.
Browse files- app.py +18 -16
- requirements.txt +1 -1
app.py
CHANGED
@@ -12,7 +12,7 @@ from input_format import *
|
|
12 |
from score import *
|
13 |
|
14 |
# load document scoring model
|
15 |
-
torch.cuda.is_available = lambda : False
|
16 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
17 |
pretrained_model = 'allenai/specter'
|
18 |
tokenizer = AutoTokenizer.from_pretrained(pretrained_model)
|
@@ -27,21 +27,22 @@ def get_similar_paper(
|
|
27 |
abstract_text_input,
|
28 |
author_id_input,
|
29 |
results={}, # this state variable will be updated and returned
|
|
|
30 |
):
|
31 |
-
progress = gr.Progress()
|
32 |
|
|
|
33 |
num_papers_show = 10 # number of top papers to show from the reviewer
|
34 |
print('retrieving similar papers...')
|
35 |
start = time.time()
|
36 |
input_sentences = sent_tokenize(abstract_text_input)
|
37 |
|
38 |
# Get author papers from id
|
39 |
-
progress(0.1, desc="Retrieving reviewer papers ...")
|
40 |
name, papers = get_text_from_author_id(author_id_input)
|
41 |
|
42 |
# Compute Doc-level affinity scores for the Papers
|
43 |
# print('computing document scores...')
|
44 |
-
progress(0.5, desc="Computing document scores...")
|
45 |
# TODO detect duplicate papers?
|
46 |
titles, abstracts, paper_urls, doc_scores = compute_document_score(
|
47 |
doc_model,
|
@@ -69,7 +70,7 @@ def get_similar_paper(
|
|
69 |
retrieval_time = end - start
|
70 |
print('paper retrieval complete in [%0.2f] seconds'%(retrieval_time))
|
71 |
|
72 |
-
progress(0.
|
73 |
print('obtaining highlights..')
|
74 |
start = time.time()
|
75 |
input_sentences = sent_tokenize(abstract_text_input)
|
@@ -81,13 +82,12 @@ def get_similar_paper(
|
|
81 |
sent_model,
|
82 |
abstract_text_input,
|
83 |
ab,
|
84 |
-
K=2
|
85 |
)
|
86 |
|
87 |
# get scores for each word in the format for Gradio Interpretation component
|
88 |
word_scores = dict()
|
89 |
for i in range(num_sents):
|
90 |
-
|
91 |
ww, ss = remove_spaces(info['all_words'], info[i]['scores'])
|
92 |
word_scores[str(i)] = {
|
93 |
"original": ab,
|
@@ -207,7 +207,7 @@ with gr.Blocks() as demo:
|
|
207 |
# Paper Matching Helper
|
208 |
|
209 |
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.
|
210 |
-
Below we describe how to use the tool. Also feel free to check out
|
211 |
|
212 |
##### Input
|
213 |
- 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.
|
@@ -215,18 +215,18 @@ Below we describe how to use the tool. Also feel free to check out the [video]()
|
|
215 |
- 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).
|
216 |
##### Relevant Parts from Top Papers
|
217 |
- 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).
|
218 |
-
- 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,
|
219 |
-
- **<span style="color:black;background-color:#65B5E3;">Blue highlights</span>** inidicate phrases that
|
220 |
##### More Relevant Parts
|
221 |
- If the information above is not enough, click `See more relevant parts from other papers` button.
|
222 |
-
- You will see a list top 10 similar papers
|
223 |
-
- You can select different papers from the list to see title
|
224 |
- Below the list of papers, we highlight relevant parts from the selected paper to different sentences of the submission abstract.
|
225 |
- On the left, you will see individual sentences from the submission abstract to select from.
|
226 |
- On the right, you will see the abstract of the selected paper, with **highlights** incidating relevant parts to the selected sentence.
|
227 |
- **<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.
|
228 |
- **<span style="color:black;background-color:#65B5E3;">Blue highlights</span>**: phrases included in the selected sentence.
|
229 |
-
- To see relevant parts in a different paper from the reviewer,
|
230 |
-------
|
231 |
"""
|
232 |
)
|
@@ -433,7 +433,9 @@ Below we describe how to use the tool. Also feel free to check out the [video]()
|
|
433 |
demarc2,
|
434 |
search_status,
|
435 |
info,
|
436 |
-
]
|
|
|
|
|
437 |
)
|
438 |
|
439 |
# Get more info (move to more interactive portion)
|
@@ -477,9 +479,9 @@ Below we describe how to use the tool. Also feel free to check out the [video]()
|
|
477 |
gr.Markdown(
|
478 |
"""
|
479 |
---------
|
480 |
-
**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.
|
481 |
"""
|
482 |
)
|
483 |
|
484 |
if __name__ == "__main__":
|
485 |
-
demo.launch()
|
|
|
12 |
from score import *
|
13 |
|
14 |
# load document scoring model
|
15 |
+
#torch.cuda.is_available = lambda : False # uncomment to test with CPU only
|
16 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
17 |
pretrained_model = 'allenai/specter'
|
18 |
tokenizer = AutoTokenizer.from_pretrained(pretrained_model)
|
|
|
27 |
abstract_text_input,
|
28 |
author_id_input,
|
29 |
results={}, # this state variable will be updated and returned
|
30 |
+
#progress=gr.Progress()
|
31 |
):
|
|
|
32 |
|
33 |
+
progress = gr.Progress()
|
34 |
num_papers_show = 10 # number of top papers to show from the reviewer
|
35 |
print('retrieving similar papers...')
|
36 |
start = time.time()
|
37 |
input_sentences = sent_tokenize(abstract_text_input)
|
38 |
|
39 |
# Get author papers from id
|
40 |
+
#progress(0.1, desc="Retrieving reviewer papers ...")
|
41 |
name, papers = get_text_from_author_id(author_id_input)
|
42 |
|
43 |
# Compute Doc-level affinity scores for the Papers
|
44 |
# print('computing document scores...')
|
45 |
+
#progress(0.5, desc="Computing document scores...")
|
46 |
# TODO detect duplicate papers?
|
47 |
titles, abstracts, paper_urls, doc_scores = compute_document_score(
|
48 |
doc_model,
|
|
|
70 |
retrieval_time = end - start
|
71 |
print('paper retrieval complete in [%0.2f] seconds'%(retrieval_time))
|
72 |
|
73 |
+
progress(0.9, desc="Obtaining relevant information from the papers...")
|
74 |
print('obtaining highlights..')
|
75 |
start = time.time()
|
76 |
input_sentences = sent_tokenize(abstract_text_input)
|
|
|
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
|
89 |
word_scores = dict()
|
90 |
for i in range(num_sents):
|
|
|
91 |
ww, ss = remove_spaces(info['all_words'], info[i]['scores'])
|
92 |
word_scores[str(i)] = {
|
93 |
"original": ab,
|
|
|
207 |
# Paper Matching Helper
|
208 |
|
209 |
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.
|
210 |
+
Below we describe how to use the tool. Also feel free to check out [this video]() for a quicker rundown.
|
211 |
|
212 |
##### Input
|
213 |
- 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.
|
|
|
215 |
- 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).
|
216 |
##### Relevant Parts from Top Papers
|
217 |
- 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).
|
218 |
+
- 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)
|
219 |
+
- **<span style="color:black;background-color:#65B5E3;">Blue highlights</span>** inidicate phrases that appear in both sentences.
|
220 |
##### More Relevant Parts
|
221 |
- If the information above is not enough, click `See more relevant parts from other papers` button.
|
222 |
+
- You will see a list of top 10 similar papers with affinity scores.
|
223 |
+
- You can select different papers from the list to see the title and the abstract in detail.
|
224 |
- Below the list of papers, we highlight relevant parts from the selected paper to different sentences of the submission abstract.
|
225 |
- On the left, you will see individual sentences from the submission abstract to select from.
|
226 |
- On the right, you will see the abstract of the selected paper, with **highlights** incidating relevant parts to the selected sentence.
|
227 |
- **<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.
|
228 |
- **<span style="color:black;background-color:#65B5E3;">Blue highlights</span>**: phrases included in the selected sentence.
|
229 |
+
- To see relevant parts in a different paper from the reviewer, click on another paper from the list.
|
230 |
-------
|
231 |
"""
|
232 |
)
|
|
|
433 |
demarc2,
|
434 |
search_status,
|
435 |
info,
|
436 |
+
],
|
437 |
+
show_progress=True,
|
438 |
+
scroll_to_output=True
|
439 |
)
|
440 |
|
441 |
# Get more info (move to more interactive portion)
|
|
|
479 |
gr.Markdown(
|
480 |
"""
|
481 |
---------
|
482 |
+
**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.
|
483 |
"""
|
484 |
)
|
485 |
|
486 |
if __name__ == "__main__":
|
487 |
+
demo.queue().launch()
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
gradio==3.
|
2 |
huggingface-hub==0.8.1
|
3 |
nltk==3.7
|
4 |
numpy==1.21.6
|
|
|
1 |
+
gradio==3.20.1
|
2 |
huggingface-hub==0.8.1
|
3 |
nltk==3.7
|
4 |
numpy==1.21.6
|