utrobinmv commited on
Commit
b35a515
1 Parent(s): 1828029

update readme

Browse files
Files changed (1) hide show
  1. README.md +22 -3
README.md CHANGED
@@ -52,10 +52,29 @@ Then you can use the model like this:
52
 
53
  ```python
54
  from sentence_transformers import SentenceTransformer
55
- sentences = ["This is an example sentence", "Each sentence is converted"]
 
56
  model = SentenceTransformer('utrobinmv/t5_translate_en_ru_zh_base_200_sent')
57
- embeddings = model.encode(sentences)
58
- print(embeddings)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  ```
60
 
61
 
 
52
 
53
  ```python
54
  from sentence_transformers import SentenceTransformer
55
+ import torch.nn.functional as F
56
+
57
  model = SentenceTransformer('utrobinmv/t5_translate_en_ru_zh_base_200_sent')
58
+
59
+ sentences_1 = ["The purpose of the development is to provide users with a personal simultaneous interpreter.",
60
+ "Съешь ещё этих мягких французских булок.",
61
+ "再吃这些法国的甜蜜的面包。"]
62
+
63
+ sentences_2 = ["Цель разработки — предоставить пользователям личного синхронного переводчика.",
64
+ "Have some more of these soft French rolls.",
65
+ "开发的目的就是向用户提供个性化的同步翻译。"]
66
+
67
+ embeddings = model.encode(sentences_1+sentences_2)
68
+ embeddings_1 = embeddings[:len(sentences_1)]
69
+ embeddings_2 = embeddings[len(sentences_1):]
70
+
71
+ similarity = embeddings_1 @ embeddings_2.T
72
+ print(similarity)
73
+ #[[ 0.8956245 -0.0390042 0.8493222 ]
74
+ # [ 0.00778637 0.85185283 -0.010229 ]
75
+ # [ 0.01991986 0.72560245 0.02547248]]
76
+
77
+
78
  ```
79
 
80