Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,11 @@ class CustomHuggingFaceEmbeddings:
|
|
17 |
self.model = AutoModel.from_pretrained(model_name)
|
18 |
|
19 |
def embed_text(self, text):
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
with torch.no_grad():
|
22 |
outputs = self.model(**inputs)
|
23 |
return outputs.last_hidden_state.mean(dim=1).squeeze().tolist()
|
|
|
17 |
self.model = AutoModel.from_pretrained(model_name)
|
18 |
|
19 |
def embed_text(self, text):
|
20 |
+
try:
|
21 |
+
inputs = self.tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
22 |
+
except Exception as e:
|
23 |
+
print(f"Error during tokenization: {e}")
|
24 |
+
return []
|
25 |
with torch.no_grad():
|
26 |
outputs = self.model(**inputs)
|
27 |
return outputs.last_hidden_state.mean(dim=1).squeeze().tolist()
|