Utente
commited on
Commit
·
fa2c80e
1
Parent(s):
6857228
Push the entire model
Browse files- .gitattributes +1 -0
- 1_Pooling/config.json +7 -0
- README.md +148 -0
- binary_classification_evaluation_results.csv +2 -0
- config.json +24 -0
- config_sentence_transformers.json +7 -0
- eval/binary_classification_evaluation_results.csv +3 -0
- modules.json +20 -0
- pytorch_model.bin +3 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +15 -0
- tokenizer.json +0 -0
- tokenizer_config.json +16 -0
- vocab.txt +0 -0
.gitattributes
CHANGED
@@ -30,3 +30,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
30 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
31 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
32 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
30 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
31 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
32 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
33 |
+
pytorch_model.bin filter=lfs diff=lfs merge=lfs -text
|
1_Pooling/config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 768,
|
3 |
+
"pooling_mode_cls_token": false,
|
4 |
+
"pooling_mode_mean_tokens": true,
|
5 |
+
"pooling_mode_max_tokens": false,
|
6 |
+
"pooling_mode_mean_sqrt_len_tokens": false
|
7 |
+
}
|
README.md
CHANGED
@@ -1,3 +1,151 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: cc-by-nc-sa-4.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
pipeline_tag: sentence-similarity
|
3 |
+
tags:
|
4 |
+
- sentence-transformers
|
5 |
+
- feature-extraction
|
6 |
+
- sentence-similarity
|
7 |
+
language: en
|
8 |
+
datasets:
|
9 |
+
- quora
|
10 |
+
- embedding-data/WikiAnswers
|
11 |
+
- flax-sentence-embeddings/stackexchange_xml
|
12 |
license: cc-by-nc-sa-4.0
|
13 |
---
|
14 |
+
|
15 |
+
# All-mpnet-base-v2 model fine-tuned for questions clustering
|
16 |
+
|
17 |
+
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.
|
18 |
+
|
19 |
+
This model is named **all-mpnet-base-questions-clustering-en** since it is a Sentence Transformers model specifically fine-tuned for a questions clustering task. Three public dataset (Quora, WikiAnswer and StackExchange) has been used to enhance the model performance specifically in mapping questions with similar meanings.
|
20 |
+
|
21 |
+
## Usage (Sentence-Transformers)
|
22 |
+
|
23 |
+
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
|
24 |
+
|
25 |
+
```
|
26 |
+
pip install -U sentence-transformers
|
27 |
+
```
|
28 |
+
|
29 |
+
Then you can use the model like this:
|
30 |
+
|
31 |
+
```python
|
32 |
+
from sentence_transformers import SentenceTransformer
|
33 |
+
sentences = ["This is an example sentence", "Each sentence is converted"]
|
34 |
+
|
35 |
+
model = SentenceTransformer('aiknowyou/all-mpnet-base-questions-clustering-en')
|
36 |
+
embeddings = model.encode(sentences)
|
37 |
+
print(embeddings)
|
38 |
+
```
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
## Evaluation Results
|
43 |
+
|
44 |
+
The present model has been evaluated by employing a test set belonging to the WikiAnswer dataset. The evaluation results are the following:
|
45 |
+
|
46 |
+
[
|
47 |
+
{
|
48 |
+
"epoch": 1,
|
49 |
+
"cossim_accuracy": 0.9931843415744172,
|
50 |
+
"cossim_accuracy_threshold": 0.35143423080444336,
|
51 |
+
"cossim_f1": 0.9897547191636324,
|
52 |
+
"cossim_precision": 0.9913437348280885,
|
53 |
+
"cossim_recall": 0.9881707893839572,
|
54 |
+
"cossim_f1_threshold": 0.35143423080444336,
|
55 |
+
"cossim_ap": 0.9989950013637923,
|
56 |
+
"manhattan_accuracy": 0.9934042015236294,
|
57 |
+
"manhattan_accuracy_threshold": 24.160316467285156,
|
58 |
+
"manhattan_f1": 0.9900818249442103,
|
59 |
+
"manhattan_precision": 0.9920113508380628,
|
60 |
+
"manhattan_recall": 0.9881597905828264,
|
61 |
+
"manhattan_f1_threshold": 24.160316467285156,
|
62 |
+
"manhattan_ap": 0.9990576126715013,
|
63 |
+
"euclidean_accuracy": 0.9931843415744172,
|
64 |
+
"euclidean_accuracy_threshold": 1.1389167308807373,
|
65 |
+
"euclidean_f1": 0.9897547191636324,
|
66 |
+
"euclidean_precision": 0.9913437348280885,
|
67 |
+
"euclidean_recall": 0.9881707893839572,
|
68 |
+
"euclidean_f1_threshold": 1.1389167308807373,
|
69 |
+
"euclidean_ap": 0.9989921332302106,
|
70 |
+
"dot_accuracy": 0.9931843415744172,
|
71 |
+
"dot_accuracy_threshold": 0.35143429040908813,
|
72 |
+
"dot_f1": 0.9897547191636324,
|
73 |
+
"dot_precision": 0.9913437348280885,
|
74 |
+
"dot_recall": 0.9881707893839572,
|
75 |
+
"dot_f1_threshold": 0.35143429040908813,
|
76 |
+
"dot_ap": 0.9989933009226604
|
77 |
+
}
|
78 |
+
]
|
79 |
+
|
80 |
+
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})
|
81 |
+
|
82 |
+
|
83 |
+
## Training
|
84 |
+
The model was trained with the parameters:
|
85 |
+
|
86 |
+
**DataLoader**:
|
87 |
+
|
88 |
+
`torch.utils.data.dataloader.DataLoader` of length 34123 with parameters:
|
89 |
+
```
|
90 |
+
{'batch_size': 32, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
|
91 |
+
```
|
92 |
+
|
93 |
+
**Loss**:
|
94 |
+
|
95 |
+
`sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss` with parameters:
|
96 |
+
```
|
97 |
+
{'scale': 20.0, 'similarity_fct': 'cos_sim'}
|
98 |
+
```
|
99 |
+
|
100 |
+
**DataLoader**:
|
101 |
+
|
102 |
+
`torch.utils.data.dataloader.DataLoader` of length 51184 with parameters:
|
103 |
+
```
|
104 |
+
{'batch_size': 32, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
|
105 |
+
```
|
106 |
+
|
107 |
+
**Loss**:
|
108 |
+
|
109 |
+
`sentence_transformers.losses.OnlineContrastiveLoss.OnlineContrastiveLoss`
|
110 |
+
|
111 |
+
Parameters of the fit()-Method:
|
112 |
+
```
|
113 |
+
{
|
114 |
+
"epochs": 2,
|
115 |
+
"evaluation_steps": 0,
|
116 |
+
"evaluator": "sentence_transformers.evaluation.SequentialEvaluator.SequentialEvaluator",
|
117 |
+
"max_grad_norm": 1,
|
118 |
+
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
|
119 |
+
"optimizer_params": {
|
120 |
+
"lr": 2e-05
|
121 |
+
},
|
122 |
+
"scheduler": "WarmupLinear",
|
123 |
+
"steps_per_epoch": null,
|
124 |
+
"warmup_steps": 1000,
|
125 |
+
"weight_decay": 0.01
|
126 |
+
}
|
127 |
+
```
|
128 |
+
|
129 |
+
|
130 |
+
## Full Model Architecture
|
131 |
+
```
|
132 |
+
SentenceTransformer(
|
133 |
+
(0): Transformer({'max_seq_length': 384, 'do_lower_case': False}) with Transformer model: MPNetModel
|
134 |
+
(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})
|
135 |
+
(2): Normalize()
|
136 |
+
)
|
137 |
+
```
|
138 |
+
|
139 |
+
## Contribution
|
140 |
+
|
141 |
+
Thanks to [@tradicio](https://huggingface.co/tradicio) for adding this model.
|
142 |
+
|
143 |
+
## License
|
144 |
+
|
145 |
+
This work is licensed under a
|
146 |
+
[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].
|
147 |
+
|
148 |
+
[![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa]
|
149 |
+
|
150 |
+
[cc-by-nc-sa]: http://creativecommons.org/licenses/by-nc-sa/4.0/
|
151 |
+
[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png
|
binary_classification_evaluation_results.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
epoch,steps,cossim_accuracy,cossim_accuracy_threshold,cossim_f1,cossim_precision,cossim_recall,cossim_f1_threshold,cossim_ap,manhattan_accuracy,manhattan_accuracy_threshold,manhattan_f1,manhattan_precision,manhattan_recall,manhattan_f1_threshold,manhattan_ap,euclidean_accuracy,euclidean_accuracy_threshold,euclidean_f1,euclidean_precision,euclidean_recall,euclidean_f1_threshold,euclidean_ap,dot_accuracy,dot_accuracy_threshold,dot_f1,dot_precision,dot_recall,dot_f1_threshold,dot_ap
|
2 |
+
0,0,0.9893422889619312,0.3684113025665283,0.9839550952295576,0.9870342598792521,0.9808950824360144,0.3684113025665283,0.9981098929310646,0.9887431706003276,24.35479736328125,0.9830630888912166,0.9855571523325226,0.9805816166037902,24.358116149902344,0.9979432632969408,0.9893422889619312,1.123911738395691,0.9839550952295576,0.9870342598792521,0.9808950824360144,1.123911738395691,0.9981070245867787,0.9893422889619312,0.36841127276420593,0.9839550952295576,0.9870342598792521,0.9808950824360144,0.36841127276420593,0.9981101239841529
|
config.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "/home/utente/.cache/torch/sentence_transformers/sentence-transformers_all-mpnet-base-v2/",
|
3 |
+
"architectures": [
|
4 |
+
"MPNetModel"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"bos_token_id": 0,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 768,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 3072,
|
14 |
+
"layer_norm_eps": 1e-05,
|
15 |
+
"max_position_embeddings": 514,
|
16 |
+
"model_type": "mpnet",
|
17 |
+
"num_attention_heads": 12,
|
18 |
+
"num_hidden_layers": 12,
|
19 |
+
"pad_token_id": 1,
|
20 |
+
"relative_attention_num_buckets": 32,
|
21 |
+
"torch_dtype": "float32",
|
22 |
+
"transformers_version": "4.22.0.dev0",
|
23 |
+
"vocab_size": 30527
|
24 |
+
}
|
config_sentence_transformers.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "2.0.0",
|
4 |
+
"transformers": "4.6.1",
|
5 |
+
"pytorch": "1.8.1"
|
6 |
+
}
|
7 |
+
}
|
eval/binary_classification_evaluation_results.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
epoch,steps,cossim_accuracy,cossim_accuracy_threshold,cossim_f1,cossim_precision,cossim_recall,cossim_f1_threshold,cossim_ap,manhattan_accuracy,manhattan_accuracy_threshold,manhattan_f1,manhattan_precision,manhattan_recall,manhattan_f1_threshold,manhattan_ap,euclidean_accuracy,euclidean_accuracy_threshold,euclidean_f1,euclidean_precision,euclidean_recall,euclidean_f1_threshold,euclidean_ap,dot_accuracy,dot_accuracy_threshold,dot_f1,dot_precision,dot_recall,dot_f1_threshold,dot_ap
|
2 |
+
0,-1,0.9906596164909619,0.3930458724498749,0.9859670564400695,0.9870212179663819,0.9849151442492768,0.3930458724498749,0.9984901891426392,0.991234916691401,23.361751556396484,0.9868355558244485,0.9869576936405692,0.9867134482341425,23.616687774658203,0.9986105475645636,0.9906596164909619,1.1017749309539795,0.9859670564400695,0.9870212179663819,0.9849151442492768,1.1017749309539795,0.9984873210075305,0.9906596164909619,0.39304593205451965,0.9859670564400695,0.9870212179663819,0.9849151442492768,0.39304593205451965,0.9984897548380124
|
3 |
+
1,-1,0.9931843415744172,0.35143423080444336,0.9897547191636324,0.9913437348280885,0.9881707893839572,0.35143423080444336,0.9989950013637923,0.9934042015236294,24.160316467285156,0.9900818249442103,0.9920113508380628,0.9881597905828264,24.160316467285156,0.9990576126715013,0.9931843415744172,1.1389167308807373,0.9897547191636324,0.9913437348280885,0.9881707893839572,1.1389167308807373,0.9989921332302106,0.9931843415744172,0.35143429040908813,0.9897547191636324,0.9913437348280885,0.9881707893839572,0.35143429040908813,0.9989933009226604
|
modules.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"idx": 0,
|
4 |
+
"name": "0",
|
5 |
+
"path": "",
|
6 |
+
"type": "sentence_transformers.models.Transformer"
|
7 |
+
},
|
8 |
+
{
|
9 |
+
"idx": 1,
|
10 |
+
"name": "1",
|
11 |
+
"path": "1_Pooling",
|
12 |
+
"type": "sentence_transformers.models.Pooling"
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"idx": 2,
|
16 |
+
"name": "2",
|
17 |
+
"path": "2_Normalize",
|
18 |
+
"type": "sentence_transformers.models.Normalize"
|
19 |
+
}
|
20 |
+
]
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9b0627657a0954b301f54383025898a0de1dc0c76d37a852cb2195167f66926c
|
3 |
+
size 438014769
|
sentence_bert_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 384,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"mask_token": {
|
6 |
+
"content": "<mask>",
|
7 |
+
"lstrip": true,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false
|
11 |
+
},
|
12 |
+
"pad_token": "<pad>",
|
13 |
+
"sep_token": "</s>",
|
14 |
+
"unk_token": "[UNK]"
|
15 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"do_lower_case": true,
|
5 |
+
"eos_token": "</s>",
|
6 |
+
"mask_token": "<mask>",
|
7 |
+
"model_max_length": 512,
|
8 |
+
"name_or_path": "/home/utente/.cache/torch/sentence_transformers/sentence-transformers_all-mpnet-base-v2/",
|
9 |
+
"pad_token": "<pad>",
|
10 |
+
"sep_token": "</s>",
|
11 |
+
"special_tokens_map_file": null,
|
12 |
+
"strip_accents": null,
|
13 |
+
"tokenize_chinese_chars": true,
|
14 |
+
"tokenizer_class": "MPNetTokenizer",
|
15 |
+
"unk_token": "[UNK]"
|
16 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|