sohomghosh commited on
Commit
f507b04
β€’
1 Parent(s): f43394f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import gradio as gr
3
+ from sentence_transformers import SentenceTransformer
4
+ lr_clf_finbert = pickle.load(open("clf_lgbm_finbert.pickle", 'rb'))
5
+ model = SentenceTransformer('ProsusAI/finbert')
6
+
7
+ def get_readability(text):
8
+ emd = model.encode([text])
9
+ ans = 'not readable'
10
+ if lr_clf_finbert.predict(emd)==1:
11
+ ans = 'readable'
12
+ score = str(round(lr_clf_finbert.predict_proba(emd)[0,1],4))
13
+ return "Prediction: "+ans +"\nPredicted probability: "+ score
14
+
15
+ iface = gr.Interface(fn=get_readability, inputs="textbox", title="FinRead",description="Financial Readability Assessment Tool", outputs="textbox", allow_flagging="never", examples=[['Inflation is the rate of increase in prices over a given period of time. Inflation is typically a broad measure, such as the overall increase in prices or the increase in the cost of living in a country.'], ['Legally assured line of credit with a bank'], ['A mutual fund is a type of financial vehicle made up of a pool of money collected from many investors to invest in securities like stocks, bonds, money market instruments']])
16
+ iface.launch()