azamat commited on
Commit
e2bbb4a
1 Parent(s): 58b1e41

Upload with huggingface_hub

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,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 506 with parameters:
89
+ ```
90
+ {'batch_size': 512, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
91
+ ```
92
+
93
+ **Loss**:
94
+
95
+ `sentence_transformers.losses.OnlineContrastiveLoss.OnlineContrastiveLoss`
96
+
97
+ Parameters of the fit()-Method:
98
+ ```
99
+ {
100
+ "epochs": 3,
101
+ "evaluation_steps": 250,
102
+ "evaluator": "sentence_transformers.evaluation.BinaryClassificationEvaluator.BinaryClassificationEvaluator",
103
+ "max_grad_norm": 1,
104
+ "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
105
+ "optimizer_params": {
106
+ "lr": 2e-05
107
+ },
108
+ "scheduler": "WarmupLinear",
109
+ "steps_per_epoch": null,
110
+ "warmup_steps": 50,
111
+ "weight_decay": 0.01
112
+ }
113
+ ```
114
+
115
+
116
+ ## Full Model Architecture
117
+ ```
118
+ SentenceTransformer(
119
+ (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
120
+ (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})
121
+ )
122
+ ```
123
+
124
+ ## Citing & Authors
125
+
126
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "bert-base-uncased",
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.20.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.20.1",
5
+ "pytorch": "1.11.0"
6
+ }
7
+ }
eval/binary_classification_evaluation_results.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
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,250,0.9968473759040614,0.819008469581604,0.4102564102564102,0.345679012345679,0.5045045045045045,0.6200909614562988,0.32367631179329875,0.9968473759040614,155.64419555664062,0.3880597014925374,0.43333333333333335,0.35135135135135137,186.0501251220703,0.29794185057979755,0.9968473759040614,7.0642805099487305,0.3781094527363184,0.4222222222222222,0.34234234234234234,8.470755577087402,0.29787611303670497,0.9967855597453175,108.98558807373047,0.29268292682926833,0.23863636363636365,0.3783783783783784,71.06520080566406,0.22575220202572693
3
+ 0,500,0.9968164678246894,0.8198140263557434,0.4298245614035088,0.4188034188034188,0.44144144144144143,0.642940104007721,0.34250682190321907,0.9969401001421772,142.98379516601562,0.3980099502487562,0.4444444444444444,0.36036036036036034,174.25442504882812,0.31950985747490374,0.9969091920628053,6.795235633850098,0.39423076923076916,0.422680412371134,0.36936936936936937,7.996814727783203,0.32203209169038804,0.9967855597453175,82.6785659790039,0.30357142857142855,0.3008849557522124,0.3063063063063063,62.52280807495117,0.2418150530354318
4
+ 0,-1,0.9968164678246894,0.7224494218826294,0.4338624338624339,0.5256410256410257,0.36936936936936937,0.6594376564025879,0.34490882334069173,0.9969710082215492,145.15773010253906,0.39423076923076916,0.422680412371134,0.36936936936936937,177.75613403320312,0.3188573275632005,0.9969401001421772,6.699878692626953,0.3921568627450981,0.43010752688172044,0.36036036036036034,8.037707328796387,0.31991715452382996,0.9967855597453175,81.75849914550781,0.32340425531914896,0.3064516129032258,0.34234234234234234,61.235633850097656,0.24605959956453338
5
+ 1,250,0.9969091920628053,0.7172892689704895,0.46031746031746035,0.41134751773049644,0.5225225225225225,0.6217999458312988,0.36497312895504797,0.9969401001421772,156.0782470703125,0.3908045977011494,0.5396825396825397,0.3063063063063063,163.83856201171875,0.3166861275735117,0.9969401001421772,7.0155110359191895,0.39548022598870053,0.5303030303030303,0.3153153153153153,7.511675834655762,0.3197920851680463,0.9967855597453175,83.52542114257812,0.36815920398009944,0.4111111111111111,0.3333333333333333,59.910614013671875,0.27654843727008993
6
+ 1,500,0.997001916300921,0.7830982208251953,0.45,0.4186046511627907,0.4864864864864865,0.6362024545669556,0.39596447586274913,0.9971255486184089,162.73956298828125,0.42553191489361697,0.5194805194805194,0.36036036036036034,193.948974609375,0.35837996324319654,0.997094640539037,7.368961334228516,0.419889502762431,0.5428571428571428,0.34234234234234234,8.703409194946289,0.35992751726116046,0.9967855597453175,119.95298767089844,0.3770491803278688,0.3458646616541353,0.4144144144144144,85.48049926757812,0.27671355760614064
7
+ 1,-1,0.9970328243802931,0.7790623903274536,0.45248868778280543,0.45454545454545453,0.45045045045045046,0.649742841720581,0.3967334612979909,0.9971255486184089,164.37477111816406,0.43478260869565216,0.547945205479452,0.36036036036036034,194.60169982910156,0.36005183240496497,0.997094640539037,7.443972110748291,0.4193548387096775,0.52,0.35135135135135137,8.877153396606445,0.36147808839241424,0.9967855597453175,118.86785888671875,0.37362637362637363,0.3148148148148148,0.4594594594594595,81.50203704833984,0.2820114803025444
8
+ 2,250,0.9970328243802931,0.706745982170105,0.4522613065326634,0.5113636363636364,0.40540540540540543,0.657722532749176,0.3995700475996162,0.997063732459665,160.36976623535156,0.4210526315789474,0.5063291139240507,0.36036036036036034,195.18704223632812,0.3542026783176512,0.997063732459665,7.276709079742432,0.42487046632124353,0.5,0.36936936936936937,8.84858512878418,0.35917689555660137,0.9968164678246894,98.19419860839844,0.3594470046082949,0.36792452830188677,0.35135135135135137,82.72917175292969,0.270701333946961
9
+ 2,500,0.997094640539037,0.7525038123130798,0.4597701149425287,0.6349206349206349,0.36036036036036034,0.6907355785369873,0.41282746676524545,0.997094640539037,174.91311645507812,0.43157894736842106,0.5189873417721519,0.36936936936936937,194.66091918945312,0.3647998616562449,0.997094640539037,7.828941345214844,0.4222222222222222,0.5507246376811594,0.34234234234234234,8.725908279418945,0.3687708893008705,0.9968164678246894,118.57579803466797,0.36507936507936506,0.3262411347517731,0.4144144144144144,79.40945434570312,0.2844228222857304
10
+ 2,-1,0.997094640539037,0.7525147199630737,0.4597701149425287,0.6349206349206349,0.36036036036036034,0.6907644867897034,0.412820964683786,0.997094640539037,174.91392517089844,0.43157894736842106,0.5189873417721519,0.36936936936936937,194.65829467773438,0.36480363906928015,0.997094640539037,7.829055309295654,0.4222222222222222,0.5507246376811594,0.34234234234234234,8.725940704345703,0.3687681562467502,0.9968164678246894,118.57998657226562,0.36507936507936506,0.3262411347517731,0.4144144144144144,79.41696166992188,0.28434837275829544
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:bdfd3f6b7e68503383b27c85768ca75ce81f1a24da2bb88e0ee099ebd030dab2
3
+ size 437998385
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 128,
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,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "do_lower_case": true,
4
+ "mask_token": "[MASK]",
5
+ "model_max_length": 512,
6
+ "name_or_path": "bert-base-uncased",
7
+ "pad_token": "[PAD]",
8
+ "sep_token": "[SEP]",
9
+ "special_tokens_map_file": null,
10
+ "strip_accents": null,
11
+ "tokenize_chinese_chars": true,
12
+ "tokenizer_class": "BertTokenizer",
13
+ "unk_token": "[UNK]"
14
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff