ssocean commited on
Commit
d771f77
·
verified ·
1 Parent(s): 89ec693

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -11
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,)# load_in_8bit=True
 
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
- iface = gr.Interface(
26
- fn=predict,
27
- inputs=[
28
- gr.Textbox(lines=2, placeholder="Enter Paper Title Here...", label="Paper Title"),
29
- gr.Textbox(lines=5, placeholder="Enter Paper Abstract Here... (Do not input line breaks. No more than 1024 tokens.)", label="Paper Abstract")
30
- ],
31
- outputs=gr.Label(label="Predicted Impact"),
32
- title="Predict academic future impact with LLMs",
33
- description="Predict the normalized academic impact (0-1) of a paper based on its title and abstract. !!!Important!!! Please note that the predicted impact is a probabilistic value generated by the model and does not accurately reflect the article's future citation performance. It should not be associated with writing quality, novelty, or other attributes. The author assumes no responsibility for the predictive metrics."
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
+