ighina commited on
Commit
76525d7
1 Parent(s): 6be78ff

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-sa-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 2161 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.SoftmaxLoss.SoftmaxLoss`
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': 128, '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.8722484698808117,0.4351142346858978,0.9316402602812532,0.8729675891030473,0.998768055683883,0.4351142346858978,0.9273274599729336,0.872221625684527,455.4324951171875,0.9316013334866077,0.8732052905207015,0.9983676737811451,455.4324951171875,0.9277763939952177,0.8722484698808117,21.180402755737305,0.9316472412011254,0.8724159251592785,0.9995072222735533,22.117809295654297,0.9279007008915421,0.8716310533662622,116.7283935546875,0.9314074244075965,0.8716675168469944,0.9999384027841941,116.7283935546875,0.9216453463578042
3
+ 1,-1,0.8830398367872866,0.3007200360298157,0.9364470779598002,0.886030725259021,0.9929471187902307,0.2588081955909729,0.9482871193539114,0.882207666702459,487.31793212890625,0.9360256597171599,0.8887074001273497,0.9886661122917244,487.31793212890625,0.9461220079788373,0.8830666809835713,23.504304885864258,0.9366215626364033,0.8876478861586828,0.9913147925713758,23.517887115478516,0.9467487756789987,0.8825834854504456,113.39614868164062,0.9361304544591892,0.8898695531501527,0.9874649665835105,111.72044372558594,0.9507865150614077
4
+ 2,-1,0.8845162675829485,0.2841256558895111,0.9371438590339266,0.8915019598031857,0.9877113554467338,0.28402209281921387,0.9516869011641892,0.8812144314399227,507.72344970703125,0.9356611233864404,0.8860226302893484,0.9911915981397641,510.73065185546875,0.9471039831122477,0.8825834854504456,23.905746459960938,0.936394834806887,0.886994132069754,0.991622778650405,24.25924301147461,0.9477412265308965,0.8844357349940942,118.96554565429688,0.9371115066974057,0.8903923471509774,0.9890048969786566,104.86940002441406,0.9585834428467714
5
+ 3,-1,0.8836572533018361,0.21417638659477234,0.93692122057947,0.8872735282779889,0.9924543410637839,0.1970081925392151,0.9523206327499225,0.8794695586814131,534.152587890625,0.9346909090909091,0.8855874975882694,0.9895592719209092,534.152587890625,0.9486626710392245,0.8821808225061741,25.215444564819336,0.9360437158469945,0.8883172917358115,0.9891896886260741,25.215444564819336,0.9492455942082272,0.8841404488349619,86.42855072021484,0.9370680353445512,0.8897903801954975,0.989651667744618,86.42855072021484,0.9570234757186677
6
+ 4,-1,0.8798722216256846,0.25027716159820557,0.9346721967547114,0.8859736246758263,0.9890356955865595,0.22327956557273865,0.9554433793124206,0.8747181359390099,535.3999633789062,0.9323476117996666,0.8806824405739949,0.9904524315500939,535.5391845703125,0.9483380164245947,0.8754429292386986,26.259357452392578,0.9330698439257997,0.8775266570800662,0.9961193754042317,26.34870719909668,0.9490645415706767,0.8805164823365188,98.86474609375,0.934933395246249,0.8839346961174372,0.9921771535926576,76.32582092285156,0.9608402295842868
7
+ 5,-1,0.8807312359067969,0.19902488589286804,0.9352425856398615,0.8864796270241938,0.9896824663525209,0.14756590127944946,0.9561285161785213,0.8765703854826586,563.439453125,0.9331219455434023,0.8840779428382438,0.9879269457020543,563.439453125,0.9521545073503304,0.8777246859229034,27.761768341064453,0.9340877190443804,0.880943282930291,0.9940558686747359,27.761768341064453,0.9526811390769112,0.8812412756362075,80.35063171386719,0.9353743973666195,0.8873107107328396,0.9889432997628507,64.56120300292969,0.9608582395872189
8
+ 6,-1,0.8803017287662407,0.1000756025314331,0.935190969447794,0.8851061489385106,0.9912839939634729,0.0952296257019043,0.9567613927498687,0.8755503060238377,596.5432739257812,0.9328466307433803,0.8805753821751853,0.9917151744741137,599.5631713867188,0.9542370089895149,0.8782884140448834,27.748462677001953,0.9342204223315014,0.8806959177551744,0.9946718408327944,29.226673126220703,0.9549135353297387,0.8806775475142274,46.014225006103516,0.9353520368835174,0.8861331569664903,0.9903600357263852,46.014225006103516,0.959801265732717
9
+ 7,-1,0.8810533662622141,0.17146050930023193,0.935334504231199,0.8845541401273885,0.9923003480242693,0.0979340672492981,0.9585477736269306,0.8780736604746054,573.9776611328125,0.9335311831711256,0.8846153846153846,0.9881733345652777,591.5021362304688,0.9565941718265172,0.8796574680554065,27.430192947387695,0.9344107430929992,0.8846661896637129,0.9900828482552588,28.644481658935547,0.9570841459280737,0.8813754966176313,89.87899780273438,0.9354472065980823,0.8877395801642836,0.9885737164680156,60.17534637451172,0.9611790238269508
10
+ 8,-1,0.882422420272737,0.12833011150360107,0.9362240446693423,0.8867862160152054,0.9914995842187934,0.1064419150352478,0.9583366205623727,0.8788789863631483,576.5555419921875,0.9339462434853898,0.8900359943078769,0.9824139948874311,576.5555419921875,0.9566613979611653,0.8812144314399227,28.651039123535156,0.935679646891425,0.8850982007965938,0.992392743847978,29.07884979248047,0.95714470144745,0.8827445506281542,61.60306167602539,0.936296814840742,0.8892213080694756,0.9886353136838215,61.60306167602539,0.9607561852922555
11
+ 9,-1,0.8835230323204123,0.14272668957710266,0.9366282551227563,0.8906944444444445,0.9875573624072191,0.14272668957710266,0.9585921192887226,0.8793890260925588,570.8216552734375,0.9345867834742494,0.8858695652173914,0.9889740983707537,594.0714111328125,0.9571362048431409,0.8824492644690218,28.793184280395508,0.936250691029707,0.8872039482753867,0.9910376051002495,28.937076568603516,0.957526683474774,0.8834961881241276,65.23014068603516,0.9366564640722926,0.8890733515951412,0.989620869136715,59.329498291015625,0.9608721872163821
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:bec2d3df949099aacac726b94a341a6ac16db99c5b7c29ab1f59f7c027da9e73
3
+ size 498652017
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 @@
 
 
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