Spaces:
Sleeping
Sleeping
import os | |
os.system("pip install gradio==3.0.18") | |
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification, AutoModelForTokenClassification | |
import gradio as gr | |
import spacy | |
nlp = spacy.load('en_core_web_sm') | |
nlp.add_pipe('sentencizer') | |
def split_in_sentences(text): | |
doc = nlp(text) | |
return [str(sent).strip() for sent in doc.sents] | |
def make_spans(text,results): | |
results_list = [] | |
for i in range(len(results)): | |
results_list.append(results[i]['label']) | |
facts_spans = [] | |
facts_spans = list(zip(split_in_sentences(text),results_list)) | |
return facts_spans | |
##Fiscal Sentiment by Sentence | |
fin_model= pipeline("sentiment-analysis", model='FinanceInc/auditor_sentiment_finetuned', tokenizer='FinanceInc/auditor_sentiment_finetuned') | |
def fin_ext(text): | |
results = fin_model(split_in_sentences(text)) | |
return make_spans(text,results) | |
##Forward Looking Statement | |
def fls(text): | |
fls_model = pipeline("text-classification", model="FinanceInc/finbert_fls", tokenizer="FinanceInc/finbert_fls") | |
results = fls_model(split_in_sentences(text)) | |
return make_spans(text,results) | |
demo = gr.Blocks() | |
with demo: | |
gr.Markdown("## Financial & Audit Analyst AI") | |
gr.Markdown("This AI trained model can be used by auditors to provide initial analysis of earning calls, financial statements, monetary policies and review any other financial document.") | |
with gr.Row(): | |
with gr.Column(): | |
with gr.Row(): | |
text = gr.Textbox(value="January 31, 2024 Federal Reserve issues FOMC statement For release at 2:00 p.m. EST. Recent indicators suggest that economic activity has been expanding at a solid pace. Job gains have moderated since early last year but remain strong, and the unemployment rate has remained low. Inflation has eased over the past year but remains elevated. The Committee seeks to achieve maximum employment and inflation at the rate of 2 percent over the longer run. The Committee judges that the risks to achieving its employment and inflation goals are moving into better balance. The economic outlook is uncertain, and the Committee remains highly attentive to inflation risks.In support of its goals, the Committee decided to maintain the target range for the federal funds rate at 5-1/4 to 5-1/2 percent. In considering any adjustments to the target range for the federal funds rate, the Committee will carefully assess incoming data, the evolving outlook, and the balance of risks. The Committee does not expect it will be appropriate to reduce the target range until it has gained greater confidence that inflation is moving sustainably toward 2 percent. In addition, the Committee will continue reducing its holdings of Treasury securities and agency debt and agency mortgage-backed securities, as described in its previously announced plans. The Committee is strongly committed to returning inflation to its 2 percent objective. In assessing the appropriate stance of monetary policy, the Committee will continue to monitor the implications of incoming information for the economic outlook. The Committee would be prepared to adjust the stance of monetary policy as appropriate if risks emerge that could impede the attainment of the Committee's goals. The Committee's assessments will take into account a wide range of information, including readings on labor market conditions, inflation pressures and inflation expectations, and financial and international developments. Voting for the monetary policy action were Jerome H. Powell, Chair; John C. Williams, Vice Chair; Thomas I. Barkin; Michael S. Barr; Raphael W. Bostic; Michelle W. Bowman; Lisa D. Cook; Mary C. Daly; Philip N. Jefferson; Adriana D. Kugler; Loretta J. Mester; and Christopher J. Waller. For media inquiries, please email [email protected] or call 202-452-2955. Implementation Note issued January 31, 2024") | |
with gr.Row(): | |
b5 = gr.Button("Run Financial Analysis") | |
with gr.Column(): | |
gr.Markdown("Sentiment Analysis") | |
with gr.Row(): | |
fin_spans = gr.HighlightedText() | |
gr.Markdown("Forward Looking Statement Analysis") | |
with gr.Row(): | |
fls_spans = gr.HighlightedText() | |
b5.click(fin_ext, inputs=text, outputs=fin_spans) | |
b5.click(fls, inputs=text, outputs=fls_spans) | |
demo.launch() |