Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -106,15 +106,8 @@ outputs = session.run(None, {
|
|
| 106 |
"attention_mask": inputs["attention_mask"].astype(np.int64),
|
| 107 |
})
|
| 108 |
|
| 109 |
-
#
|
| 110 |
-
|
| 111 |
-
attention_mask = inputs["attention_mask"]
|
| 112 |
-
mask_expanded = np.expand_dims(attention_mask, -1)
|
| 113 |
-
sum_embeddings = np.sum(hidden_states * mask_expanded, axis=1)
|
| 114 |
-
sum_mask = np.sum(mask_expanded, axis=1)
|
| 115 |
-
embedding = sum_embeddings / sum_mask # (1, 256)
|
| 116 |
-
|
| 117 |
-
# L2 normalize
|
| 118 |
embedding = embedding / np.linalg.norm(embedding, axis=1, keepdims=True)
|
| 119 |
```
|
| 120 |
|
|
|
|
| 106 |
"attention_mask": inputs["attention_mask"].astype(np.int64),
|
| 107 |
})
|
| 108 |
|
| 109 |
+
# Model outputs pooled embeddings, just L2 normalize
|
| 110 |
+
embedding = outputs[0] # (1, 256)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
embedding = embedding / np.linalg.norm(embedding, axis=1, keepdims=True)
|
| 112 |
```
|
| 113 |
|