Update README.md
Browse files
README.md
CHANGED
@@ -1,156 +1,166 @@
|
|
1 |
-
---
|
2 |
-
language:
|
3 |
-
- multilingual
|
4 |
-
- ar
|
5 |
-
- bg
|
6 |
-
- ca
|
7 |
-
- cs
|
8 |
-
- da
|
9 |
-
- de
|
10 |
-
- el
|
11 |
-
- en
|
12 |
-
- es
|
13 |
-
- et
|
14 |
-
- fa
|
15 |
-
- fi
|
16 |
-
- fr
|
17 |
-
- gl
|
18 |
-
- gu
|
19 |
-
- he
|
20 |
-
- hi
|
21 |
-
- hr
|
22 |
-
- hu
|
23 |
-
- hy
|
24 |
-
- id
|
25 |
-
- it
|
26 |
-
- ja
|
27 |
-
- ka
|
28 |
-
- ko
|
29 |
-
- ku
|
30 |
-
- lt
|
31 |
-
- lv
|
32 |
-
- mk
|
33 |
-
- mn
|
34 |
-
- mr
|
35 |
-
- ms
|
36 |
-
- my
|
37 |
-
- nb
|
38 |
-
- nl
|
39 |
-
- pl
|
40 |
-
- pt
|
41 |
-
- ro
|
42 |
-
- ru
|
43 |
-
- sk
|
44 |
-
- sl
|
45 |
-
- sq
|
46 |
-
- sr
|
47 |
-
- sv
|
48 |
-
- th
|
49 |
-
- tr
|
50 |
-
- uk
|
51 |
-
- ur
|
52 |
-
- vi
|
53 |
-
license: apache-2.0
|
54 |
-
library_name: sentence-transformers
|
55 |
-
tags:
|
56 |
-
- sentence-transformers
|
57 |
-
- feature-extraction
|
58 |
-
- sentence-similarity
|
59 |
-
- transformers
|
60 |
-
language_bcp47:
|
61 |
-
- fr-ca
|
62 |
-
- pt-br
|
63 |
-
- zh-cn
|
64 |
-
- zh-tw
|
65 |
-
pipeline_tag: sentence-similarity
|
66 |
-
---
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
This is a [sentence-transformers](https://
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
#
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
#
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
)
|
139 |
-
```
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
```
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- multilingual
|
4 |
+
- ar
|
5 |
+
- bg
|
6 |
+
- ca
|
7 |
+
- cs
|
8 |
+
- da
|
9 |
+
- de
|
10 |
+
- el
|
11 |
+
- en
|
12 |
+
- es
|
13 |
+
- et
|
14 |
+
- fa
|
15 |
+
- fi
|
16 |
+
- fr
|
17 |
+
- gl
|
18 |
+
- gu
|
19 |
+
- he
|
20 |
+
- hi
|
21 |
+
- hr
|
22 |
+
- hu
|
23 |
+
- hy
|
24 |
+
- id
|
25 |
+
- it
|
26 |
+
- ja
|
27 |
+
- ka
|
28 |
+
- ko
|
29 |
+
- ku
|
30 |
+
- lt
|
31 |
+
- lv
|
32 |
+
- mk
|
33 |
+
- mn
|
34 |
+
- mr
|
35 |
+
- ms
|
36 |
+
- my
|
37 |
+
- nb
|
38 |
+
- nl
|
39 |
+
- pl
|
40 |
+
- pt
|
41 |
+
- ro
|
42 |
+
- ru
|
43 |
+
- sk
|
44 |
+
- sl
|
45 |
+
- sq
|
46 |
+
- sr
|
47 |
+
- sv
|
48 |
+
- th
|
49 |
+
- tr
|
50 |
+
- uk
|
51 |
+
- ur
|
52 |
+
- vi
|
53 |
+
license: apache-2.0
|
54 |
+
library_name: sentence-transformers
|
55 |
+
tags:
|
56 |
+
- sentence-transformers
|
57 |
+
- feature-extraction
|
58 |
+
- sentence-similarity
|
59 |
+
- transformers
|
60 |
+
language_bcp47:
|
61 |
+
- fr-ca
|
62 |
+
- pt-br
|
63 |
+
- zh-cn
|
64 |
+
- zh-tw
|
65 |
+
pipeline_tag: sentence-similarity
|
66 |
+
---
|
67 |
+
|
68 |
+
Please do not use.
|
69 |
+
|
70 |
+
This is just a backup for [sentence-transformers/paraphrase-multilingual-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2).
|
71 |
+
|
72 |
+
-----
|
73 |
+
|
74 |
+
-----
|
75 |
+
|
76 |
+
-----
|
77 |
+
|
78 |
+
# sentence-transformers/paraphrase-multilingual-mpnet-base-v2
|
79 |
+
|
80 |
+
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
## Usage (Sentence-Transformers)
|
85 |
+
|
86 |
+
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
|
87 |
+
|
88 |
+
```
|
89 |
+
pip install -U sentence-transformers
|
90 |
+
```
|
91 |
+
|
92 |
+
Then you can use the model like this:
|
93 |
+
|
94 |
+
```python
|
95 |
+
from sentence_transformers import SentenceTransformer
|
96 |
+
sentences = ["This is an example sentence", "Each sentence is converted"]
|
97 |
+
|
98 |
+
model = SentenceTransformer('sentence-transformers/paraphrase-multilingual-mpnet-base-v2')
|
99 |
+
embeddings = model.encode(sentences)
|
100 |
+
print(embeddings)
|
101 |
+
```
|
102 |
+
|
103 |
+
|
104 |
+
|
105 |
+
## Usage (HuggingFace Transformers)
|
106 |
+
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
|
107 |
+
|
108 |
+
```python
|
109 |
+
from transformers import AutoTokenizer, AutoModel
|
110 |
+
import torch
|
111 |
+
|
112 |
+
|
113 |
+
#Mean Pooling - Take attention mask into account for correct averaging
|
114 |
+
def mean_pooling(model_output, attention_mask):
|
115 |
+
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
|
116 |
+
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
117 |
+
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
118 |
+
|
119 |
+
|
120 |
+
# Sentences we want sentence embeddings for
|
121 |
+
sentences = ['This is an example sentence', 'Each sentence is converted']
|
122 |
+
|
123 |
+
# Load model from HuggingFace Hub
|
124 |
+
tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/paraphrase-multilingual-mpnet-base-v2')
|
125 |
+
model = AutoModel.from_pretrained('sentence-transformers/paraphrase-multilingual-mpnet-base-v2')
|
126 |
+
|
127 |
+
# Tokenize sentences
|
128 |
+
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
|
129 |
+
|
130 |
+
# Compute token embeddings
|
131 |
+
with torch.no_grad():
|
132 |
+
model_output = model(**encoded_input)
|
133 |
+
|
134 |
+
# Perform pooling. In this case, average pooling
|
135 |
+
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
|
136 |
+
|
137 |
+
print("Sentence embeddings:")
|
138 |
+
print(sentence_embeddings)
|
139 |
+
```
|
140 |
+
|
141 |
+
|
142 |
+
|
143 |
+
## Full Model Architecture
|
144 |
+
```
|
145 |
+
SentenceTransformer(
|
146 |
+
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
|
147 |
+
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
|
148 |
+
)
|
149 |
+
```
|
150 |
+
|
151 |
+
## Citing & Authors
|
152 |
+
|
153 |
+
This model was trained by [sentence-transformers](https://www.sbert.net/).
|
154 |
+
|
155 |
+
If you find this model helpful, feel free to cite our publication [Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks](https://arxiv.org/abs/1908.10084):
|
156 |
+
```bibtex
|
157 |
+
@inproceedings{reimers-2019-sentence-bert,
|
158 |
+
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
|
159 |
+
author = "Reimers, Nils and Gurevych, Iryna",
|
160 |
+
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
|
161 |
+
month = "11",
|
162 |
+
year = "2019",
|
163 |
+
publisher = "Association for Computational Linguistics",
|
164 |
+
url = "http://arxiv.org/abs/1908.10084",
|
165 |
+
}
|
166 |
```
|