Update README.md
Browse files
README.md
CHANGED
|
@@ -2660,6 +2660,9 @@ Training data to train the models is released in its entirety. For more details,
|
|
| 2660 |
|
| 2661 |
## Usage
|
| 2662 |
|
|
|
|
|
|
|
|
|
|
| 2663 |
|
| 2664 |
```python
|
| 2665 |
import torch
|
|
@@ -2671,7 +2674,7 @@ def mean_pooling(model_output, attention_mask):
|
|
| 2671 |
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
| 2672 |
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
| 2673 |
|
| 2674 |
-
sentences = ['What is TSNE?', 'Who is Laurens van der Maaten?']
|
| 2675 |
|
| 2676 |
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
| 2677 |
model = AutoModel.from_pretrained('nomic-ai/nomic-embed-text-v1-unsupervised', trust_remote_code=True)
|
|
|
|
| 2660 |
|
| 2661 |
## Usage
|
| 2662 |
|
| 2663 |
+
Note `nomic-embed-text` requires prefixes! We support the prefixes `[search_query, search_document, classification, clustering]`.
|
| 2664 |
+
For retrieval applications, you should prepend `search_document` for all your documents and `search_query` for your queries.
|
| 2665 |
+
|
| 2666 |
|
| 2667 |
```python
|
| 2668 |
import torch
|
|
|
|
| 2674 |
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
| 2675 |
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
| 2676 |
|
| 2677 |
+
sentences = ['search_query: What is TSNE?', 'search_query: Who is Laurens van der Maaten?']
|
| 2678 |
|
| 2679 |
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
| 2680 |
model = AutoModel.from_pretrained('nomic-ai/nomic-embed-text-v1-unsupervised', trust_remote_code=True)
|