ighina commited on
Commit
c3e1111
1 Parent(s): 36d33fb

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.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.9370445507210289,0.350566029548645,0.9649095598798485,0.945288073247771,0.9853628854120647,0.3493797779083252,0.9869283589021389,0.9352648654982753,495.2237548828125,0.9638435962555363,0.946110861326996,0.9822537488851286,497.1432800292969,0.9865569187209084,0.9356530272958306,24.031417846679688,0.9641881812030748,0.9434230152589556,0.9858880210721103,24.036739349365234,0.9863536107547041,0.9373375030210706,153.85113525390625,0.9651188371316131,0.9438773477405115,0.987338395752236,148.6768798828125,0.9878442693957095
3
+ 1,-1,0.9341077039131104,0.2967468500137329,0.9637081647553317,0.9336944457471588,0.995715559852962,0.2967468500137329,0.9868130185726761,0.9289810386623798,477.98345947265625,0.9599520928407707,0.9513203346266556,0.968741924997291,478.0232238769531,0.9846551702325459,0.9301528478625468,22.466224670410156,0.9611133884722658,0.9279666607169188,0.9967158182530487,25.57215118408203,0.9846153819993153,0.9358068272533525,138.15414428710938,0.9645531742822484,0.9366689965522929,0.9941484883594929,137.59837341308594,0.9875160259369489
4
+ 2,-1,0.9398788642239327,0.35100603103637695,0.9666166465366143,0.9437315376552425,0.990639248472522,0.35100603103637695,0.9876329741722245,0.9279996484572399,543.824462890625,0.960476961980534,0.927647314633616,0.995715559852962,543.824462890625,0.9865919135031538,0.9377036933961228,24.869953155517578,0.9655191978796009,0.9395947214400089,0.9929148363327193,24.88949966430664,0.9867422522289879,0.9400839308339619,166.67996215820312,0.9666627275357476,0.9456119650487914,0.9886720736190182,166.66346740722656,0.9886199599590941
5
+ 3,-1,0.9327308281029142,0.28820234537124634,0.9627846860097161,0.9367145492675697,0.9903475064391635,0.288156121969223,0.9867302421307684,0.9215546978563215,571.294189453125,0.9570596418362807,0.9219433073298834,0.9949570305662296,571.294189453125,0.9853893279501603,0.9282926007572817,26.393104553222656,0.9605381418950236,0.929899175927082,0.9932649267727496,26.398319244384766,0.9857229849517096,0.9342322086406281,140.8247528076172,0.9635098783391712,0.93999603567889,0.9882302928256467,140.8247528076172,0.9880354860143596
6
+ 4,-1,0.9171750609706975,0.26328885555267334,0.9537730797372477,0.9357834958932238,0.9724678875376139,0.26328885555267334,0.9849655239402361,0.9057572450765704,584.3106689453125,0.9478944288944763,0.9015258048263259,0.9992914836332719,647.7732543945312,0.9837597419271367,0.9147215854578479,26.81503677368164,0.9525048637140422,0.9325554650438449,0.973326442664355,26.84126853942871,0.9838984220161715,0.917944060758307,128.63760375976562,0.9541582448876051,0.9370283758046241,0.9719260809042336,128.63760375976562,0.9864085721964047
7
+ 5,-1,0.9088259204195077,0.3231595456600189,0.9480898464206505,0.9483349595936851,0.9478448599221465,0.31901654601097107,0.984814729708529,0.9004035417933075,548.4482421875,0.9435682203688573,0.9389537283127259,0.9482282923088464,555.0816040039062,0.9835035017094012,0.908371844354443,25.645401000976562,0.9477760963184378,0.9480409000683891,0.947511440455451,25.821611404418945,0.9839929643005484,0.9088185966120067,159.354248046875,0.9480193059220415,0.9497084731017291,0.9463361368353491,159.32086181640625,0.9861303380162763
8
+ 6,-1,0.9094045012120902,0.33286556601524353,0.9485081549206138,0.946661352729205,0.950362176895698,0.3150109648704529,0.984081195021739,0.9001984751832783,560.5879516601562,0.9436432739589494,0.9364360174012969,0.9509623319357501,565.6997680664062,0.9823579398238871,0.9090236632220359,26.072866439819336,0.948241113961158,0.947396886414884,0.9490868474355876,26.143306732177734,0.9833917767570004,0.9093019679070755,162.8985595703125,0.9485111276241557,0.9447890305827089,0.9522626678558628,152.87750244140625,0.9853612179185512
9
+ 7,-1,0.9125024717850316,0.10767194628715515,0.9524960734805861,0.9106488450952663,0.9983745800998591,0.10764265060424805,0.9852975069007872,0.9050614833639713,665.625732421875,0.948688007410017,0.9033031312659239,0.9988747092999025,665.625732421875,0.9841236613422152,0.9103053295347185,30.4620361328125,0.9513755166376172,0.908347232752085,0.9986829931065525,30.47404670715332,0.9847704664981646,0.9127588050475681,55.546478271484375,0.9526346762521273,0.9107912684473438,0.9985079478865374,55.52813720703125,0.9864194650652539
10
+ 8,-1,0.9100270248496789,0.31625962257385254,0.9487114187544619,0.9503420933772729,0.9470863306354141,0.31609046459198,0.9837877941718483,0.9020660460960445,562.0693359375,0.9443183656874014,0.9400555087475839,0.9486200601822138,570.4227294921875,0.9826372422930949,0.9096535106671256,26.50196647644043,0.948487961315862,0.9503133655205884,0.9466695563020447,26.503070831298828,0.9832200020791139,0.9101222343471924,163.95989990234375,0.9487593512827895,0.9498095301744303,0.9477114921354683,161.18621826171875,0.9848667576203933
11
+ 9,-1,0.9098951963146601,0.3273000121116638,0.95037339922187,0.9064944694115333,0.9987163350532221,0.06412458419799805,0.9840443843146534,0.9028570173061571,682.4580078125,0.9475640032258574,0.9011858301939287,0.9989747351399112,682.4580078125,0.9828071837864701,0.9096461868596246,26.269685745239258,0.9494500443768225,0.9048295132726655,0.9986996640798873,31.32526397705078,0.9835179680993102,0.9099830820046726,171.16078186035156,0.9504434466674071,0.9066494131535335,0.9986829931065525,33.64715576171875,0.9851120242408369
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:60c87ee8c36773255cfb24f23e5e7ae6d622c12d53c62b81eeb730edad864755
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