File size: 1,117 Bytes
f507b04
 
 
8f5317b
f507b04
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import pickle
import gradio as gr
from sentence_transformers import SentenceTransformer
import lightgbm
lr_clf_finbert = pickle.load(open("clf_lgbm_finbert.pickle", 'rb'))
model = SentenceTransformer('ProsusAI/finbert')

def get_readability(text):
  emd = model.encode([text])
  ans = 'not readable'
  if lr_clf_finbert.predict(emd)==1:
    ans = 'readable'
  score = str(round(lr_clf_finbert.predict_proba(emd)[0,1],4))
  return "Prediction: "+ans +"\nPredicted probability: "+ score

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']])
iface.launch()