Tom Aarsen
commited on
Commit
·
799acf9
1
Parent(s):
645fd27
embeddings models -> embedding models
Browse files
README.md
CHANGED
@@ -45,9 +45,9 @@ from transformers import AutoTokenizer, AutoModel
|
|
45 |
import torch
|
46 |
|
47 |
|
48 |
-
#Mean Pooling - Take attention mask into account for correct averaging
|
49 |
def mean_pooling(model_output, attention_mask):
|
50 |
-
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
|
51 |
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
52 |
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
53 |
|
@@ -75,7 +75,7 @@ print(sentence_embeddings)
|
|
75 |
|
76 |
## Usage (Text Embeddings Inference (TEI))
|
77 |
|
78 |
-
[Text Embeddings Inference (TEI)](https://github.com/huggingface/text-embeddings-inference) is a blazing fast inference solution for text
|
79 |
|
80 |
- CPU:
|
81 |
```bash
|
|
|
45 |
import torch
|
46 |
|
47 |
|
48 |
+
# Mean Pooling - Take attention mask into account for correct averaging
|
49 |
def mean_pooling(model_output, attention_mask):
|
50 |
+
token_embeddings = model_output[0] # First element of model_output contains all token embeddings
|
51 |
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
52 |
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
53 |
|
|
|
75 |
|
76 |
## Usage (Text Embeddings Inference (TEI))
|
77 |
|
78 |
+
[Text Embeddings Inference (TEI)](https://github.com/huggingface/text-embeddings-inference) is a blazing fast inference solution for text embedding models.
|
79 |
|
80 |
- CPU:
|
81 |
```bash
|