Update README.md
Browse files
README.md
CHANGED
@@ -21,6 +21,19 @@ widget:
|
|
21 |
|
22 |
This is the sentence embedding model pre-trained by [UER-py](https://github.com/dbiir/UER-py/), which is introduced in [this paper](https://arxiv.org/abs/1909.05658).
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
## Training data
|
25 |
|
26 |
[ChineseTextualInference](https://github.com/liuhuanyong/ChineseTextualInference/) is used as training data.
|
|
|
21 |
|
22 |
This is the sentence embedding model pre-trained by [UER-py](https://github.com/dbiir/UER-py/), which is introduced in [this paper](https://arxiv.org/abs/1909.05658).
|
23 |
|
24 |
+
## How to use
|
25 |
+
|
26 |
+
You can use this model to extract sentence embeddings for sentence similarity task. We use cosine distance to calculate the embedding similarity here:
|
27 |
+
|
28 |
+
```python
|
29 |
+
>>> from sentence_transformers import SentenceTransformer
|
30 |
+
>>> model = SentenceTransformer('uer/sbert-base-chinese-nli')
|
31 |
+
>>> sentences = ['那个人很开心', '那个人非常开心']
|
32 |
+
>>> sentence_embeddings = model.encode(sentences)
|
33 |
+
>>> from sklearn.metrics.pairwise import paired_cosine_distances
|
34 |
+
>>> cosine_score = 1 - paired_cosine_distances([sentence_embeddings[0]],[sentence_embeddings[1]])
|
35 |
+
```
|
36 |
+
|
37 |
## Training data
|
38 |
|
39 |
[ChineseTextualInference](https://github.com/liuhuanyong/ChineseTextualInference/) is used as training data.
|