Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
---
|
5 |
+
{sentence-transformers/LaBSE}{https://huggingface.co/sentence-transformers/LaBSE} pre-trained on an instructional question-and-answer dataset. Evaluated on Precision at K metrics and Mean reciprocal rank
|
6 |
+
```python
|
7 |
+
import torch
|
8 |
+
from transformers import AutoTokenizer, AutoModel
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained("zjkarina/LaBSE-instructDialogs")
|
10 |
+
model = AutoModel.from_pretrained("zjkarina/LaBSE-instructDialogs")
|
11 |
+
sentences = ["List 5 reasons why someone should learn to code", "Describe the sound of the wind on a sunny day."]
|
12 |
+
encoded_input = tokenizer(sentences, padding=True, truncation=True, max_length=64, return_tensors='pt')
|
13 |
+
with torch.no_grad():
|
14 |
+
model_output = model(**encoded_input)
|
15 |
+
embeddings = model_output.pooler_output
|
16 |
+
embeddings = torch.nn.functional.normalize(embeddings)
|
17 |
+
print(embeddings)
|
18 |
+
```
|