Upload 13 files
Browse files- 1_Pooling/config.json +7 -0
- README.md +124 -1
- added_tokens.json +3 -0
- config.json +27 -0
- config_sentence_transformers.json +7 -0
- eval/similarity_evaluation_sts-dev_results.csv +37 -0
- modules.json +14 -0
- pytorch_model.bin +3 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +15 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
- unigram.json +0 -0
1_Pooling/config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 1024,
|
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,126 @@
|
|
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 |
+
|
11 |
+
# {MODEL_NAME}
|
12 |
+
|
13 |
+
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 1024 dimensional dense vector space and can be used for tasks like clustering or semantic search.
|
14 |
+
|
15 |
+
<!--- Describe your model here -->
|
16 |
+
|
17 |
+
## Usage (Sentence-Transformers)
|
18 |
+
|
19 |
+
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
|
20 |
+
|
21 |
+
```
|
22 |
+
pip install -U sentence-transformers
|
23 |
+
```
|
24 |
+
|
25 |
+
Then you can use the model like this:
|
26 |
+
|
27 |
+
```python
|
28 |
+
from sentence_transformers import SentenceTransformer
|
29 |
+
sentences = ["This is an example sentence", "Each sentence is converted"]
|
30 |
+
|
31 |
+
model = SentenceTransformer('{MODEL_NAME}')
|
32 |
+
embeddings = model.encode(sentences)
|
33 |
+
print(embeddings)
|
34 |
+
```
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
## Usage (HuggingFace Transformers)
|
39 |
+
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.
|
40 |
+
|
41 |
+
```python
|
42 |
+
from transformers import AutoTokenizer, AutoModel
|
43 |
+
import torch
|
44 |
+
|
45 |
+
|
46 |
+
#Mean Pooling - Take attention mask into account for correct averaging
|
47 |
+
def mean_pooling(model_output, attention_mask):
|
48 |
+
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
|
49 |
+
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
50 |
+
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
51 |
+
|
52 |
+
|
53 |
+
# Sentences we want sentence embeddings for
|
54 |
+
sentences = ['This is an example sentence', 'Each sentence is converted']
|
55 |
+
|
56 |
+
# Load model from HuggingFace Hub
|
57 |
+
tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
|
58 |
+
model = AutoModel.from_pretrained('{MODEL_NAME}')
|
59 |
+
|
60 |
+
# Tokenize sentences
|
61 |
+
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
|
62 |
+
|
63 |
+
# Compute token embeddings
|
64 |
+
with torch.no_grad():
|
65 |
+
model_output = model(**encoded_input)
|
66 |
+
|
67 |
+
# Perform pooling. In this case, mean pooling.
|
68 |
+
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
|
69 |
+
|
70 |
+
print("Sentence embeddings:")
|
71 |
+
print(sentence_embeddings)
|
72 |
+
```
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
## Evaluation Results
|
77 |
+
|
78 |
+
<!--- Describe how your model was evaluated -->
|
79 |
+
|
80 |
+
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})
|
81 |
+
|
82 |
+
|
83 |
+
## Training
|
84 |
+
The model was trained with the parameters:
|
85 |
+
|
86 |
+
**DataLoader**:
|
87 |
+
|
88 |
+
`torch.utils.data.dataloader.DataLoader` of length 502 with parameters:
|
89 |
+
```
|
90 |
+
{'batch_size': 12, 'sampler': 'torch.utils.data.sampler.SequentialSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
|
91 |
+
```
|
92 |
+
|
93 |
+
**Loss**:
|
94 |
+
|
95 |
+
`sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
|
96 |
+
|
97 |
+
Parameters of the fit()-Method:
|
98 |
+
```
|
99 |
+
{
|
100 |
+
"epochs": 4,
|
101 |
+
"evaluation_steps": 60,
|
102 |
+
"evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
|
103 |
+
"max_grad_norm": 1,
|
104 |
+
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
|
105 |
+
"optimizer_params": {
|
106 |
+
"lr": 3e-05
|
107 |
+
},
|
108 |
+
"scheduler": "WarmupLinear",
|
109 |
+
"steps_per_epoch": null,
|
110 |
+
"warmup_steps": 201,
|
111 |
+
"weight_decay": 0.001
|
112 |
+
}
|
113 |
+
```
|
114 |
+
|
115 |
+
|
116 |
+
## Full Model Architecture
|
117 |
+
```
|
118 |
+
SentenceTransformer(
|
119 |
+
(0): Transformer({'max_seq_length': 514, 'do_lower_case': False}) with Transformer model: RobertaModel
|
120 |
+
(1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
|
121 |
+
)
|
122 |
+
```
|
123 |
+
|
124 |
+
## Citing & Authors
|
125 |
+
|
126 |
+
<!--- Describe where people can find more information -->
|
added_tokens.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"<mask>": 128000
|
3 |
+
}
|
config.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "/home/pkedzia/.cache/torch/sentence_transformers/sdadas_polish-roberta-large-v2",
|
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": 1024,
|
13 |
+
"initializer_range": 0.02,
|
14 |
+
"intermediate_size": 4096,
|
15 |
+
"layer_norm_eps": 1e-05,
|
16 |
+
"max_position_embeddings": 514,
|
17 |
+
"model_type": "roberta",
|
18 |
+
"num_attention_heads": 16,
|
19 |
+
"num_hidden_layers": 24,
|
20 |
+
"pad_token_id": 1,
|
21 |
+
"position_embedding_type": "absolute",
|
22 |
+
"torch_dtype": "float32",
|
23 |
+
"transformers_version": "4.32.0.dev0",
|
24 |
+
"type_vocab_size": 1,
|
25 |
+
"use_cache": true,
|
26 |
+
"vocab_size": 128001
|
27 |
+
}
|
config_sentence_transformers.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "2.2.2",
|
4 |
+
"transformers": "4.32.0.dev0",
|
5 |
+
"pytorch": "2.0.1+cu117"
|
6 |
+
}
|
7 |
+
}
|
eval/similarity_evaluation_sts-dev_results.csv
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
epoch,steps,cosine_pearson,cosine_spearman,euclidean_pearson,euclidean_spearman,manhattan_pearson,manhattan_spearman,dot_pearson,dot_spearman
|
2 |
+
0,60,0.7723377884317062,0.6848956045123572,0.7152605842975858,0.6814080128639715,0.7146540118387618,0.6814076367163262,0.7655718477195023,0.6803585707316407
|
3 |
+
0,120,0.8370147824828019,0.748121720919438,0.7977715021142033,0.7463093674802602,0.7977753866317443,0.7461754998255451,0.8249910891107867,0.7484228681895718
|
4 |
+
0,180,0.8412107056142095,0.7573165042350277,0.8191425212957503,0.7534018183544323,0.8199518222782404,0.7547560117888883,0.824586698892314,0.7579180215727301
|
5 |
+
0,240,0.837106924967446,0.7630832717200202,0.8220217716623711,0.7607839261058997,0.8216868802621007,0.7599840415327889,0.8094282306886391,0.7505044724065164
|
6 |
+
0,300,0.8593067651714921,0.7830460665541533,0.8399012375673669,0.7764804624714321,0.8399339010351562,0.7762166086557818,0.8276788821928601,0.7721023935915596
|
7 |
+
0,360,0.8665655979938239,0.7732949341446029,0.8545295327465703,0.7697428627742703,0.8545354655828016,0.7696464434105125,0.8445517048647507,0.7545824873897884
|
8 |
+
0,420,0.8533447707963788,0.7779752447601324,0.8379218031499144,0.7796348029456448,0.8377841343177789,0.7795564500980751,0.8171126456584482,0.7564218135681523
|
9 |
+
0,480,0.8602777478239267,0.7896022033109009,0.851277592173933,0.7904089027088778,0.8531483271198013,0.7925487272708136,0.8151493932750264,0.7693757401635
|
10 |
+
0,-1,0.8733524187757641,0.801241610872071,0.8594518319623657,0.7983195543461667,0.8615610582215179,0.8009104855500164,0.8438522803058813,0.7906356490534119
|
11 |
+
1,60,0.8800355364105653,0.8071205642516021,0.8730860562264653,0.8057475748108692,0.8737903797563991,0.8061342293379045,0.8257019699895579,0.7698008230581763
|
12 |
+
1,120,0.8876459216943074,0.8092585894910349,0.8594916682933916,0.8071052436068142,0.8595895309681786,0.8076299656167611,0.8770885427845342,0.8075390065309256
|
13 |
+
1,180,0.8880171650665162,0.8009590296946825,0.8676631575671394,0.797410002473631,0.8677240176036778,0.7980510573420357,0.8681030748953881,0.7902927866273348
|
14 |
+
1,240,0.881015735280224,0.813330644654383,0.867067690116044,0.8083533567125002,0.8676895090008107,0.8083999405776959,0.855654847421449,0.8017470801335793
|
15 |
+
1,300,0.8843579942277597,0.8112727733089956,0.865051627435241,0.8082134676251221,0.8655270477647705,0.8086467010634517,0.8556136326504059,0.7986907110115209
|
16 |
+
1,360,0.8954597994221302,0.8200285728038922,0.8806812773086389,0.8152718773478064,0.8806148484272255,0.8149731933972615,0.8826792020714116,0.8181629776235715
|
17 |
+
1,420,0.895589815245497,0.821548185226753,0.8743130665109228,0.8117873855051204,0.874611266784221,0.8117502938288281,0.8730161807645946,0.8132652568935764
|
18 |
+
1,480,0.8776797650451719,0.8201129555170418,0.8654625746050276,0.818093090115076,0.865949140796305,0.8184162975250704,0.8463938791459291,0.8071626609505446
|
19 |
+
1,-1,0.8937036967511763,0.82100687346626,0.8743024441971151,0.8148256926528317,0.8741094709053767,0.8139167971488852,0.8655781996303326,0.811649896616024
|
20 |
+
2,60,0.8933204660338322,0.8220086350914352,0.8815303043559162,0.8201069414016506,0.8814057595006122,0.8197553987573727,0.8652702294327467,0.808381598386674
|
21 |
+
2,120,0.8983910650805065,0.8251779282543263,0.8842641869555355,0.8222150981590015,0.884328886775028,0.8217224429340584,0.8756059032125816,0.8147439064437346
|
22 |
+
2,180,0.891061045993371,0.8164002951103102,0.8692422271684284,0.8137354292148122,0.8689965024823662,0.8133446188731359,0.8745620727696709,0.8122774524826174
|
23 |
+
2,240,0.892737921091004,0.821203525588565,0.8743652421506768,0.8185276874312727,0.8742426248975135,0.8176266171031434,0.8724818418208147,0.8137438525489629
|
24 |
+
2,300,0.8979082616035172,0.8320854978902463,0.8718853581190686,0.8286576015493827,0.8719397220498483,0.8285537804030144,0.8814618064828623,0.8269167193018929
|
25 |
+
2,360,0.8999945016513503,0.8265552824909093,0.8743008122675382,0.8222274718880402,0.8741226806498806,0.8216062529863789,0.8886022306352925,0.8246740176169497
|
26 |
+
2,420,0.8973139839275432,0.82593995783094,0.86881919858127,0.8212068638365851,0.8689532103740931,0.8212211077499195,0.8843156616077439,0.8210921551180456
|
27 |
+
2,480,0.897068053882517,0.8307663316433891,0.8707976445087627,0.8263758467869303,0.871239504499395,0.8266489044403778,0.8810722630739297,0.8268764399759804
|
28 |
+
2,-1,0.893056360360453,0.828789974791719,0.8681154116594885,0.8251725573971419,0.8687005307895503,0.8260593503597131,0.8736751386979628,0.822468618758977
|
29 |
+
3,60,0.8953092594064866,0.8267657089313443,0.8696610797043184,0.8214760269906742,0.8700956805433372,0.8217280723236282,0.8730219759863326,0.8191904072002362
|
30 |
+
3,120,0.9045617112207887,0.8342039414851543,0.882735122132509,0.8299392183891955,0.8831619991197784,0.8302188423327491,0.8882423445809651,0.829470060544808
|
31 |
+
3,180,0.9009582705548707,0.8341845855722531,0.8746023405253759,0.8310668530880551,0.8748963513678898,0.8310146123258915,0.8865399220191287,0.8289448234372219
|
32 |
+
3,240,0.9039040014067536,0.8318809769493862,0.8791088535730097,0.8279481716818312,0.8794417517207601,0.8277618271565996,0.889473348473952,0.8286785758863902
|
33 |
+
3,300,0.9019800827470996,0.8346425692960706,0.8769436656539308,0.8303509660800329,0.877227964551666,0.8302079433878513,0.887591220723701,0.8311376378124925
|
34 |
+
3,360,0.8977488760945409,0.8323578592935313,0.8714978128180628,0.8273664072722503,0.8717533828423454,0.8272509996284058,0.8806321045236665,0.8281881501919962
|
35 |
+
3,420,0.9014976611594302,0.832199208697392,0.8736418167624681,0.8261002474821094,0.8740573860995634,0.8261083017064028,0.8842138405295805,0.828658104378473
|
36 |
+
3,480,0.9001505727331757,0.8325485207355094,0.872472058052955,0.8269999476785627,0.8728199966100785,0.8269961965518435,0.8833124308769593,0.8279664716569112
|
37 |
+
3,-1,0.8998080145072995,0.832313376578528,0.8721773004694198,0.8267608285928677,0.8725100153464427,0.8267719311713813,0.8827680996540198,0.8276706873594402
|
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:3250e4059abf3d6ad2d12dc0b78ab31213aa88b891be7df68472c466bf9d873b
|
3 |
+
size 1739977449
|
sentence_bert_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 514,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"mask_token": {
|
6 |
+
"content": "<mask>",
|
7 |
+
"lstrip": true,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false
|
11 |
+
},
|
12 |
+
"pad_token": "<pad>",
|
13 |
+
"sep_token": "</s>",
|
14 |
+
"unk_token": "<unk>"
|
15 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_prefix_space": false,
|
3 |
+
"bos_token": "<s>",
|
4 |
+
"clean_up_tokenization_spaces": true,
|
5 |
+
"cls_token": "<s>",
|
6 |
+
"eos_token": "</s>",
|
7 |
+
"errors": "replace",
|
8 |
+
"mask_token": "<mask>",
|
9 |
+
"model_max_length": 1000000000000000019884624838656,
|
10 |
+
"pad_token": "<pad>",
|
11 |
+
"sep_token": "</s>",
|
12 |
+
"tokenizer_class": "RobertaTokenizer",
|
13 |
+
"trim_offsets": true,
|
14 |
+
"unk_token": "<unk>"
|
15 |
+
}
|
unigram.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|