numBery commited on
Commit
4158e04
1 Parent(s): 7f3cfe8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -14,17 +14,13 @@ import streamlit as st
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
 
16
  # Load KeyBert Model
17
- kw_extractor = KeyBERT('all-MiniLM-L6-v2')
18
- #kw_extractor = KeyBERT('distilbert-base-nli-mean-tokens')
19
 
20
  # Load T5 for Paraphrasing
21
- t5_model = T5ForConditionalGeneration.from_pretrained('ramsrigouthamg/t5_paraphraser')
22
  t5_tokenizer = T5Tokenizer.from_pretrained('t5-base')
23
  t5_model = t5_model.to(device)
24
 
25
-
26
- doc = st.text_area("Enter a custom document")
27
-
28
  def get_keybert_results_with_vectorizer(text, number_of_results=20):
29
  keywords = kw_extractor.extract_keywords(text, vectorizer=KeyphraseCountVectorizer(), stop_words=None, top_n=number_of_results)
30
  return keywords
@@ -83,5 +79,8 @@ def extract_paraphrased_sentences(article):
83
  return t5_paraphrasing_keywords
84
 
85
 
 
86
 
87
-
 
 
 
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
 
16
  # Load KeyBert Model
17
+ kw_extractor = KeyBERT('valurank/MiniLM-L6-Keyword-Extraction', use_auth_token=st.secrets["hf-auth-token"])
 
18
 
19
  # Load T5 for Paraphrasing
20
+ t5_model = T5ForConditionalGeneration.from_pretrained('valurank/t5-paraphraser', use_auth_token=st.secrets["hf-auth-token"])
21
  t5_tokenizer = T5Tokenizer.from_pretrained('t5-base')
22
  t5_model = t5_model.to(device)
23
 
 
 
 
24
  def get_keybert_results_with_vectorizer(text, number_of_results=20):
25
  keywords = kw_extractor.extract_keywords(text, vectorizer=KeyphraseCountVectorizer(), stop_words=None, top_n=number_of_results)
26
  return keywords
 
79
  return t5_paraphrasing_keywords
80
 
81
 
82
+ doc = st.text_area("Enter a custom document")
83
 
84
+ if doc:
85
+ keywords = extract_paraphrased_sentences(doc)
86
+ st.write(keywords)