hadangvu commited on
Commit
dce6e25
Β·
verified Β·
1 Parent(s): 9ccf3de

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app/main.py +36 -8
app/main.py CHANGED
@@ -51,14 +51,17 @@ with gr.Blocks(title="PKD Financial Sentiment") as demo:
51
  gr.Markdown("""
52
  # πŸ“ˆ PKD Financial Sentiment
53
  ALBERT student model trained via **Patient Knowledge Distillation** on scraped
54
- financial headlines. Outperforms FinBERT teacher on macro-F1 at ~40% parameter count.
 
55
 
56
  API endpoint: `POST /predict` β€” see [/docs](/docs) for full spec.
 
 
57
  """)
58
 
59
  text_input = gr.Textbox(
60
  label="Financial Headline",
61
- placeholder="e.g. Apple beats Q3 earnings expectations by wide margin",
62
  lines=2,
63
  )
64
 
@@ -70,12 +73,38 @@ with gr.Blocks(title="PKD Financial Sentiment") as demo:
70
  latency_out = gr.Textbox(label="Latency")
71
 
72
  gr.Examples(
 
73
  examples=[
74
- ["Apple beats Q3 earnings expectations by wide margin"],
75
- ["Company files for bankruptcy amid mounting losses"],
76
- ["Federal Reserve holds interest rates steady"],
77
- ["Oil prices surge following OPEC supply cut announcement"],
78
- ["Retailer misses revenue forecast, shares fall 8%"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  ],
80
  inputs=text_input,
81
  )
@@ -86,5 +115,4 @@ with gr.Blocks(title="PKD Financial Sentiment") as demo:
86
  outputs=[label_out, confidence_out, latency_out],
87
  )
88
 
89
- # Gradio takes over "/" β€” FastAPI routes still work at /predict, /docs, /health
90
  app = gr.mount_gradio_app(app, demo, path="/")
 
51
  gr.Markdown("""
52
  # πŸ“ˆ PKD Financial Sentiment
53
  ALBERT student model trained via **Patient Knowledge Distillation** on scraped
54
+ financial headlines. Matches FinBERT teacher's performance on macro-F1 at
55
+ ~40% parameter count.
56
 
57
  API endpoint: `POST /predict` β€” see [/docs](/docs) for full spec.
58
+
59
+ *Examples below are real headlines from the held-out test set.*
60
  """)
61
 
62
  text_input = gr.Textbox(
63
  label="Financial Headline",
64
+ placeholder="e.g. Charles Schwab price target raised to $121 from $119 at JPMorgan",
65
  lines=2,
66
  )
67
 
 
73
  latency_out = gr.Textbox(label="Latency")
74
 
75
  gr.Examples(
76
+ label="Real headlines from test set",
77
  examples=[
78
+ # positive
79
+ ["Charles Schwab price target raised to $121 from $119 at JPMorgan"],
80
+ # negative
81
+ ["Starbucks price target lowered to $94 from $100 at UBS"],
82
+ # neutral
83
+ ["Costco assumed with a Peer Perform at Wolfe Research"],
84
+ # positive
85
+ ["Morning Movers: General Motors and RTX higher following Q3 reports"],
86
+ # negative
87
+ ["PayPal price target lowered to $65 from $68 at Truist"],
88
+ # neutral
89
+ ["Bernstein Keeps Their Hold Rating on Deere (DE)"],
90
+ # positive
91
+ ["Micron price target raised to $245 from $225 at UBS"],
92
+ # negative
93
+ ["Mixed options sentiment in Exxon Mobil with shares down 1.86%"],
94
+ # neutral
95
+ ["EU approves Boeing's acquisition of Spirit AeroSystems, with conditions"],
96
+ # positive
97
+ ["Morning Movers: Charles Schwab rises following third quarter earnings"],
98
+ # negative
99
+ ["Expect Starbucks' (SBUX) Turnaround to 'Take Longer than Expected,' Says BTIG"],
100
+ # neutral
101
+ ["Bank of America (BAC) Receives a Rating Update from a Top Analyst"],
102
+ # positive
103
+ ["Amazon's Stock (AMZN) Pops as It Lands JetBlue as First Airline Partner for Project Kuiper"],
104
+ # negative
105
+ ["NVDA, MSFT, GOOGL: Ray Dalio's Bridgewater Loses Confidence in Big Tech, Trims Stakes in Q3"],
106
+ # neutral
107
+ ["SAP SE (0NW4): New Buy Recommendation for This Technology Giant"],
108
  ],
109
  inputs=text_input,
110
  )
 
115
  outputs=[label_out, confidence_out, latency_out],
116
  )
117
 
 
118
  app = gr.mount_gradio_app(app, demo, path="/")