jfarray commited on
Commit
d19997d
1 Parent(s): 9388bcd

Add new SentenceTransformer model.

Browse files
.gitattributes CHANGED
@@ -25,3 +25,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
28
+ unigram.json filter=lfs diff=lfs merge=lfs -text
29
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
30
+ pytorch_model.bin filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
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 ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: sentence-similarity
3
+ tags:
4
+ - sentence-transformers
5
+ - feature-extraction
6
+ - sentence-similarity
7
+ - transformers
8
+ ---
9
+
10
+ # {MODEL_NAME}
11
+
12
+ This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.
13
+
14
+ <!--- Describe your model here -->
15
+
16
+ ## Usage (Sentence-Transformers)
17
+
18
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
19
+
20
+ ```
21
+ pip install -U sentence-transformers
22
+ ```
23
+
24
+ Then you can use the model like this:
25
+
26
+ ```python
27
+ from sentence_transformers import SentenceTransformer
28
+ sentences = ["This is an example sentence", "Each sentence is converted"]
29
+
30
+ model = SentenceTransformer('{MODEL_NAME}')
31
+ embeddings = model.encode(sentences)
32
+ print(embeddings)
33
+ ```
34
+
35
+
36
+
37
+ ## Usage (HuggingFace Transformers)
38
+ 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.
39
+
40
+ ```python
41
+ from transformers import AutoTokenizer, AutoModel
42
+ import torch
43
+
44
+
45
+ #Mean Pooling - Take attention mask into account for correct averaging
46
+ def mean_pooling(model_output, attention_mask):
47
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
48
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
49
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
50
+
51
+
52
+ # Sentences we want sentence embeddings for
53
+ sentences = ['This is an example sentence', 'Each sentence is converted']
54
+
55
+ # Load model from HuggingFace Hub
56
+ tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
57
+ model = AutoModel.from_pretrained('{MODEL_NAME}')
58
+
59
+ # Tokenize sentences
60
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
61
+
62
+ # Compute token embeddings
63
+ with torch.no_grad():
64
+ model_output = model(**encoded_input)
65
+
66
+ # Perform pooling. In this case, mean pooling.
67
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
68
+
69
+ print("Sentence embeddings:")
70
+ print(sentence_embeddings)
71
+ ```
72
+
73
+
74
+
75
+ ## Evaluation Results
76
+
77
+ <!--- Describe how your model was evaluated -->
78
+
79
+ For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})
80
+
81
+
82
+ ## Training
83
+ The model was trained with the parameters:
84
+
85
+ **DataLoader**:
86
+
87
+ `torch.utils.data.dataloader.DataLoader` of length 11 with parameters:
88
+ ```
89
+ {'batch_size': 15, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
90
+ ```
91
+
92
+ **Loss**:
93
+
94
+ `sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
95
+
96
+ Parameters of the fit()-Method:
97
+ ```
98
+ {
99
+ "epochs": 5,
100
+ "evaluation_steps": 1,
101
+ "evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
102
+ "max_grad_norm": 1,
103
+ "optimizer_class": "<class 'transformers.optimization.AdamW'>",
104
+ "optimizer_params": {
105
+ "lr": 2e-05
106
+ },
107
+ "scheduler": "WarmupLinear",
108
+ "steps_per_epoch": null,
109
+ "warmup_steps": 6,
110
+ "weight_decay": 0.01
111
+ }
112
+ ```
113
+
114
+
115
+ ## Full Model Architecture
116
+ ```
117
+ SentenceTransformer(
118
+ (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
119
+ (1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
120
+ )
121
+ ```
122
+
123
+ ## Citing & Authors
124
+
125
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-multilingual-MiniLM-L12-v2/",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 384,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 1536,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.16.2",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 250037
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.7.0",
5
+ "pytorch": "1.9.0+cu102"
6
+ }
7
+ }
eval/similarity_evaluation_results.csv ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ epoch,steps,cosine_pearson,cosine_spearman,euclidean_pearson,euclidean_spearman,manhattan_pearson,manhattan_spearman,dot_pearson,dot_spearman
2
+ 0,1,0.4106261751588814,0.41069823848644194,0.39567371234645116,0.4539296320113305,0.37736095233478156,0.4081552153379191,-0.05937455447312464,-0.24667324540671745
3
+ 0,2,0.41703347562800147,0.4310424236746248,0.39495681024825563,0.4208703310805334,0.3762328507432742,0.4081552153379191,-0.06870090518429162,-0.24667324540671745
4
+ 0,3,0.43387628146379564,0.43867149312019343,0.3949820838999695,0.4157842847834876,0.37694433412458683,0.44248602784297775,-0.08389158302407942,-0.18818371299069164
5
+ 0,4,0.43888751276830884,0.464101724605422,0.3887693374722494,0.3827249838526905,0.37054486403862874,0.3789104491299062,-0.11465797345590431,-0.24794475698097887
6
+ 0,5,0.4199516289483206,0.46283021303116056,0.3718819775042325,0.3216924282881418,0.3541219756219773,0.31787789356535756,-0.14057270119398318,-0.31279184726831183
7
+ 0,6,0.3636268475717739,0.3077058009712661,0.34532352176771713,0.3038912662484818,0.33009164119396317,0.3077058009712661,-0.1652263206336318,-0.3598377755159847
8
+ 0,7,0.27058883954378427,0.20979940975313596,0.3103824614293719,0.20852789817887454,0.2975129443163477,0.19708429401052166,-0.1828569049848596,-0.3598377755159847
9
+ 0,8,0.17460599159763063,0.16021045835694017,0.2685757982240059,0.1983558055847831,0.25744516029998266,0.2021703403075674,-0.1915139522620683,-0.3700098681100762
10
+ 0,9,0.10970843059534678,0.11952208798057443,0.23127618295899868,0.17038255095103164,0.22184607060968276,0.1856406898421688,-0.19929718098431048,-0.41196975006070335
11
+ 0,10,0.06884684690475125,0.10934999538648299,0.20040156742091517,0.11570755325779014,0.1912876656806486,0.1309656921489273,-0.20212439030800322,-0.39544009959530474
12
+ 0,11,0.044849195434396555,-0.043231393524888626,0.17480423437686426,0.10553546066369869,0.16406036472244478,0.14622383104006448,-0.20547530014127693,-0.39544009959530474
13
+ 0,-1,0.044849195434396555,-0.043231393524888626,0.17480423437686426,0.10553546066369869,0.16406036472244478,0.14622383104006448,-0.20547530014127693,-0.39544009959530474
14
+ 1,1,0.029028796048977516,-0.10299243751517584,0.1570090393795128,0.0928203449210844,0.1450816296615038,0.10426394908943727,-0.2051709607706394,-0.3344075440307561
15
+ 1,2,0.02522248337174138,-0.10172092594091442,0.15824742456568783,0.08773429862403868,0.1462905290999444,0.11062150696074444,-0.19799103462794115,-0.32042091671388034
16
+ 1,3,0.017323894964116293,-0.09790639121813012,0.15130458176520872,0.10680697223796014,0.13883722516764563,0.08010522917847009,-0.1940989069538219,-0.28990463893160606
17
+ 1,4,0.003297061631681285,-0.12587964585188158,0.1313143042287291,0.054674997693241495,0.1165413177039431,0.04450290509915005,-0.19626476790808867,-0.3115203356940504
18
+ 1,5,0.00726098197234125,-0.1691110393767702,0.14313992188027375,0.026701743059490034,0.12869884400675458,0.01907267361392145,-0.18788543710798475,-0.23777266438688743
19
+ 1,6,0.005664336541190259,-0.18818371299069164,0.14301861112598646,0.026701743059490034,0.1274927498404123,0.01907267361392145,-0.18614394327566008,-0.20852789817887454
20
+ 1,7,-0.010660180532377495,-0.2530308032780246,0.11533163030981536,-0.021615696762444313,0.09784505807015652,0.01907267361392145,-0.19564072131600976,-0.2492162685552403
21
+ 1,8,-0.01715041047089929,-0.2822755694860375,0.09701273196824367,-0.01398662731687573,0.07545848808051656,-0.02924476620801289,-0.20485300893866354,-0.26447440744637746
22
+ 1,9,-0.02038561512442355,-0.24158719910967172,0.07967078254411952,-0.021615696762444313,0.049409196526083984,-0.02924476620801289,-0.21363332115422054,-0.28609010420882175
23
+ 1,10,-0.008418116334679829,-0.16275348150546307,0.08363694769312821,-0.005086046297045721,0.041821647184158456,-0.0673901134358558,-0.21830085187329173,-0.3077058009712661
24
+ 1,11,0.015586916032080874,-0.16656801622824735,0.09798356020185679,0.021615696762444313,0.040982966744801515,-0.03051627778227432,-0.2219992374306971,-0.33059300930797186
25
+ 1,-1,0.015586916032080874,-0.16656801622824735,0.09798356020185679,0.021615696762444313,0.040982966744801515,-0.03051627778227432,-0.2219992374306971,-0.33059300930797186
26
+ 2,1,0.047801516019719714,0.00762906944556858,0.11980525772875769,0.06484709028733295,0.054392079338261866,-0.0025430231485228604,-0.22284381969988437,-0.33059300930797186
27
+ 2,2,0.07956714760005196,0.012715115742614302,0.13888356320107245,0.12333662270335873,0.06957069998087369,-0.0025430231485228604,-0.22176210730918058,-0.33059300930797186
28
+ 2,3,0.1057183312921956,0.1474953426143259,0.15260537096939022,0.17546859724807737,0.0827703181283367,0.04704592824767291,-0.21855764869145566,-0.30261975467422036
29
+ 2,4,0.12934688896830013,0.2352296412383646,0.1657997690056382,0.19962731715904453,0.09756826904484978,0.06993313658437866,-0.21132281263687777,-0.34839417134763184
30
+ 2,5,0.14782488778792863,0.2822755694860375,0.17727911754805137,0.18436917826790739,0.11069177402183757,0.08519127547551582,-0.2014845070966012,-0.3560232407932004
31
+ 2,6,0.15637574668593676,0.2568453380008089,0.1829389204809058,0.21361394447592028,0.11754178862428834,0.09536336806960725,-0.19538267690560565,-0.38653951857547475
32
+ 2,7,0.157137225006789,0.2568453380008089,0.18359359844830836,0.15512441205989447,0.11841104894438723,0.08519127547551582,-0.19500228522297441,-0.38653951857547475
33
+ 2,8,0.15265641320433912,0.1907267361392145,0.1809694568252187,0.13350871529745015,0.11561229136264951,0.08519127547551582,-0.19616413846992908,-0.38653951857547475
34
+ 2,9,0.1559446697666977,0.1691110393767702,0.18254506061649572,0.13350871529745015,0.11686882559570261,0.06611860186159436,-0.19269131224899028,-0.38653951857547475
35
+ 2,10,0.1598883770901154,0.16148196993120162,0.1845205349414064,0.13350871529745015,0.11872648508716209,0.04450290509915005,-0.19025755081059587,-0.3763674259813833
36
+ 2,11,0.16335588368015394,0.18182615511938452,0.185548428788402,0.12333662270335873,0.11869123710973699,0.04450290509915005,-0.1891281323598976,-0.4043406806151348
37
+ 2,-1,0.16335588368015394,0.18182615511938452,0.185548428788402,0.12333662270335873,0.11869123710973699,0.04450290509915005,-0.1891281323598976,-0.4043406806151348
38
+ 3,1,0.16084878565735056,0.15639592363415591,0.18291369778515698,0.12333662270335873,0.1153313199190561,0.0025430231485228604,-0.1897234269863271,-0.37763893755564476
39
+ 3,2,0.15987176101415468,0.12079359955483586,0.18160800507886074,0.13986627316875733,0.11372207329898108,0.0025430231485228604,-0.18903305293982103,-0.3700098681100762
40
+ 3,3,0.1591909281264029,0.12079359955483586,0.18068883949077896,0.13986627316875733,0.11262448158692233,-0.04450290509915005,-0.188623826709613,-0.3700098681100762
41
+ 3,4,0.15694779200303524,0.10044941436665299,0.17944668209481687,0.08519127547551582,0.11295697539978297,-0.0419598819506272,-0.1894529219316317,-0.3700098681100762
42
+ 3,5,0.15511632246525442,0.10299243751517584,0.17894555764704256,0.0928203449210844,0.11444465471685551,-0.0419598819506272,-0.18932334844160703,-0.33695056717927896
43
+ 3,6,0.15542689574399937,0.10299243751517584,0.17938798800482234,0.06866162501011723,0.11570420028785418,-0.0419598819506272,-0.1872997840516068,-0.33695056717927896
44
+ 3,7,0.15546340531113298,0.10044941436665299,0.18055153549236613,0.06866162501011723,0.11818501847813453,0.03560232407932004,-0.1857944636835592,-0.33695056717927896
45
+ 3,8,0.16214808746316528,0.12587964585188158,0.18609684289616127,0.04958895139619578,0.12601642554151612,0.04958895139619578,-0.18399996951169115,-0.3115203356940504
46
+ 3,9,0.17254063491690202,0.10044941436665299,0.1944187664636575,0.07120464815864008,0.13785884705189178,0.03941685880210433,-0.18150021551845624,-0.32550696301092613
47
+ 3,10,0.17638997854462649,0.11825057640631301,0.19872060123012816,0.13350871529745015,0.14506844102241745,0.03941685880210433,-0.18011112216071898,-0.32550696301092613
48
+ 3,11,0.18449115393072982,0.11825057640631301,0.20709479718510213,0.1296941805746659,0.15575158593730679,0.05086046297045721,-0.17795467761013317,-0.31024882411978894
49
+ 3,-1,0.18449115393072982,0.11825057640631301,0.20709479718510213,0.1296941805746659,0.15575158593730679,0.05086046297045721,-0.17795467761013317,-0.31024882411978894
50
+ 4,1,0.19014118310036487,0.11825057640631301,0.2134476561852836,0.1296941805746659,0.1634979170414422,0.09663487964386869,-0.17629394695817932,-0.31024882411978894
51
+ 4,2,0.19321773662151137,0.11825057640631301,0.2178857749959978,0.1296941805746659,0.1687328738866751,0.08264825232699297,-0.17491056873445324,-0.31024882411978894
52
+ 4,3,0.19636698312816747,0.11825057640631301,0.22060934997798368,0.1296941805746659,0.17140318738455818,0.04704592824767291,-0.17374133367999142,-0.30261975467422036
53
+ 4,4,0.19748606882909112,0.10044941436665299,0.22151561837191408,0.10426394908943727,0.1718291033396474,0.06103255556454864,-0.17308408081355006,-0.30261975467422036
54
+ 4,5,0.19940729493487955,0.04958895139619578,0.22251960921676367,0.10426394908943727,0.17228917664172388,0.06103255556454864,-0.17233135741857689,-0.30261975467422036
55
+ 4,6,0.20165697846038638,0.031787789356535756,0.22386873711347385,0.10426394908943727,0.1731868970810523,0.06103255556454864,-0.171558745760406,-0.30261975467422036
56
+ 4,7,0.20405371256404706,0.012715115742614302,0.2253802677892442,0.10426394908943727,0.17445471467868595,0.06103255556454864,-0.17083077224245694,-0.30261975467422036
57
+ 4,8,0.20528716666399116,0.012715115742614302,0.2263630661975477,0.08264825232699297,0.17542231230551567,0.06103255556454864,-0.17037942684347893,-0.30261975467422036
58
+ 4,9,0.20612393783010774,0.012715115742614302,0.22752355864670962,0.07756220602994723,0.17686262312518253,0.06103255556454864,-0.1699562582446593,-0.30261975467422036
59
+ 4,10,0.20709131114742294,0.012715115742614302,0.22886365829774544,0.07756220602994723,0.17861490130210808,0.06103255556454864,-0.16953728319760075,-0.30261975467422036
60
+ 4,11,0.20708357118430498,0.012715115742614302,0.2293017214864497,0.07756220602994723,0.17930350756603547,0.06103255556454864,-0.16939245137472528,-0.30261975467422036
61
+ 4,-1,0.20708357118430498,0.012715115742614302,0.2293017214864497,0.07756220602994723,0.17930350756603547,0.06103255556454864,-0.16939245137472528,-0.30261975467422036
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ]
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10799b50d3bb3b960eb291e7c6b0e3a8bb74bf87deec42733c712ff636c90d8b
3
+ size 470696369
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 128,
3
+ "do_lower_case": false
4
+ }
similarity_evaluation_sts-test_results.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ epoch,steps,cosine_pearson,cosine_spearman,euclidean_pearson,euclidean_spearman,manhattan_pearson,manhattan_spearman,dot_pearson,dot_spearman
2
+ -1,-1,0.6610049361985745,0.14846384769101478,0.5905155340577791,0.1257945101768986,0.5102097495363672,0.1212281418317612,0.6183753965624046,0.3497740649848295
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": false}}
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a3313815c3d2e1b78b5182b09e66e6cd4cdd54df67a35c4a318c23d461821a4
3
+ size 17082913
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": true, "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "tokenize_chinese_chars": true, "strip_accents": null, "bos_token": "<s>", "eos_token": "</s>", "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-multilingual-MiniLM-L12-v2/", "tokenizer_class": "BertTokenizer"}
unigram.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71b44701d7efd054205115acfa6ef126c5d2f84bd3affe0c59e48163674d19a6
3
+ size 14763234