Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,9 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
5 |
import torch.nn.functional as F
|
6 |
import torch.nn as nn
|
7 |
import re
|
|
|
|
|
|
|
8 |
model_path = r'ssocean/NAIP'
|
9 |
device = 'cuda:0'
|
10 |
|
@@ -12,6 +15,34 @@ global model, tokenizer
|
|
12 |
model = None
|
13 |
tokenizer = None
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
@spaces.GPU(duration=60, enable_queue=True)
|
16 |
def predict(title, abstract):
|
17 |
title = title.replace("\n", " ").strip().replace(''',"'")
|
@@ -48,17 +79,20 @@ example_papers = [
|
|
48 |
{
|
49 |
"title": "Attention Is All You Need",
|
50 |
"abstract": "The dominant sequence transduction models are based on complex recurrent or convolutional neural networks that include an encoder and a decoder. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two machine translation tasks show these models to be superior in quality while being more parallelizable and requiring significantly less time to train.",
|
51 |
-
"
|
|
|
52 |
},
|
53 |
{
|
54 |
"title": "Language Models are Few-Shot Learners",
|
55 |
"abstract": "Recent work has demonstrated substantial gains on many NLP tasks and benchmarks by pre-training on a large corpus of text followed by fine-tuning on a specific task. While typically task-agnostic in architecture, this method still requires task-specific fine-tuning datasets of thousands or tens of thousands of examples. By contrast, humans can generally perform a new language task from only a few examples or from simple instructions - something which current NLP systems still largely struggle to do. Here we show that scaling up language models greatly improves task-agnostic, few-shot performance, sometimes even reaching competitiveness with prior state-of-the-art fine-tuning approaches.",
|
56 |
-
"
|
|
|
57 |
},
|
58 |
{
|
59 |
"title": "An Empirical Study of Neural Network Training Protocols",
|
60 |
"abstract": "This paper presents a comparative analysis of different training protocols for neural networks across various architectures. We examine the effects of learning rate schedules, batch size selection, and optimization algorithms on model convergence and final performance. Our experiments span multiple datasets and model sizes, providing practical insights for deep learning practitioners.",
|
61 |
-
"
|
|
|
62 |
}
|
63 |
]
|
64 |
|
@@ -89,14 +123,82 @@ def update_button_status(title, abstract):
|
|
89 |
return gr.update(value="Error: " + message), gr.update(interactive=False)
|
90 |
return gr.update(value=message), gr.update(interactive=True)
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
with gr.Row():
|
99 |
-
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
title_input = gr.Textbox(
|
101 |
lines=2,
|
102 |
placeholder="Enter Paper Title (minimum 3 words)...",
|
@@ -107,57 +209,56 @@ with gr.Blocks(theme=gr.themes.Default()) as iface:
|
|
107 |
placeholder="Enter Paper Abstract (minimum 50 words)...",
|
108 |
label="Paper Abstract"
|
109 |
)
|
110 |
-
validation_status = gr.Textbox(label="Validation Status", interactive=False)
|
111 |
-
submit_button = gr.Button("Predict Impact", interactive=False)
|
112 |
|
113 |
-
with gr.Column():
|
114 |
-
score_output = gr.Number(label="Impact Score")
|
115 |
-
grade_output = gr.Textbox(label="Grade", value="")
|
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 |
# Example Papers Section
|
142 |
-
gr.
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
gr.Markdown("""
|
155 |
-
### π Important Notes
|
156 |
-
- This tool is designed for research in Computer Vision (CV), Natural Language Processing (NLP), and AI fields only
|
157 |
-
- Predictions are based on title and abstract analysis using advanced AI models
|
158 |
-
- Scores reflect potential academic impact, not paper quality or novelty
|
159 |
-
- For research and educational purposes only
|
160 |
-
""")
|
161 |
|
162 |
# Event handlers
|
163 |
title_input.change(
|
@@ -170,6 +271,12 @@ with gr.Blocks(theme=gr.themes.Default()) as iface:
|
|
170 |
inputs=[title_input, abstract_input],
|
171 |
outputs=[validation_status, submit_button]
|
172 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
def process_prediction(title, abstract):
|
175 |
score = predict(title, abstract)
|
|
|
5 |
import torch.nn.functional as F
|
6 |
import torch.nn as nn
|
7 |
import re
|
8 |
+
import requests
|
9 |
+
import arxiv
|
10 |
+
|
11 |
model_path = r'ssocean/NAIP'
|
12 |
device = 'cuda:0'
|
13 |
|
|
|
15 |
model = None
|
16 |
tokenizer = None
|
17 |
|
18 |
+
def fetch_arxiv_paper(arxiv_input):
|
19 |
+
"""Fetch paper details from arXiv URL or ID."""
|
20 |
+
try:
|
21 |
+
# Extract arXiv ID from URL or use directly
|
22 |
+
arxiv_id = arxiv_input.split('/')[-1]
|
23 |
+
if 'abs' in arxiv_id:
|
24 |
+
arxiv_id = arxiv_id.split('abs/')[-1]
|
25 |
+
if '.pdf' in arxiv_id:
|
26 |
+
arxiv_id = arxiv_id.replace('.pdf', '')
|
27 |
+
|
28 |
+
# Search for the paper
|
29 |
+
search = arxiv.Search(id_list=[arxiv_id])
|
30 |
+
paper = next(search.results())
|
31 |
+
|
32 |
+
return {
|
33 |
+
"title": paper.title,
|
34 |
+
"abstract": paper.summary,
|
35 |
+
"success": True,
|
36 |
+
"message": "Paper fetched successfully!"
|
37 |
+
}
|
38 |
+
except Exception as e:
|
39 |
+
return {
|
40 |
+
"title": "",
|
41 |
+
"abstract": "",
|
42 |
+
"success": False,
|
43 |
+
"message": f"Error fetching paper: {str(e)}"
|
44 |
+
}
|
45 |
+
|
46 |
@spaces.GPU(duration=60, enable_queue=True)
|
47 |
def predict(title, abstract):
|
48 |
title = title.replace("\n", " ").strip().replace(''',"'")
|
|
|
79 |
{
|
80 |
"title": "Attention Is All You Need",
|
81 |
"abstract": "The dominant sequence transduction models are based on complex recurrent or convolutional neural networks that include an encoder and a decoder. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two machine translation tasks show these models to be superior in quality while being more parallelizable and requiring significantly less time to train.",
|
82 |
+
"score": 0.982,
|
83 |
+
"note": "π« Revolutionary paper that introduced the Transformer architecture, fundamentally changing NLP and deep learning."
|
84 |
},
|
85 |
{
|
86 |
"title": "Language Models are Few-Shot Learners",
|
87 |
"abstract": "Recent work has demonstrated substantial gains on many NLP tasks and benchmarks by pre-training on a large corpus of text followed by fine-tuning on a specific task. While typically task-agnostic in architecture, this method still requires task-specific fine-tuning datasets of thousands or tens of thousands of examples. By contrast, humans can generally perform a new language task from only a few examples or from simple instructions - something which current NLP systems still largely struggle to do. Here we show that scaling up language models greatly improves task-agnostic, few-shot performance, sometimes even reaching competitiveness with prior state-of-the-art fine-tuning approaches.",
|
88 |
+
"score": 0.956,
|
89 |
+
"note": "π Groundbreaking GPT-3 paper that demonstrated the power of large language models."
|
90 |
},
|
91 |
{
|
92 |
"title": "An Empirical Study of Neural Network Training Protocols",
|
93 |
"abstract": "This paper presents a comparative analysis of different training protocols for neural networks across various architectures. We examine the effects of learning rate schedules, batch size selection, and optimization algorithms on model convergence and final performance. Our experiments span multiple datasets and model sizes, providing practical insights for deep learning practitioners.",
|
94 |
+
"score": 0.623,
|
95 |
+
"note": "π Solid research paper with useful findings but more limited scope and impact."
|
96 |
}
|
97 |
]
|
98 |
|
|
|
123 |
return gr.update(value="Error: " + message), gr.update(interactive=False)
|
124 |
return gr.update(value=message), gr.update(interactive=True)
|
125 |
|
126 |
+
def process_arxiv_input(arxiv_input):
|
127 |
+
"""Process arXiv input and update title/abstract fields."""
|
128 |
+
if not arxiv_input.strip():
|
129 |
+
return "", "", "Please enter an arXiv URL or ID"
|
130 |
+
|
131 |
+
result = fetch_arxiv_paper(arxiv_input)
|
132 |
+
if result["success"]:
|
133 |
+
return result["title"], result["abstract"], result["message"]
|
134 |
+
else:
|
135 |
+
return "", "", result["message"]
|
136 |
+
|
137 |
+
css = """
|
138 |
+
.gradio-container {
|
139 |
+
font-family: 'Arial', sans-serif;
|
140 |
+
}
|
141 |
+
.main-title {
|
142 |
+
text-align: center;
|
143 |
+
color: #2563eb;
|
144 |
+
font-size: 2.5rem !important;
|
145 |
+
margin-bottom: 1rem !important;
|
146 |
+
background: linear-gradient(45deg, #2563eb, #1d4ed8);
|
147 |
+
-webkit-background-clip: text;
|
148 |
+
-webkit-text-fill-color: transparent;
|
149 |
+
}
|
150 |
+
.sub-title {
|
151 |
+
text-align: center;
|
152 |
+
color: #4b5563;
|
153 |
+
font-size: 1.5rem !important;
|
154 |
+
margin-bottom: 2rem !important;
|
155 |
+
}
|
156 |
+
.input-section {
|
157 |
+
background: white;
|
158 |
+
padding: 2rem;
|
159 |
+
border-radius: 1rem;
|
160 |
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
161 |
+
}
|
162 |
+
.result-section {
|
163 |
+
background: #f8fafc;
|
164 |
+
padding: 2rem;
|
165 |
+
border-radius: 1rem;
|
166 |
+
margin-top: 2rem;
|
167 |
+
}
|
168 |
+
.methodology-section {
|
169 |
+
background: #ecfdf5;
|
170 |
+
padding: 2rem;
|
171 |
+
border-radius: 1rem;
|
172 |
+
margin-top: 2rem;
|
173 |
+
}
|
174 |
+
.example-section {
|
175 |
+
background: #fff7ed;
|
176 |
+
padding: 2rem;
|
177 |
+
border-radius: 1rem;
|
178 |
+
margin-top: 2rem;
|
179 |
+
}
|
180 |
+
"""
|
181 |
+
|
182 |
+
with gr.Blocks(theme=gr.themes.Default(), css=css) as iface:
|
183 |
+
gr.Markdown(
|
184 |
+
"""
|
185 |
+
# PaperImpact: AI-Powered Research Impact Predictor {.main-title}
|
186 |
+
### Estimate the future academic impact from the title and abstract with advanced AI analysis {.sub-title}
|
187 |
+
"""
|
188 |
+
)
|
189 |
|
190 |
with gr.Row():
|
191 |
+
with gr.Column(elem_classes="input-section"):
|
192 |
+
# arXiv Input
|
193 |
+
arxiv_input = gr.Textbox(
|
194 |
+
lines=1,
|
195 |
+
placeholder="Enter arXiv URL or ID (e.g., 2006.16236 or https://arxiv.org/abs/2006.16236)",
|
196 |
+
label="π arXiv Paper URL/ID"
|
197 |
+
)
|
198 |
+
fetch_button = gr.Button("π Fetch Paper Details", variant="secondary")
|
199 |
+
|
200 |
+
gr.Markdown("### π Or Enter Paper Details Manually")
|
201 |
+
|
202 |
title_input = gr.Textbox(
|
203 |
lines=2,
|
204 |
placeholder="Enter Paper Title (minimum 3 words)...",
|
|
|
209 |
placeholder="Enter Paper Abstract (minimum 50 words)...",
|
210 |
label="Paper Abstract"
|
211 |
)
|
212 |
+
validation_status = gr.Textbox(label="βοΈ Validation Status", interactive=False)
|
213 |
+
submit_button = gr.Button("π― Predict Impact", interactive=False, variant="primary")
|
214 |
|
215 |
+
with gr.Column(elem_classes="result-section"):
|
216 |
+
score_output = gr.Number(label="π― Impact Score")
|
217 |
+
grade_output = gr.Textbox(label="π Grade", value="")
|
218 |
+
|
219 |
+
with gr.Row(elem_classes="methodology-section"):
|
220 |
+
gr.Markdown(
|
221 |
+
"""
|
222 |
+
### π¬ Scientific Methodology
|
223 |
+
- **Training Data**: Model trained on extensive dataset of published papers from CS.CV, CS.CL(NLP), and CS.AI fields
|
224 |
+
- **Optimization**: NDCG optimization with Sigmoid activation and MSE loss function
|
225 |
+
- **Validation**: Cross-validated against historical paper impact data
|
226 |
+
- **Architecture**: Advanced transformer-based deep textual analysis
|
227 |
+
- **Metrics**: Quantitative analysis of citation patterns and research influence
|
228 |
+
"""
|
229 |
+
)
|
230 |
+
|
231 |
+
with gr.Row():
|
232 |
+
gr.Markdown(
|
233 |
+
"""
|
234 |
+
### π Rating Scale
|
235 |
+
| Grade | Score Range | Description | Indicator |
|
236 |
+
|-------|-------------|-------------|-----------|
|
237 |
+
| AAA | 0.900-1.000 | Exceptional Impact | π |
|
238 |
+
| AA | 0.800-0.899 | Very High Impact | β |
|
239 |
+
| A | 0.650-0.799 | High Impact | β¨ |
|
240 |
+
| BBB | 0.600-0.649 | Above Average Impact | π΅ |
|
241 |
+
| BB | 0.550-0.599 | Moderate Impact | π |
|
242 |
+
| B | 0.500-0.549 | Average Impact | π |
|
243 |
+
| CCC | 0.400-0.499 | Below Average Impact | π |
|
244 |
+
| CC | 0.300-0.399 | Low Impact | βοΈ |
|
245 |
+
| C | < 0.299 | Limited Impact | π |
|
246 |
+
"""
|
247 |
+
)
|
248 |
|
249 |
# Example Papers Section
|
250 |
+
with gr.Row(elem_classes="example-section"):
|
251 |
+
gr.Markdown("### π Example Papers")
|
252 |
+
for paper in example_papers:
|
253 |
+
gr.Markdown(
|
254 |
+
f"""
|
255 |
+
#### {paper['title']}
|
256 |
+
**Score**: {paper.get('score', 'N/A')} | **Grade**: {get_grade_and_emoji(paper.get('score', 0))}
|
257 |
+
{paper['abstract']}
|
258 |
+
*{paper['note']}*
|
259 |
+
---
|
260 |
+
"""
|
261 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
# Event handlers
|
264 |
title_input.change(
|
|
|
271 |
inputs=[title_input, abstract_input],
|
272 |
outputs=[validation_status, submit_button]
|
273 |
)
|
274 |
+
|
275 |
+
fetch_button.click(
|
276 |
+
process_arxiv_input,
|
277 |
+
inputs=[arxiv_input],
|
278 |
+
outputs=[title_input, abstract_input, validation_status]
|
279 |
+
)
|
280 |
|
281 |
def process_prediction(title, abstract):
|
282 |
score = predict(title, abstract)
|