nickmuchi commited on
Commit
d39ea15
β€’
1 Parent(s): a322a26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -28,6 +28,7 @@ st.markdown(
28
  This app assists finance analysts with transcribing and analysis Earnings Calls by carrying out the following tasks:
29
  - Transcribing earnings calls using Open AI's [Whisper](https://github.com/openai/whisper).
30
  - Analysing the sentiment of transcribed text using the quantized version of [FinBert-Tone](https://huggingface.co/nickmuchi/quantized-optimum-finbert-tone).
 
31
  - Semantic search engine with [Sentence-Transformers](https://huggingface.co/sentence-transformers/all-mpnet-base-v2) and reranking results with a Cross-Encoder.
32
 
33
  **πŸ‘‡ Enter a YouTube Earnings Call URL below and navigate to the sidebar tabs**
@@ -54,11 +55,13 @@ def load_models():
54
  asr_model = whisper.load_model("small")
55
  q_model = ORTModelForSequenceClassification.from_pretrained("nickmuchi/quantized-optimum-finbert-tone")
56
  q_tokenizer = AutoTokenizer.from_pretrained("nickmuchi/quantized-optimum-finbert-tone")
 
 
57
  cross_encoder = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-12-v2')
58
 
59
- return asr_model, q_model, q_tokenizer, cross_encoder
60
 
61
- asr_model, q_model, q_tokenizer, cross_encoder = load_models()
62
 
63
  @st.experimental_memo(suppress_st_warning=True)
64
  def inference(link, upload):
@@ -83,11 +86,10 @@ def inference(link, upload):
83
  def sentiment_pipe(earnings_text):
84
  '''Determine the sentiment of the text'''
85
 
86
- remote_clx = pipeline("text-classification",model=q_model, tokenizer=q_tokenizer)
87
-
88
- earnings_sentiment = remote_clx(sent_tokenize(earnings_text))
89
 
90
- return earnings_sentiment
91
 
92
  @st.experimental_memo(suppress_st_warning=True)
93
  def preprocess_plain_text(text,window_size=3):
@@ -151,4 +153,4 @@ def fin_ext(text):
151
  results = remote_clx(sent_tokenizer(text))
152
  return make_spans(text,results)
153
 
154
- progress_bar.empty()
 
28
  This app assists finance analysts with transcribing and analysis Earnings Calls by carrying out the following tasks:
29
  - Transcribing earnings calls using Open AI's [Whisper](https://github.com/openai/whisper).
30
  - Analysing the sentiment of transcribed text using the quantized version of [FinBert-Tone](https://huggingface.co/nickmuchi/quantized-optimum-finbert-tone).
31
+ - Summarization of the call with [FaceBook-Bart](https://huggingface.co/facebook/bart-large-cnn) model with entity extraction
32
  - Semantic search engine with [Sentence-Transformers](https://huggingface.co/sentence-transformers/all-mpnet-base-v2) and reranking results with a Cross-Encoder.
33
 
34
  **πŸ‘‡ Enter a YouTube Earnings Call URL below and navigate to the sidebar tabs**
 
55
  asr_model = whisper.load_model("small")
56
  q_model = ORTModelForSequenceClassification.from_pretrained("nickmuchi/quantized-optimum-finbert-tone")
57
  q_tokenizer = AutoTokenizer.from_pretrained("nickmuchi/quantized-optimum-finbert-tone")
58
+ sent_pipe = pipeline("text-classification",model=q_model, tokenizer=q_tokenizer)
59
+ sum_pipe = pipeline("summarization",model="facebook/bart-large-cnn", tokenizer="facebook/bart-large-cnn")
60
  cross_encoder = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-12-v2')
61
 
62
+ return asr_model, sent_pipe, sum_pipe, cross_encoder
63
 
64
+ asr_model, sent_pipe, sum_pipe, cross_encoder = load_models()
65
 
66
  @st.experimental_memo(suppress_st_warning=True)
67
  def inference(link, upload):
 
86
  def sentiment_pipe(earnings_text):
87
  '''Determine the sentiment of the text'''
88
 
89
+ earnings_sentences = sent_tokenize(earnings_text)
90
+ earnings_sentiment = sent_pipe(earnings_sentences)
 
91
 
92
+ return earnings_sentiment, earnings_sentences
93
 
94
  @st.experimental_memo(suppress_st_warning=True)
95
  def preprocess_plain_text(text,window_size=3):
 
153
  results = remote_clx(sent_tokenizer(text))
154
  return make_spans(text,results)
155
 
156
+ progress_bar.empty()