Update app.py
Browse files
app.py
CHANGED
@@ -230,13 +230,13 @@ def load_embedding_model(model_name="mixedbread-ai/mxbai-embed-large-v1"):
|
|
230 |
return tokenizer, model
|
231 |
|
232 |
@st.cache_data
|
233 |
-
def generate_embeddings(_tokenizer,
|
234 |
"""Generates embeddings for a list of text entries."""
|
235 |
encoded_input = _tokenizer(
|
236 |
text_list, padding=True, truncation=True, return_tensors="pt"
|
237 |
)
|
238 |
with torch.no_grad():
|
239 |
-
model_output =
|
240 |
embeddings = model_output.last_hidden_state.mean(dim=1)
|
241 |
return embeddings.cpu().numpy()
|
242 |
|
|
|
230 |
return tokenizer, model
|
231 |
|
232 |
@st.cache_data
|
233 |
+
def generate_embeddings(_tokenizer, _model, text_list):
|
234 |
"""Generates embeddings for a list of text entries."""
|
235 |
encoded_input = _tokenizer(
|
236 |
text_list, padding=True, truncation=True, return_tensors="pt"
|
237 |
)
|
238 |
with torch.no_grad():
|
239 |
+
model_output = _model(**encoded_input)
|
240 |
embeddings = model_output.last_hidden_state.mean(dim=1)
|
241 |
return embeddings.cpu().numpy()
|
242 |
|