ighina commited on
Commit
f0fac36
1 Parent(s): 07d3bd9

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 11254 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': 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.9439362535795109,0.1942729651927948,0.9685996382087642,0.9535447188615549,0.9841375688719586,0.1647069752216339,0.9902755193638794,0.9368541317260017,487.0047607421875,0.9645212757208416,0.9518012644153905,0.9775858763513908,498.6268310546875,0.9898180767245379,0.942097977896749,24.628259658813477,0.9675310024572241,0.9525532705449024,0.9829872717118588,25.403541564941406,0.9898257269375648,0.9442438534945548,78.79898834228516,0.9686986121160297,0.9556939949220873,0.9820620326917787,75.07635498046875,0.9900140526691402
3
+ 1,-1,0.9470561955749555,0.18167856335639954,0.9702743933780444,0.9574670107610654,0.9834290525052305,0.18167856335639954,0.9912960496040254,0.9387949407137782,479.0604248046875,0.965502722382983,0.9563713383817732,0.9748101592911502,479.4814758300781,0.9907058000029847,0.9444123010670787,24.648906707763672,0.9687756981678234,0.9559230438416411,0.9819786778251048,24.865650177001953,0.990866311518843,0.9474663287950139,68.83369445800781,0.9705034521611474,0.9577313897996949,0.9836207686985805,68.81210327148438,0.9903996870224162
4
+ 2,-1,0.9463311386323522,0.22136378288269043,0.9698651733368368,0.9556078735953011,0.9845543432053281,0.17708265781402588,0.9905355310308794,0.9395566166938868,454.2745361328125,0.9659684678193056,0.9544729604374501,0.9777442505980711,461.0172119140625,0.9904393931016515,0.9455474912297405,25.55816650390625,0.9695038166373393,0.9543817430066541,0.9851128208120431,25.559284210205078,0.9901726452959991,0.9464409957448678,81.23705291748047,0.9699218123413933,0.9573414309376116,0.9828372329518459,81.23705291748047,0.9897013960712675
5
+ 3,-1,0.9457232626097656,0.18248775601387024,0.9694735932801593,0.9570217327745834,0.9822537488851286,0.139762282371521,0.9909181937486247,0.937073845951033,504.1842956542969,0.9645830928786954,0.9541291885147642,0.9752686110578566,504.8411865234375,0.9903830035704351,0.9438996345420056,26.65975570678711,0.968497590024511,0.9558476137904162,0.9814868841117289,26.65975570678711,0.9905645871013672,0.9460235387173084,66.33551025390625,0.9696585715049759,0.9573348064144015,0.982303761805133,57.859554290771484,0.9906879011626413
6
+ 4,-1,0.9436652727019723,0.11534753441810608,0.9683488477995987,0.9534342634631853,0.9837374655119239,0.06546029448509216,0.9900469736993498,0.9334339136230143,513.6358642578125,0.9626392402983603,0.9488967164662537,0.9767856696313214,522.61083984375,0.9894900538887156,0.9410872924616049,27.711666107177734,0.9669730040206778,0.9521212561908686,0.9822954263184656,27.918235778808594,0.9897008326041719,0.9437971012369911,50.360958099365234,0.9684617881102132,0.954807614418793,0.9825121489718177,36.10419845581055,0.989799752282519
7
+ 5,-1,0.9429621871818721,0.11458128690719604,0.9679751301472946,0.9552172184033048,0.9810784452650267,0.11458128690719604,0.9899560337774227,0.9326063233753964,513.9761352539062,0.962089564536728,0.9511489805394221,0.973284765231018,513.9761352539062,0.9891385367307349,0.9404720926315173,28.27408218383789,0.9666365651424349,0.9522446239820139,0.9814702131383941,28.27408218383789,0.9896793488721957,0.943291758519419,65.82530212402344,0.9680972712390072,0.9556133013926672,0.980911735531679,51.612796783447266,0.9891788757454277
8
+ 6,-1,0.940581949744033,0.09761971235275269,0.9667227028578457,0.9513076879624922,0.982645516758496,0.04933968186378479,0.9895408037915339,0.9311049428376824,548.2176513671875,0.9615290349988562,0.9427742932897573,0.9810451033183573,558.80859375,0.9888136447393836,0.9381138266161813,28.64573097229004,0.965285020901259,0.9512694545837144,0.9797197609382424,28.986019134521484,0.9892326950498872,0.9408602544290726,43.0414924621582,0.966812388399729,0.9524367953674199,0.9816285873850745,30.146373748779297,0.9878655790861148
9
+ 7,-1,0.9391757787038325,0.030027329921722412,0.9659112831395277,0.9514960375222384,0.9807700322583334,0.030027329921722412,0.9890914588974957,0.9293399052299309,545.63623046875,0.9604531781323569,0.9422227211855368,0.9794030124448816,561.580810546875,0.9883382311635116,0.9361583700134025,29.675506591796875,0.964211667234605,0.9500412614682611,0.978811192891497,29.675506591796875,0.9887414510150588,0.9393369024688555,34.53508377075195,0.965934841866728,0.9516594808409439,0.9806449999583225,14.90319538116455,0.9863649329706106
10
+ 8,-1,0.938912121633795,0.060673296451568604,0.9657690103953508,0.9486777464199854,0.9834874009119022,-0.012976646423339844,0.9891983928664781,0.9280362674947452,552.2633056640625,0.9596400449943757,0.9421553981334233,0.9777859280314081,571.57470703125,0.9881091301374394,0.9355285225683128,30.27292251586914,0.9639386670814472,0.9470069247287614,0.9814868841117289,30.674551010131836,0.9887845514212033,0.93908789301382,30.922779083251953,0.9657991372681254,0.9530889848391391,0.9788528703248339,30.922779083251953,0.9856311459374316
11
+ 9,-1,0.9379746742736614,-0.006018996238708496,0.9653101767464722,0.9489956993057681,0.9821954004784569,-0.006138503551483154,0.9885918376836251,0.92750895335467,558.5787353515625,0.9594141332961563,0.9441606340136713,0.975168585217848,558.8121337890625,0.9876599182719511,0.9346643132831897,30.3677978515625,0.9634728235515579,0.9463250721480422,0.981253490485042,31.051837921142578,0.9882595765259202,0.9379819980811624,5.89303731918335,0.9652957824934774,0.9489289740698985,0.9822370779117939,-3.409907817840576,0.9836457854227416
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:b4a54052511dcb4d1a63061cb1220ca92d7ad667d4d8fe377c1b51a4bcb918fc
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