Spaces:
Build error
Build error
#import pickle | |
import joblib | |
import gradio as gr | |
from sentence_transformers import SentenceTransformer | |
import lightgbm | |
lr_clf_finbert = joblib.load('lgb.pkl')#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() |