Owos commited on
Commit
eb484c3
·
1 Parent(s): 0a83a1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -255,18 +255,22 @@ with st.columns(1)[0]:
255
 
256
  scores = {}
257
  for index, model_id in enumerate(selected_models):
258
- tokenizer = AutoTokenizer.from_pretrained(model_id)
259
- model = AutoModelWithLMHead.from_pretrained(model_id)
260
- if model_id.startswith("castorini"):
261
- tokenizer.model_max_length = 512
262
- MLM_MASK_TOKEN = tokenizer.mask_token_id # [(103, '[MASK]')]
263
- MLM_UNK_TOKEN = tokenizer.unk_token_id
264
-
265
- BATCH_SIZE = 1
266
- score = get_sense_score_batched(
267
- sentence, tokenizer, model, MLM_MASK_TOKEN, MLM_UNK_TOKEN, BATCH_SIZE
268
- )
269
- scores[model_id] = score
 
 
 
 
270
  my_bar.progress((index + 1) / len(selected_models))
271
  scores = sort_dictionary(scores)
272
  st.write("Our recommendation is:", scores)
 
255
 
256
  scores = {}
257
  for index, model_id in enumerate(selected_models):
258
+ try:
259
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
260
+ model = AutoModelWithLMHead.from_pretrained(model_id)
261
+ if model_id.startswith("castorini"):
262
+ tokenizer.model_max_length = 512
263
+ MLM_MASK_TOKEN = tokenizer.mask_token_id # [(103, '[MASK]')]
264
+ MLM_UNK_TOKEN = tokenizer.unk_token_id
265
+
266
+ BATCH_SIZE = 1
267
+ score = get_sense_score_batched(
268
+ sentence, tokenizer, model, MLM_MASK_TOKEN, MLM_UNK_TOKEN, BATCH_SIZE
269
+ )
270
+ scores[model_id] = score
271
+ except:
272
+ scores[model_id] = 0
273
+
274
  my_bar.progress((index + 1) / len(selected_models))
275
  scores = sort_dictionary(scores)
276
  st.write("Our recommendation is:", scores)