Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,8 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
| 4 |
import torch.nn.functional as F
|
| 5 |
|
| 6 |
model_path = "ssocean/NAIP" # 更换为你的模型路径
|
| 7 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_path, num_labels=1,
|
|
|
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 9 |
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -22,15 +23,37 @@ def predict(title, abstract):
|
|
| 22 |
return {"Predicted Impact": round(probability, 4)}
|
| 23 |
|
| 24 |
# 创建 Gradio 界面
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
iface.launch()
|
|
|
|
|
|
|
|
|
| 4 |
import torch.nn.functional as F
|
| 5 |
|
| 6 |
model_path = "ssocean/NAIP" # 更换为你的模型路径
|
| 7 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_path, num_labels=1, load_in_8bit=True)
|
| 8 |
+
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 10 |
|
| 11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 23 |
return {"Predicted Impact": round(probability, 4)}
|
| 24 |
|
| 25 |
# 创建 Gradio 界面
|
| 26 |
+
with gr.Blocks() as iface:
|
| 27 |
+
gr.Markdown("""
|
| 28 |
+
# 🧠 Predict Academic Impact
|
| 29 |
+
### Use AI to estimate the future academic impact of a paper
|
| 30 |
+
""")
|
| 31 |
+
with gr.Row():
|
| 32 |
+
with gr.Column():
|
| 33 |
+
title_input = gr.Textbox(
|
| 34 |
+
lines=2,
|
| 35 |
+
placeholder="Enter Paper Title Here...",
|
| 36 |
+
label="Paper Title"
|
| 37 |
+
)
|
| 38 |
+
abstract_input = gr.Textbox(
|
| 39 |
+
lines=5,
|
| 40 |
+
placeholder="Enter Paper Abstract Here... (Do not input line breaks. No more than 1024 tokens.)",
|
| 41 |
+
label="Paper Abstract"
|
| 42 |
+
)
|
| 43 |
+
submit_button = gr.Button("Predict Impact")
|
| 44 |
+
with gr.Column():
|
| 45 |
+
output = gr.Label(label="Predicted Impact")
|
| 46 |
+
|
| 47 |
+
gr.Markdown("""
|
| 48 |
+
**Important Notes**
|
| 49 |
+
- Predicted impact is a probabilistic value and not an accurate measure of actual future citations.
|
| 50 |
+
- It is intended as a tool for research and educational purposes only.
|
| 51 |
+
- The author takes no responsibility for the prediction results.
|
| 52 |
+
- Since the goal of this paper is to identify potentially more impactful papers, the sigmoid+MSE approach was adopted to achieve higher NDCG values (rather than sigmoid+BCE).
|
| 53 |
+
- As a result of the sigmoid gradient effect, the predicted values are concentrated between 0.1 and 0.9. Generally, we consider a predicted influence score greater than 0.65 to indicate an exceptionally impactful paper.
|
| 54 |
+
""")
|
| 55 |
+
submit_button.click(predict, inputs=[title_input, abstract_input], outputs=output)
|
| 56 |
|
| 57 |
iface.launch()
|
| 58 |
+
|
| 59 |
+
|