theshark4 commited on
Commit
23b3b96
·
verified ·
1 Parent(s): 355f34a

Upload 13 files

Browse files
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 ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: sentence-similarity
3
+ tags:
4
+ - sentence-transformers
5
+ - feature-extraction
6
+ - sentence-similarity
7
+ - transformers
8
+
9
+ ---
10
+
11
+ # {MODEL_NAME}
12
+
13
+ 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.
14
+
15
+ <!--- Describe your model here -->
16
+
17
+ ## Usage (Sentence-Transformers)
18
+
19
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
20
+
21
+ ```
22
+ pip install -U sentence-transformers
23
+ ```
24
+
25
+ Then you can use the model like this:
26
+
27
+ ```python
28
+ from sentence_transformers import SentenceTransformer
29
+ sentences = ["This is an example sentence", "Each sentence is converted"]
30
+
31
+ model = SentenceTransformer('{MODEL_NAME}')
32
+ embeddings = model.encode(sentences)
33
+ print(embeddings)
34
+ ```
35
+
36
+
37
+
38
+ ## Usage (HuggingFace Transformers)
39
+ 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.
40
+
41
+ ```python
42
+ from transformers import AutoTokenizer, AutoModel
43
+ import torch
44
+
45
+
46
+ #Mean Pooling - Take attention mask into account for correct averaging
47
+ def mean_pooling(model_output, attention_mask):
48
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
49
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
50
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
51
+
52
+
53
+ # Sentences we want sentence embeddings for
54
+ sentences = ['This is an example sentence', 'Each sentence is converted']
55
+
56
+ # Load model from HuggingFace Hub
57
+ tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
58
+ model = AutoModel.from_pretrained('{MODEL_NAME}')
59
+
60
+ # Tokenize sentences
61
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
62
+
63
+ # Compute token embeddings
64
+ with torch.no_grad():
65
+ model_output = model(**encoded_input)
66
+
67
+ # Perform pooling. In this case, mean pooling.
68
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
69
+
70
+ print("Sentence embeddings:")
71
+ print(sentence_embeddings)
72
+ ```
73
+
74
+
75
+
76
+ ## Evaluation Results
77
+
78
+ <!--- Describe how your model was evaluated -->
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 3615 with parameters:
89
+ ```
90
+ {'batch_size': 16, '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
+ Parameters of the fit()-Method:
101
+ ```
102
+ {
103
+ "epochs": 5,
104
+ "evaluation_steps": 5000,
105
+ "evaluator": "sentence_transformers.evaluation.InformationRetrievalEvaluator.InformationRetrievalEvaluator",
106
+ "max_grad_norm": 1,
107
+ "optimizer_class": "<class 'transformers.optimization.AdamW'>",
108
+ "optimizer_params": {
109
+ "correct_bias": false,
110
+ "eps": 1e-06,
111
+ "lr": 2e-05
112
+ },
113
+ "scheduler": "WarmupLinear",
114
+ "steps_per_epoch": null,
115
+ "warmup_steps": 1807,
116
+ "weight_decay": 0.01
117
+ }
118
+ ```
119
+
120
+
121
+ ## Full Model Architecture
122
+ ```
123
+ SentenceTransformer(
124
+ (0): Transformer({'max_seq_length': 350, 'do_lower_case': False}) with Transformer model: BertModel
125
+ (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})
126
+ )
127
+ ```
128
+
129
+ ## Citing & Authors
130
+
131
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/new_disk2/changle_qu/beir-main/PLMs/contriever-base-msmarco",
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": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
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.28.1",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.28.1",
5
+ "pytorch": "1.13.1+cu117"
6
+ }
7
+ }
eval/Information-Retrieval_evaluation_eval_results.csv ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ epoch,steps,cos_sim-Accuracy@1,cos_sim-Accuracy@3,cos_sim-Accuracy@5,cos_sim-Accuracy@10,cos_sim-Precision@1,cos_sim-Recall@1,cos_sim-Precision@3,cos_sim-Recall@3,cos_sim-Precision@5,cos_sim-Recall@5,cos_sim-Precision@10,cos_sim-Recall@10,cos_sim-MRR@10,cos_sim-NDCG@10,cos_sim-MAP@100,dot_score-Accuracy@1,dot_score-Accuracy@3,dot_score-Accuracy@5,dot_score-Accuracy@10,dot_score-Precision@1,dot_score-Recall@1,dot_score-Precision@3,dot_score-Recall@3,dot_score-Precision@5,dot_score-Recall@5,dot_score-Precision@10,dot_score-Recall@10,dot_score-MRR@10,dot_score-NDCG@10,dot_score-MAP@100
2
+ 0,5000,0.6105454545454545,0.7869090909090909,0.8381818181818181,0.8872727272727273,0.6105454545454545,0.2596161616161616,0.38242424242424244,0.4773131313131313,0.27592727272727274,0.5688484848484848,0.16556363636363639,0.6776363636363636,0.7085754689754655,0.5967748307092097,0.5122648747321592,0.5829090909090909,0.7637575757575757,0.8173333333333334,0.8726060606060606,0.5829090909090909,0.24740404040404038,0.3591515151515151,0.4471919191919191,0.25920000000000004,0.5344343434343434,0.15681212121212124,0.6413434343434344,0.6836522366522336,0.5646022984983109,0.4811462006301545
3
+ 0,10000,0.6374545454545455,0.8058181818181818,0.8515151515151516,0.8995151515151515,0.6374545454545455,0.27099999999999996,0.4027474747474747,0.5024747474747474,0.2912,0.5991717171717171,0.17505454545454546,0.7130909090909092,0.7301447811447775,0.6278654618839715,0.5441548396802555,0.5924848484848485,0.7792727272727272,0.8330909090909091,0.8875151515151515,0.5924848484848485,0.25106060606060604,0.37422222222222223,0.4658181818181818,0.27248484848484855,0.5602121212121212,0.1656727272727273,0.675010101010101,0.696122462722461,0.5881525992264697,0.5030615882030314
4
+ 0,-1,0.6423030303030303,0.8078787878787879,0.8562424242424242,0.9053333333333333,0.6423030303030303,0.2731717171717172,0.4097373737373737,0.5103131313131314,0.29723636363636374,0.6101313131313131,0.177769696969697,0.723,0.7349672919672893,0.6362850472092083,0.5527210541783336,0.6072727272727273,0.788969696969697,0.8421818181818181,0.8940606060606061,0.6072727272727273,0.25806060606060605,0.38533333333333336,0.4799595959595959,0.28058181818181815,0.5764444444444444,0.17012121212121212,0.6928888888888889,0.708291582491579,0.604482357867727,0.5196932736543793
5
+ 1,5000,0.6538181818181819,0.8241212121212121,0.8705454545454545,0.9112727272727272,0.6538181818181819,0.2772323232323233,0.4193535353535353,0.5213333333333333,0.3066666666666667,0.6292121212121211,0.1831757575757576,0.7435959595959595,0.7468392015391991,0.6526016165300956,0.5677766950877088,0.6064242424242424,0.7896969696969697,0.8475151515151516,0.8995151515151515,0.6064242424242424,0.25677777777777777,0.38715151515151514,0.4802424242424242,0.28463030303030307,0.5835252525252524,0.17410909090909094,0.7071515151515153,0.7096602693602667,0.6111915073225092,0.5238372174095693
6
+ 1,10000,0.66,0.8383030303030303,0.8841212121212121,0.9223030303030303,0.66,0.27935353535353535,0.43519191919191913,0.5400909090909092,0.31638787878787883,0.6473636363636365,0.18801212121212127,0.7625454545454546,0.7563655603655575,0.6681199799211335,0.5832476617532044,0.6170909090909091,0.8088484848484848,0.8671515151515151,0.9098181818181819,0.6170909090909091,0.2607575757575757,0.40379797979797977,0.5008080808080808,0.2978181818181818,0.6095656565656565,0.17928484848484852,0.7275959595959597,0.7221697931697897,0.6295189212974119,0.5428619707004281
7
+ 1,-1,0.6705454545454546,0.8378181818181818,0.884,0.9212121212121213,0.6705454545454546,0.2844242424242424,0.44109090909090914,0.5478383838383838,0.320969696969697,0.6565353535353535,0.18995151515151518,0.7697171717171717,0.7616406445406396,0.6765679579217162,0.5934144444320416,0.6213333333333333,0.8096969696969697,0.8623030303030303,0.9087272727272727,0.6213333333333333,0.2624343434343434,0.40872727272727266,0.5066666666666666,0.29905454545454546,0.6117474747474747,0.18071515151515155,0.7327777777777779,0.7248578162578134,0.6348498384972413,0.5491594218232675
8
+ 2,5000,0.6855757575757576,0.8473939393939394,0.8923636363636364,0.9281212121212121,0.6855757575757576,0.2913030303030303,0.45228282828282823,0.5614545454545453,0.32850909090909086,0.6719090909090909,0.1936606060606061,0.7843030303030302,0.7739389129389088,0.691228229551754,0.6083824491777859,0.6266666666666667,0.8146666666666667,0.8692121212121212,0.9134545454545454,0.6266666666666667,0.2655252525252525,0.4137373737373736,0.5142121212121211,0.30470303030303036,0.6236969696969697,0.1835636363636364,0.7446666666666667,0.7301293891293856,0.644151080698012,0.5583789890087074
9
+ 2,10000,0.6894545454545454,0.8576969696969697,0.9006060606060606,0.9328484848484848,0.6894545454545454,0.2923131313131313,0.45967676767676763,0.570989898989899,0.33408484848484854,0.6821818181818182,0.19688484848484847,0.796,0.7798493987493941,0.7006693456394752,0.6177325712133496,0.6397575757575757,0.826060606060606,0.8801212121212121,0.924,0.6397575757575757,0.2713434343434344,0.4247272727272727,0.527050505050505,0.3132363636363637,0.6398888888888888,0.1885818181818182,0.7635656565656566,0.743298508898505,0.6606382579325417,0.5738167729448306
10
+ 2,-1,0.6903030303030303,0.8543030303030303,0.8981818181818182,0.9326060606060607,0.6903030303030303,0.2929090909090909,0.45931313131313134,0.5703131313131314,0.33360000000000006,0.681090909090909,0.1972727272727273,0.7972828282828284,0.7797257335257309,0.7008349479962921,0.6173545584567035,0.6306666666666667,0.8271515151515152,0.8832727272727273,0.9241212121212121,0.6306666666666667,0.266989898989899,0.4237575757575758,0.5261313131313131,0.3132121212121213,0.6394040404040404,0.18775757575757582,0.7594444444444445,0.7387642135642091,0.6564422239133095,0.5701427869326198
11
+ 3,5000,0.7007272727272728,0.8618181818181818,0.9050909090909091,0.9374545454545454,0.7007272727272728,0.29710101010101014,0.4705050505050504,0.5843434343434343,0.3431757575757577,0.7007474747474747,0.2008,0.8109494949494949,0.7887607022606987,0.7146603959349379,0.6323425406586913,0.6515151515151515,0.8383030303030303,0.8905454545454545,0.9305454545454546,0.6515151515151515,0.27604040404040403,0.4363232323232323,0.5416363636363637,0.3224484848484849,0.6594242424242425,0.19219393939393942,0.7777878787878788,0.7538737373737332,0.6745704501357943,0.5888229171296353
12
+ 3,10000,0.7105454545454546,0.8675151515151515,0.9070303030303031,0.9383030303030303,0.7105454545454546,0.30111111111111116,0.4757575757575757,0.5900707070707072,0.3459636363636365,0.7048888888888889,0.2021333333333334,0.8156666666666667,0.7953825877825839,0.7206482966515769,0.6386633798402518,0.650060606060606,0.8449696969696969,0.8956363636363637,0.9321212121212121,0.650060606060606,0.27498989898989895,0.4422222222222222,0.5492323232323232,0.32591515151515155,0.6654848484848485,0.19442424242424244,0.7859090909090909,0.7556703222703179,0.6806056455472214,0.594458655839509
13
+ 3,-1,0.7069090909090909,0.8694545454545455,0.9082424242424243,0.9392727272727273,0.7069090909090909,0.29993939393939395,0.4799191919191919,0.5945353535353536,0.34715151515151527,0.706959595959596,0.20326060606060606,0.8197878787878788,0.7941203463203432,0.7232232074964473,0.6416737116158094,0.6555151515151515,0.8460606060606061,0.8938181818181818,0.929939393939394,0.6555151515151515,0.2775353535353535,0.4423030303030303,0.5489898989898989,0.32635151515151517,0.6661212121212121,0.1943878787878788,0.7858888888888889,0.7574186628186587,0.6812382107560458,0.5950831348724044
14
+ 4,5000,0.7144242424242424,0.8739393939393939,0.9116363636363637,0.9413333333333334,0.7144242424242424,0.3024343434343434,0.4867070707070707,0.6035050505050504,0.3509333333333334,0.7146060606060606,0.20471515151515154,0.8254747474747475,0.7997220298220269,0.7298729767548976,0.6491108606319274,0.6630303030303031,0.8488484848484849,0.8974545454545455,0.9323636363636364,0.6630303030303031,0.28015151515151515,0.44743434343434346,0.5545252525252525,0.3308121212121212,0.6746464646464647,0.19638787878787883,0.7932525252525252,0.7634417027416983,0.6883044674659277,0.6021682687233837
15
+ 4,10000,0.7180606060606061,0.8752727272727273,0.9145454545454546,0.9435151515151515,0.7180606060606061,0.3039090909090909,0.48973737373737375,0.6060404040404042,0.3541575757575758,0.7204040404040404,0.20614545454545455,0.8306666666666667,0.8029773929773892,0.7346521600002316,0.6539404090854473,0.6643636363636364,0.8523636363636363,0.8989090909090909,0.9358787878787879,0.6643636363636364,0.2804242424242424,0.4516767676767676,0.5598282828282828,0.3332848484848486,0.6795959595959596,0.19761212121212124,0.7979090909090908,0.7656853294853257,0.6923505451081151,0.6065122402378942
16
+ 4,-1,0.7181818181818181,0.8755151515151515,0.9153939393939394,0.9433939393939393,0.7181818181818181,0.3037373737373737,0.49042424242424243,0.6070404040404042,0.35398787878787885,0.720050505050505,0.2060848484848485,0.8305858585858586,0.8032096681096644,0.7345811528313727,0.6538586434310485,0.664969696969697,0.852,0.8989090909090909,0.9370909090909091,0.664969696969697,0.28074747474747475,0.4522020202020202,0.5601616161616161,0.33299393939393945,0.6793333333333333,0.19789090909090915,0.799060606060606,0.7659186628186594,0.6928462859078343,0.6065561942968388
17
+ 0,-1,0.7479983143699958,0.8997050147492626,0.9351032448377581,0.9599662873999157,0.7479983143699958,0.2953364236550077,0.5028796179238657,0.5809453574940301,0.37168141592920356,0.7053659221800815,0.22073324905183314,0.8282062087371822,0.8270627228275762,0.7389749813295776,0.6544242991261333,0.6868942267172355,0.866835229667088,0.9152970922882427,0.9515381373788453,0.6868942267172355,0.2713513133867116,0.46270543615676357,0.5350821744627055,0.34378423935946056,0.6553588987217305,0.21188369152970926,0.7972327574097485,0.7849978929624937,0.695318460772596,0.604725344628288
18
+ 1,-1,0.7728613569321534,0.910661609776654,0.9452170248630426,0.9705014749262537,0.7728613569321534,0.30436156763590394,0.5592077538980194,0.644402303694339,0.40303413400758537,0.7602542491923022,0.23168984407922458,0.864693074870066,0.8466292416671677,0.782165170237618,0.7089756380896797,0.7345132743362832,0.9034976822587442,0.9351032448377581,0.9705014749262537,0.7345132743362832,0.2901039471835932,0.5205787329681135,0.6007866273352999,0.3835651074589128,0.7258041859811772,0.22722292456805734,0.8491712319145948,0.8228071759677308,0.7524756051518464,0.669348621234496
19
+ 2,-1,0.7964601769911505,0.9207753898019385,0.9528023598820059,0.9709228824273072,0.7964601769911505,0.3133515943250456,0.574518893102964,0.6610127826941987,0.4161820480404551,0.7843447113358618,0.23788453434471132,0.8856580980474785,0.8616642920688428,0.8034003547332254,0.7304775788782712,0.7602191319005478,0.9085545722713865,0.9422671723556679,0.9700800674252001,0.7602191319005478,0.2992695603315072,0.5347661188369153,0.6163787048742801,0.3930046354825116,0.7435735356089338,0.23080488832701224,0.8596361848574238,0.8389123004167246,0.7683464950958505,0.6874749949901799
20
+ 3,-1,0.8027812895069533,0.9279393173198482,0.9570164348925411,0.9747155499367889,0.8027812895069533,0.3168984407922461,0.5917966006461581,0.6799410029498525,0.42292456805731143,0.7939668492765838,0.24184576485461445,0.8982300884955752,0.8689690232041678,0.8169459880683352,0.7466797175425335,0.7543194268857986,0.9043404972608512,0.943952802359882,0.9734513274336283,0.7543194268857986,0.2971976401179941,0.5357494030060402,0.6179238657114763,0.3970501474926254,0.7495785924989464,0.23438685208596716,0.8721379407220113,0.835292543762834,0.7740901360844912,0.6922344594430478
21
+ 4,-1,0.8095238095238095,0.9304677623261695,0.9549093973872735,0.9726085124315212,0.8095238095238095,0.319567354965585,0.5971344289928361,0.6858407079646017,0.4262115465655289,0.8004635482511588,0.24230931310577328,0.8994240764152267,0.8726774092134393,0.8217274360803863,0.7540718478537253,0.764433206911083,0.9093973872734935,0.9422671723556679,0.9721871049304678,0.764433206911083,0.3010605422109847,0.5391206630144683,0.6216111813456946,0.39831436999578596,0.7503160556257902,0.23463969658659922,0.8732616940581542,0.8416681716934554,0.7782993256263178,0.697674443262754
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:6ca00c66019dfc8f6231392e1e0fd8c026641092690591f23b744fc95bbb0f32
3
+ size 438000173
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 350,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "clean_up_tokenization_spaces": true,
3
+ "cls_token": "[CLS]",
4
+ "do_lower_case": true,
5
+ "mask_token": "[MASK]",
6
+ "model_max_length": 512,
7
+ "pad_token": "[PAD]",
8
+ "sep_token": "[SEP]",
9
+ "strip_accents": null,
10
+ "tokenize_chinese_chars": true,
11
+ "tokenizer_class": "BertTokenizer",
12
+ "unk_token": "[UNK]"
13
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff