Update README.md
Browse files
README.md
CHANGED
|
@@ -29,5 +29,8 @@ model.to("cuda")
|
|
| 29 |
pairs = ["pandas usually live in the jungles"]
|
| 30 |
with torch.no_grad():
|
| 31 |
inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
```
|
|
|
|
| 29 |
pairs = ["pandas usually live in the jungles"]
|
| 30 |
with torch.no_grad():
|
| 31 |
inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
|
| 32 |
+
sentence_embeddings = model(**inputs)[0][:, 0]
|
| 33 |
+
|
| 34 |
+
# normalize embeddings
|
| 35 |
+
sentence_embeddings = torch.nn.functional.normalize(sentence_embeddings, p=2, dim=1)
|
| 36 |
```
|