vives commited on
Commit
8d94e80
1 Parent(s): cbfaf6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -12,11 +12,14 @@ if choice == "distilbert-cvent":
12
  model_checkpoint = "vives/distilbert-base-uncased-finetuned-cvent-2019_2022"
13
  model = AutoModelForMaskedLM.from_pretrained(model_checkpoint, output_hidden_states=True)
14
  tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
 
 
15
  elif choice == "finbert":
16
  model_checkpoint = "ProsusAI/finbert"
17
  tokenizer = AutoTokenizer.from_pretrained("ProsusAI/finbert")
18
  model = AutoModelForSequenceClassification.from_pretrained("ProsusAI/finbert", output_hidden_states=True)
19
-
 
20
  text = st.text_input("Enter word or key-phrase")
21
 
22
  exclude_words = st.radio("exclude_words",[True,False], help="Exclude results that contain any words in the query (i.e exclude 'hot coffee' if the query is 'cold coffee')")
@@ -29,8 +32,8 @@ with st.sidebar:
29
  if diversify_box:
30
  k_diversify = st.number_input("Set of key-phrases to diversify from",10,30,20)
31
 
32
- #load kp dict
33
- with open("kp_dict_merged.pickle",'rb') as handle:
34
  kp_dict = pickle.load(handle)
35
  keys = list(kp_dict.keys())
36
 
@@ -38,7 +41,7 @@ for key in kp_dict.keys():
38
  kp_dict[key] = kp_dict[key].detach().numpy()
39
 
40
  #load cosine distances of kp dict
41
- with open("cosine_kp.pickle",'rb') as handle:
42
  cosine_kp = pickle.load(handle)
43
 
44
  def calculate_top_k(out, tokens,text,exclude_text=False,exclude_words=False, k=5):
 
12
  model_checkpoint = "vives/distilbert-base-uncased-finetuned-cvent-2019_2022"
13
  model = AutoModelForMaskedLM.from_pretrained(model_checkpoint, output_hidden_states=True)
14
  tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
15
+ kp_dict_checkpoint = "kp_dict_finbert.pickle"
16
+ kp_cosine_checkpoint = "cosine_kp_finbert.pickle"
17
  elif choice == "finbert":
18
  model_checkpoint = "ProsusAI/finbert"
19
  tokenizer = AutoTokenizer.from_pretrained("ProsusAI/finbert")
20
  model = AutoModelForSequenceClassification.from_pretrained("ProsusAI/finbert", output_hidden_states=True)
21
+ kp_dict_checkpoint = "kp_dict_merged.pickle"
22
+ kp_cosine_checkpoint = "cosine_kp.pickle"
23
  text = st.text_input("Enter word or key-phrase")
24
 
25
  exclude_words = st.radio("exclude_words",[True,False], help="Exclude results that contain any words in the query (i.e exclude 'hot coffee' if the query is 'cold coffee')")
 
32
  if diversify_box:
33
  k_diversify = st.number_input("Set of key-phrases to diversify from",10,30,20)
34
 
35
+ #load kp di
36
+ with open(kp_dict_checkpoint,'rb') as handle:
37
  kp_dict = pickle.load(handle)
38
  keys = list(kp_dict.keys())
39
 
 
41
  kp_dict[key] = kp_dict[key].detach().numpy()
42
 
43
  #load cosine distances of kp dict
44
+ with open(kp_cosine_checkpoint,'rb') as handle:
45
  cosine_kp = pickle.load(handle)
46
 
47
  def calculate_top_k(out, tokens,text,exclude_text=False,exclude_words=False, k=5):