ighina commited on
Commit
a2ba946
1 Parent(s): 60eb865

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 CHANGED
@@ -1,3 +1,125 @@
1
  ---
2
- license: cc-by-4.0
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 768 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 6033 with parameters:
88
+ ```
89
+ {'batch_size': 64, '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": 10,
100
+ "evaluation_steps": 0,
101
+ "evaluator": "sentence_transformers.evaluation.BinaryClassificationEvaluator.BinaryClassificationEvaluator",
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": 10000,
110
+ "weight_decay": 0.01
111
+ }
112
+ ```
113
+
114
+
115
+ ## Full Model Architecture
116
+ ```
117
+ SentenceTransformer(
118
+ (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: RobertaModel
119
+ (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})
120
+ )
121
+ ```
122
+
123
+ ## Citing & Authors
124
+
125
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "roberta-base",
3
+ "architectures": [
4
+ "RobertaModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "layer_norm_eps": 1e-05,
16
+ "max_position_embeddings": 514,
17
+ "model_type": "roberta",
18
+ "num_attention_heads": 12,
19
+ "num_hidden_layers": 12,
20
+ "pad_token_id": 1,
21
+ "position_embedding_type": "absolute",
22
+ "torch_dtype": "float32",
23
+ "transformers_version": "4.18.0",
24
+ "type_vocab_size": 1,
25
+ "use_cache": true,
26
+ "vocab_size": 50265
27
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.0",
4
+ "transformers": "4.18.0",
5
+ "pytorch": "1.11.0"
6
+ }
7
+ }
eval/binary_classification_evaluation_Valid_Topic_Boundaries_results.csv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ epoch,steps,cossim_accuracy,cossim_accuracy_threshold,cossim_f1,cossim_precision,cossim_recall,cossim_f1_threshold,cossim_ap,manhatten_accuracy,manhatten_accuracy_threshold,manhatten_f1,manhatten_precision,manhatten_recall,manhatten_f1_threshold,manhatten_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.8718726511328251,-0.5806294083595276,0.9314588508982294,0.8725785622040465,0.9988604515075918,-0.5806294083595276,0.9448495311774219,0.8724363792548051,581.9130859375,0.9316430953202253,0.8734201094133183,0.9981828821337275,610.8831176757812,0.9418916371225208,0.8722484698808117,28.706748962402344,0.9316873609416493,0.8724862888482633,0.9995072222735533,29.89052963256836,0.9419012808926447,0.8723558466659508,-127.54020690917969,0.9316270040980659,0.8737458193979933,0.9977209030151837,-127.54020690917969,0.9454112161354993
3
+ 1,-1,0.8716042091699775,-0.9183016419410706,0.9313960326453334,0.8716241610738255,0.9999692013920971,-0.9183016419410706,0.9306215564881994,0.8718994953291098,674.1887817382812,0.9315115678282336,0.8722014674657994,0.9994764236656503,674.1887817382812,0.9308649610145874,0.8718994953291098,32.22175216674805,0.931488763238713,0.8721145836132534,0.9995380208814562,33.30061721801758,0.926616894185984,0.8718458069365403,-198.45037841796875,0.9314384151593453,0.8723078164071952,0.9991684375866211,-205.07373046875,0.9367382013739534
4
+ 2,-1,0.8715773649736926,-0.882503867149353,0.9313826735513483,0.8716007623956404,0.9999692013920971,-0.9365043044090271,0.9300293182223586,0.8717921185439708,734.317138671875,0.9314482560643031,0.8722077363511733,0.9993224306261357,734.317138671875,0.9329743208053412,0.871657897562547,36.25634765625,0.9314148818660432,0.8717508055853921,0.9998460069604854,36.659934997558594,0.9283484772751359,0.8716847417588317,-252.74533081054688,0.9314341452219067,0.871714324070345,0.9999384027841941,-271.25390625,0.9333017628997994
5
+ 3,-1,0.8715773649736926,-0.9233579635620117,0.9313826735513483,0.8716007623956404,0.9999692013920971,-0.94148850440979,0.9279728554551627,0.8716310533662622,797.5691528320312,0.9314113597246128,0.8716276073125554,1.0,833.8800048828125,0.9325655370380966,0.8716042091699775,39.929046630859375,0.9313940645753547,0.871644115120275,0.9999384027841941,39.929046630859375,0.926549293071476,0.8715773649736926,-330.1188049316406,0.9313826735513483,0.8716007623956404,0.9999692013920971,-361.7674560546875,0.9309662972071203
6
+ 4,-1,0.8715773649736926,-0.958938717842102,0.9313826735513483,0.8716007623956404,0.9999692013920971,-0.958938717842102,0.9237352629382556,0.871657897562547,799.770751953125,0.931416849564631,0.8717308415230116,0.9998768055683883,799.770751953125,0.9295486243592767,0.8716310533662622,41.84960174560547,0.9314113597246128,0.8716276073125554,1.0,41.84960174560547,0.9228772743484609,0.8716310533662622,-366.80645751953125,0.9314093921225508,0.8716475610083492,0.9999692013920971,-366.80645751953125,0.9291196945138074
7
+ 5,-1,0.8716310533662622,-0.891035258769989,0.9314113597246128,0.8716276073125554,1.0,-0.9004808068275452,0.9222100791396741,0.871657897562547,817.2085571289062,0.9314247192300521,0.8716510067114094,1.0,817.2085571289062,0.9283259846760687,0.8716042091699775,42.829139709472656,0.9313960326453334,0.8716241610738255,0.9999692013920971,42.829139709472656,0.9219676426293072,0.8716042091699775,-385.53192138671875,0.9313960326453334,0.8716241610738255,0.9999692013920971,-405.5646057128906,0.9237537040238877
8
+ 6,-1,0.8716042091699775,-0.9185487031936646,0.9313960326453334,0.8716241610738255,0.9999692013920971,-0.9185487031936646,0.9183475746199087,0.8717384301514013,779.2967529296875,0.9314608675694285,0.8717611363209193,0.9999384027841941,784.8831176757812,0.9252783934658072,0.8716310533662622,44.17878723144531,0.9314113597246128,0.8716276073125554,1.0,44.17878723144531,0.9182847934033853,0.8716310533662622,-414.99420166015625,0.9314093921225508,0.8716475610083492,0.9999692013920971,-414.99420166015625,0.9173291499558064
9
+ 7,-1,0.8716310533662622,-0.8870944976806641,0.9314113597246128,0.8716276073125554,1.0,-0.9236519932746887,0.9201080072611685,0.8717115859551166,793.271728515625,0.9314376712623559,0.8718375678143632,0.9997844097446795,793.271728515625,0.9267098274621985,0.8715773649736926,45.28962707519531,0.9313826735513483,0.8716007623956404,0.9999692013920971,45.28962707519531,0.9204000051611257,0.8715773649736926,-433.1257019042969,0.9313826735513483,0.8716007623956404,0.9999692013920971,-433.1257019042969,0.9173815080095685
10
+ 8,-1,0.8716310533662622,-0.8718323111534119,0.9314113597246128,0.8716276073125554,1.0,-0.9116883277893066,0.9184184649439073,0.8716310533662622,769.4930419921875,0.9313826735513483,0.8716007623956404,0.9999692013920971,842.1710815429688,0.9257301839007596,0.8716042091699775,44.77383804321289,0.9313940645753547,0.871644115120275,0.9999384027841941,44.77383804321289,0.9189387816576033,0.8715773649736926,-443.2563781738281,0.9313826735513483,0.8716007623956404,0.9999692013920971,-448.7958984375,0.9141911174673697
11
+ 9,-1,0.8716847417588317,-0.8646078705787659,0.9314341452219067,0.871714324070345,0.9999384027841941,-0.876809298992157,0.9173819020599622,0.8716310533662622,828.3596801757812,0.9314113597246128,0.8716276073125554,1.0,828.3596801757812,0.923616384821353,0.8716310533662622,44.748661041259766,0.9314113597246128,0.8716276073125554,1.0,45.308067321777344,0.9177777685547296,0.8716310533662622,-445.9535827636719,0.9314093921225508,0.8716475610083492,0.9999692013920971,-445.9535827636719,0.9137153993379528
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
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:7b6d1b2aa7c3202301dd5d66d359cb8281cc29e0c31eb94d4e485a9edbc469e6
3
+ size 498652017
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 256,
3
+ "do_lower_case": false
4
+ }
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
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"errors": "replace", "bos_token": "<s>", "eos_token": "</s>", "sep_token": "</s>", "cls_token": "<s>", "unk_token": "<unk>", "pad_token": "<pad>", "mask_token": "<mask>", "add_prefix_space": false, "trim_offsets": true, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "roberta-base", "tokenizer_class": "RobertaTokenizer"}
vocab.json ADDED
The diff for this file is too large to render. See raw diff