ajitrajasekharan commited on
Commit
de31505
·
1 Parent(s): 8a3b8f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -54,8 +54,8 @@ def get_all_predictions(text_sentence, model_name,top_clean=5):
54
 
55
  with torch.no_grad():
56
  predict = bert_model(input_ids)[0]
57
- bert = decode(bert_tokenizer, predict[0, mask_idx, :].topk(top_k*5).indices.tolist(), top_clean)
58
- cls = decode(bert_tokenizer, predict[0, 0, :].topk(top_k*5).indices.tolist(), top_clean)
59
 
60
  if ("[MASK]" in text_sentence or "<mask>" in text_sentence):
61
  return {'Input sentence':text_sentence,'Tokenized text': tokenized_text, 'results_count':top_k,'Model':model_name,'Masked position': bert,'[CLS]':cls}
@@ -143,7 +143,7 @@ def main():
143
  st.write("This app can be used to examine both model prediction for a masked position as well as the neighborhood of CLS vector")
144
  st.write(" - To examine model prediction for a position, enter the token [MASK] or <mask>")
145
  st.write(" - To examine just the [CLS] vector, enter a word/phrase or sentence. Example: eGFR or EGFR or non small cell lung cancer")
146
- st.sidebar.slider("Select how many predictions do you need", 1 , 50, 20,key='my_slider',on_change=on_results_count_change) #some times it is possible to have less words
147
 
148
 
149
  try:
 
54
 
55
  with torch.no_grad():
56
  predict = bert_model(input_ids)[0]
57
+ bert = decode(bert_tokenizer, predict[0, mask_idx, :].topk(top_k*10).indices.tolist(), top_clean)
58
+ cls = decode(bert_tokenizer, predict[0, 0, :].topk(top_k*10).indices.tolist(), top_clean)
59
 
60
  if ("[MASK]" in text_sentence or "<mask>" in text_sentence):
61
  return {'Input sentence':text_sentence,'Tokenized text': tokenized_text, 'results_count':top_k,'Model':model_name,'Masked position': bert,'[CLS]':cls}
 
143
  st.write("This app can be used to examine both model prediction for a masked position as well as the neighborhood of CLS vector")
144
  st.write(" - To examine model prediction for a position, enter the token [MASK] or <mask>")
145
  st.write(" - To examine just the [CLS] vector, enter a word/phrase or sentence. Example: eGFR or EGFR or non small cell lung cancer")
146
+ st.sidebar.slider("Select how count of predictions to display", 1 , 50, 20,key='my_slider',on_change=on_results_count_change) #some times it is possible to have less words
147
 
148
 
149
  try: