Update README.md
Browse files
README.md
CHANGED
@@ -27,19 +27,26 @@ After installing the package, you can load our model by two lines of code
|
|
27 |
```python
|
28 |
from promcse import PromCSE
|
29 |
model = PromCSE("hellonlp/promcse-roberta-base-zh", "cls", 10)
|
30 |
-
|
31 |
```
|
32 |
|
33 |
Then you can use our model for **encoding sentences into embeddings**
|
34 |
```python
|
35 |
embeddings = model.encode("武汉是一个美丽的城市。")
|
|
|
|
|
36 |
```
|
37 |
|
38 |
**Compute the cosine similarities** between two groups of sentences
|
39 |
```python
|
40 |
-
sentences_a = ['
|
41 |
-
sentences_b = ['
|
|
|
|
|
42 |
similarities = model.similarity(sentences_a, sentences_b)
|
|
|
|
|
|
|
|
|
43 |
```
|
44 |
|
45 |
|
|
|
27 |
```python
|
28 |
from promcse import PromCSE
|
29 |
model = PromCSE("hellonlp/promcse-roberta-base-zh", "cls", 10)
|
|
|
30 |
```
|
31 |
|
32 |
Then you can use our model for **encoding sentences into embeddings**
|
33 |
```python
|
34 |
embeddings = model.encode("武汉是一个美丽的城市。")
|
35 |
+
print(embeddings.shape)
|
36 |
+
#torch.Size([768])
|
37 |
```
|
38 |
|
39 |
**Compute the cosine similarities** between two groups of sentences
|
40 |
```python
|
41 |
+
sentences_a = ['你好吗']
|
42 |
+
sentences_b = ['你怎么样','我吃了一个苹果','你过的好吗','你还好吗','你',
|
43 |
+
'你好不好','你好不好呢','我不开心','我好开心啊', '你吃饭了吗',
|
44 |
+
'你好吗','你现在好吗','你好个鬼']
|
45 |
similarities = model.similarity(sentences_a, sentences_b)
|
46 |
+
print(similarities)
|
47 |
+
#[[0.7818036 , 0.0754933 , 0.751326 , 0.83766925, 0.6286671 ,
|
48 |
+
# 0.917025 , 0.8861941 , 0.20904644, 0.41348672, 0.5587336 ,
|
49 |
+
# 1.0000001 , 0.7798723 , 0.70388055]]
|
50 |
```
|
51 |
|
52 |
|