Upload 13 files
Browse files- 1_Pooling/config.json +7 -0
- README.md +134 -1
- config.json +27 -0
- config_sentence_transformers.json +7 -0
- eval/binary_classification_evaluation_Valid_Topic_Boundaries_results.csv +11 -0
- merges.txt +0 -0
- modules.json +14 -0
- pytorch_model.bin +3 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +1 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- vocab.json +0 -0
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,136 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
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 |
+
**DataLoader**:
|
97 |
+
|
98 |
+
`torch.utils.data.dataloader.DataLoader` of length 5765 with parameters:
|
99 |
+
```
|
100 |
+
{'batch_size': 64, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
|
101 |
+
```
|
102 |
+
|
103 |
+
**Loss**:
|
104 |
+
|
105 |
+
`sentence_transformers.losses.SoftmaxLoss.SoftmaxLoss`
|
106 |
+
|
107 |
+
Parameters of the fit()-Method:
|
108 |
+
```
|
109 |
+
{
|
110 |
+
"epochs": 10,
|
111 |
+
"evaluation_steps": 0,
|
112 |
+
"evaluator": "sentence_transformers.evaluation.BinaryClassificationEvaluator.BinaryClassificationEvaluator",
|
113 |
+
"max_grad_norm": 1,
|
114 |
+
"optimizer_class": "<class 'transformers.optimization.AdamW'>",
|
115 |
+
"optimizer_params": {
|
116 |
+
"lr": 2e-05
|
117 |
+
},
|
118 |
+
"scheduler": "WarmupLinear",
|
119 |
+
"steps_per_epoch": null,
|
120 |
+
"warmup_steps": 10000,
|
121 |
+
"weight_decay": 0.01
|
122 |
+
}
|
123 |
+
```
|
124 |
+
|
125 |
+
|
126 |
+
## Full Model Architecture
|
127 |
+
```
|
128 |
+
SentenceTransformer(
|
129 |
+
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: RobertaModel
|
130 |
+
(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})
|
131 |
+
)
|
132 |
+
```
|
133 |
+
|
134 |
+
## Citing & Authors
|
135 |
+
|
136 |
+
<!--- 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.8724363792548051,-0.4885462522506714,0.9315210505097046,0.8746721466619798,0.9962733684437464,-0.5198167562484741,0.9482870767152217,0.8815634059916246,475.5308837890625,0.9356532392147713,0.888633404438042,0.9879269457020543,475.8710632324219,0.9523934225130386,0.8756845270052614,25.743106842041016,0.9327036256630097,0.8829582347438508,0.9883889248205981,25.743106842041016,0.9486990778147659,0.874261784602169,-103.4189453125,0.9323140949683534,0.8782021615441157,0.9935322923403862,-103.4189453125,0.945713013926162
|
3 |
+
1,-1,0.8715773649736926,-0.8653514385223389,0.9313826735513483,0.8716007623956404,0.9999692013920971,-0.8653514385223389,0.9406942729659287,0.8791742725222806,520.5626220703125,0.9345224262142692,0.8843013826658237,0.990791216237026,539.4521484375,0.9498210302666706,0.8720874047031032,39.98064422607422,0.9315481748574221,0.8729470680092618,0.9985832640364656,39.98064422607422,0.9400555719254167,0.871657897562547,-295.98388671875,0.9314247192300521,0.8716510067114094,1.0,-435.1869812011719,0.936878204714809
|
4 |
+
2,-1,0.871657897562547,-0.8735333681106567,0.9314109461301198,0.8717907401439468,0.9997844097446795,-0.8735333681106567,0.9321755298271551,0.876758294856652,599.8697509765625,0.9335456321922269,0.8806805767970286,0.9931627090455512,599.8697509765625,0.9445760392019119,0.8716847417588317,47.64161682128906,0.9314282435301544,0.8717742152044899,0.9998460069604854,47.64161682128906,0.9333497223616692,0.871657897562547,-541.7020263671875,0.9314247192300521,0.8716510067114094,1.0,-547.5809936523438,0.9255973081265415
|
5 |
+
3,-1,0.8716847417588317,-0.8504114151000977,0.9314361122267485,0.8716943646468172,0.9999692013920971,-0.898491382598877,0.9321154275057468,0.8745570707613014,606.3648681640625,0.9324413753416775,0.8748953861936772,0.9980904863100187,645.5669555664062,0.944834245947181,0.8716847417588317,48.6949462890625,0.9314262760737957,0.8717941832048769,0.9998152083525824,48.6949462890625,0.9358121899237093,0.8716847417588317,-567.5224609375,0.9314361122267485,0.8716943646468172,0.9999692013920971,-567.5224609375,0.9199484899635636
|
6 |
+
4,-1,0.8716310533662622,-0.8704615235328674,0.9313877410468319,0.8718671931662503,0.999630416705165,-0.8704615235328674,0.9302681043990398,0.8764361645012348,624.4132690429688,0.9333140334370702,0.880462093074066,0.9929163201823278,641.5534057617188,0.9402572160452738,0.8716847417588317,49.69243621826172,0.9314380791187354,0.8716744073666407,1.0,49.69243621826172,0.9328739446647275,0.871657897562547,-561.347412109375,0.9314247192300521,0.8716510067114094,1.0,-588.161376953125,0.9184166581589492
|
7 |
+
5,-1,0.8716847417588317,-0.8523590564727783,0.9314148818660432,0.8717508055853921,0.9998460069604854,-0.8868223428726196,0.9307782643507979,0.8750939546869967,646.148681640625,0.9327749295978048,0.8781542310202306,0.9946410422248915,655.21923828125,0.9390805040751276,0.8716310533662622,48.66355895996094,0.9314074244075965,0.8716675168469944,0.9999384027841941,48.66355895996094,0.9337836096373169,0.8716310533662622,-555.56787109375,0.9314113597246128,0.8716276073125554,1.0,-572.7196044921875,0.9173812233431777
|
8 |
+
6,-1,0.8717115859551166,-0.8353337049484253,0.9314341452219067,0.871714324070345,0.9999384027841941,-0.8730157613754272,0.9318065746498914,0.8736712122839042,687.2959594726562,0.9321706543672529,0.8760803012652055,0.9959345837568142,687.2959594726562,0.9384547883542511,0.871657897562547,47.198280334472656,0.9314207846231083,0.8716909198303173,0.9999384027841941,47.198280334472656,0.9345394143691392,0.8716310533662622,-509.2225646972656,0.9314113597246128,0.8716276073125554,1.0,-539.64306640625,0.9210116283711751
|
9 |
+
7,-1,0.8718458069365403,-0.8367456793785095,0.931487591450294,0.8718079535995275,0.9999384027841941,-0.8653423190116882,0.9253199547135915,0.8732148609470632,719.7484130859375,0.9320765019470347,0.8736396939984915,0.9988912501154947,733.858154296875,0.9313230885505059,0.8716847417588317,46.59550094604492,0.9314361122267485,0.8716943646468172,0.9999692013920971,46.59550094604492,0.9284372566707704,0.8717384301514013,-482.0269775390625,0.9314451331496786,0.87192091761356,0.9996920139209707,-482.0269775390625,0.9130355782493194
|
10 |
+
8,-1,0.871657897562547,-0.8646595478057861,0.9314207846231083,0.8716909198303173,0.9999384027841941,-0.866702675819397,0.9293619748440078,0.8727048212176527,755.4833374023438,0.9318776037925586,0.8732667402600899,0.9989220487233977,755.4833374023438,0.9329840867700735,0.8716042091699775,45.98941421508789,0.931392096392455,0.8716640713096708,0.9999076041762912,46.117164611816406,0.9316092546065409,0.8716310533662622,-500.8504638671875,0.9314113597246128,0.8716276073125554,1.0,-500.8504638671875,0.9175780640419731
|
11 |
+
9,-1,0.8716847417588317,-0.8721379041671753,0.9314361122267485,0.8716943646468172,0.9999692013920971,-0.8721379041671753,0.9269127373142997,0.872677977021368,764.776123046875,0.9318720464241083,0.8731628532974428,0.9990452431550094,766.3433837890625,0.9299146316450253,0.8716847417588317,45.79191970825195,0.9314321781042001,0.8717342856375695,0.9999076041762912,45.79191970825195,0.929184382505271,0.8716310533662622,-472.2821960449219,0.9314113597246128,0.8716276073125554,1.0,-497.92877197265625,0.9154256756951731
|
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:5f360d99580445075472cdbb7b439e937b9b3a53cdff3b062979db40610e5ef3
|
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
|
|