Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,15 +74,15 @@ class EmbeddingModels:
|
|
| 74 |
df_chunk = self.preprocessing_patent_data(df_chunk)
|
| 75 |
txt_sp = self.sparse_model.encode_documents(df_chunk)
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
#
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
return txt_sp
|
| 87 |
|
| 88 |
|
|
|
|
| 74 |
df_chunk = self.preprocessing_patent_data(df_chunk)
|
| 75 |
txt_sp = self.sparse_model.encode_documents(df_chunk)
|
| 76 |
|
| 77 |
+
tensor = torch.tensor(txt_sp['values'])
|
| 78 |
+
normalized_tensor = F.normalize(tensor, p=2.0, dim=0, eps=1e-12)
|
| 79 |
+
values = normalized_tensor.tolist()
|
| 80 |
+
|
| 81 |
+
# Update the sparse_vector with normalized values
|
| 82 |
+
normalized_sparse_vector = {
|
| 83 |
+
'indices': txt_sp['indices'],
|
| 84 |
+
'values': values
|
| 85 |
+
}
|
| 86 |
return txt_sp
|
| 87 |
|
| 88 |
|