Upload 13 files
Browse files- 1_Pooling/config.json +7 -0
- README.md +123 -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,125 @@
|
|
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 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.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.8840062278535381,0.05605888366699219,0.9368800853090261,0.8910748027120151,0.9876497582309279,0.05605888366699219,0.9580340233966167,0.883335122946419,540.64697265625,0.9364582724135914,0.8913908759428841,0.9863254180911023,540.722412109375,0.95768956626295,0.8839256952646838,26.724918365478516,0.9367984097287184,0.8914791220407823,0.9869721888570636,26.724918365478516,0.9580060408879387,0.8838720068721142,24.12000846862793,0.9367710251688152,0.8914295251606442,0.9869721888570636,24.12000846862793,0.9527632486362555
|
3 |
+
1,-1,0.887522817566842,-0.02520066499710083,0.9384888341471281,0.8956619087601455,0.9856170501093351,-0.07296687364578247,0.9604720473258415,0.8837377858906904,573.0992431640625,0.9365151492942055,0.8935164466323562,0.9838615294588685,575.4552612304688,0.9586249709296829,0.8860463867711801,29.051849365234375,0.9378203438479337,0.8939888879582322,0.9861714250515876,29.088623046875,0.958901052932254,0.8874959733705573,-1.88673734664917,0.9384297460098783,0.8952239807617024,0.986017432012073,-30.153972625732422,0.9612924947130518
|
4 |
+
2,-1,0.8888113389885107,-0.046362340450286865,0.9393113553113553,0.8958385735446186,0.9872185777202871,-0.046362340450286865,0.9610528980917918,0.8861537635563191,578.6109619140625,0.9376568793415446,0.8910275967272223,0.9894360774892975,635.3765869140625,0.9593475883257288,0.8875496617631268,29.66901969909668,0.9384940430776453,0.8961806820410794,0.9850010779512766,30.178972244262695,0.959924207374268,0.8888113389885107,-16.8544864654541,0.9392909463814826,0.8957000363219804,0.9873417721518988,-21.47041893005371,0.9627327574983325
|
5 |
+
3,-1,0.8877107269408354,0.007558315992355347,0.938716950194712,0.8946061333258922,0.9874033693677046,-0.06459563970565796,0.9605266080527364,0.8847041769569419,582.9884033203125,0.9372315245024986,0.8915853556834292,0.9878037512704426,627.084716796875,0.9583043188917221,0.8872543756039944,30.02883529663086,0.9384281906324146,0.8946633527884051,0.9866950013859374,30.60776710510254,0.9593541570941686,0.8877912595296897,-28.044719696044922,0.9388047902087664,0.8946898456902085,0.9874957651914134,-28.044719696044922,0.9621213882434756
|
6 |
+
4,-1,0.8885160528293783,-0.0069811344146728516,0.9389907178944894,0.8974704511637047,0.9845390988327327,-0.021633148193359375,0.9598884560711982,0.8852947492752067,603.9135131835938,0.9373400599546684,0.8923599509967702,0.9870953832886753,635.9114990234375,0.957762133904924,0.8875496617631268,30.784770965576172,0.9386326013389783,0.8950603486812696,0.9866642027780345,30.808700561523438,0.9589422749063858,0.888542897025663,-3.219302177429199,0.9390193896081074,0.8951556610358788,0.9874033693677046,-30.825672149658203,0.9598685964105638
|
7 |
+
5,-1,0.8868785568560077,-0.16024798154830933,0.9381161971830987,0.8957720433722788,0.9846622932643444,-0.19374006986618042,0.9585190926417047,0.8828250832170085,639.2328491210938,0.9359981244871645,0.8927024232091451,0.9837075364193538,645.750732421875,0.9563974203316064,0.8841941372275314,32.37837219238281,0.9365942561509744,0.8957800331749557,0.9813052450029258,32.37837219238281,0.9572672031275953,0.8863148287340277,-75.47447204589844,0.9378319458059607,0.8932772172361894,0.9870645846807724,-102.31878662109375,0.9587777260886018
|
8 |
+
6,-1,0.886851712659723,-0.1339225172996521,0.9381037672137886,0.8963108430354888,0.9839847238904802,-0.16881197690963745,0.956145954917584,0.8819123805433265,663.226806640625,0.9357798165137615,0.8888119250803502,0.9879885429178601,680.2119140625,0.952188039081989,0.8844357349940942,33.67722702026367,0.9370641638524627,0.8918851227249959,0.9870645846807724,33.69036102294922,0.9543637613850438,0.8867174916782992,-65.90252685546875,0.9379628541201362,0.8968724534240031,0.9829991684375866,-69.89508056640625,0.9580768965624566
|
9 |
+
7,-1,0.8859926983786105,-0.10699254274368286,0.9376838100812057,0.8931597725498941,0.9868797930333549,-0.2632904052734375,0.95657471809027,0.881509717599055,682.344482421875,0.9354130695619093,0.8910322526691383,0.984446703009024,682.415283203125,0.9522622190850599,0.8843015140126704,33.98533630371094,0.9368456503594804,0.8929767753461366,0.9852474668145,34.10675048828125,0.9547589876558753,0.8858047890046172,-58.60382080078125,0.9375420333927892,0.8923988978262685,0.9874957651914134,-125.4371109008789,0.958372448796595
|
10 |
+
8,-1,0.8860732309674648,-0.18714755773544312,0.9378521152523523,0.8934147429463589,0.9869413902491607,-0.2581535577774048,0.9559683424876376,0.8810533662622141,649.5318603515625,0.9351367158941366,0.8902035021296735,0.984847084911762,674.557861328125,0.9523460949365016,0.8839793836572533,34.32533264160156,0.9368294893156771,0.8914851595315586,0.9870337860728695,34.32533264160156,0.9542995639506178,0.885939009986041,-97.29713439941406,0.9376568116792606,0.8953931513758897,0.9841079183220919,-97.73741149902344,0.9569828715386257
|
11 |
+
9,-1,0.8845431117792333,-0.284145712852478,0.9369846964926413,0.8932041545677909,0.9852782654224029,-0.2996388077735901,0.9548462488073206,0.8790937399334264,701.826416015625,0.934386868642773,0.885633896060907,0.988820105331239,713.51611328125,0.9502827542958762,0.8821808225061741,34.62346649169922,0.935777937109495,0.8913916146297948,0.9848162863038591,34.64466857910156,0.9527362849895715,0.8840062278535381,-86.64799499511719,0.9366030987525835,0.8936003580219288,0.9839539252825772,-127.51248168945312,0.9563330072381035
|
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:8e6f05ea0826b8becffeb406272bdf8b37078eafd2ddce101547ef53f20dba7c
|
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
|
|