mgbam commited on
Commit
72145e5
·
verified ·
1 Parent(s): 36083ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -50,12 +50,12 @@ def get_st(tgt):
50
  st.error("Failed to obtain service ticket from UMLS API.")
51
  st.stop()
52
 
53
- # Text embedding
54
  @st.cache_resource
55
- def embed_text(text, tokenizer, model):
56
- inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
57
  with torch.no_grad():
58
- outputs = model(**inputs)
59
  emb = outputs.last_hidden_state[:, 0, :].squeeze().cpu().numpy()
60
  return emb / np.linalg.norm(emb)
61
 
 
50
  st.error("Failed to obtain service ticket from UMLS API.")
51
  st.stop()
52
 
53
+ # Text embedding (tokenizer and model are unhashable, prefix with underscore)
54
  @st.cache_resource
55
+ def embed_text(text, _tokenizer, _model):
56
+ inputs = _tokenizer(text, return_tensors="pt", truncation=True, padding=True)
57
  with torch.no_grad():
58
+ outputs = _model(**inputs)
59
  emb = outputs.last_hidden_state[:, 0, :].squeeze().cpu().numpy()
60
  return emb / np.linalg.norm(emb)
61