upskyy commited on
Commit
830c066
1 Parent(s): 368f0b0
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 ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: sentence-similarity
3
+ tags:
4
+ - sentence-transformers
5
+ - feature-extraction
6
+ - sentence-similarity
7
+ - transformers
8
+ language: ko
9
+
10
+ ---
11
+
12
+ # kf-deberta-multitask
13
+
14
+ 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. You can check the training recipes on [GitHub](https://github.com/upskyy/kf-deberta-multitask).
15
+
16
+ <!--- Describe your model here -->
17
+
18
+ ## Usage (Sentence-Transformers)
19
+
20
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
21
+
22
+ ```
23
+ pip install -U sentence-transformers
24
+ ```
25
+
26
+ Then you can use the model like this:
27
+
28
+ ```python
29
+ from sentence_transformers import SentenceTransformer
30
+ sentences = ["안녕하세요?", "한국어 문장 임베딩을 위한 버트 모델입니다."]
31
+
32
+ model = SentenceTransformer("upskyy/kf-deberta-multitask")
33
+ embeddings = model.encode(sentences)
34
+ print(embeddings)
35
+ ```
36
+
37
+ ## Usage (HuggingFace Transformers)
38
+
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 = ["안녕하세요?", "한국어 문장 임베딩을 위한 버트 모델입니다."]
55
+
56
+ # Load model from HuggingFace Hub
57
+ tokenizer = AutoTokenizer.from_pretrained("upskyy/kf-deberta-multitask")
58
+ model = AutoModel.from_pretrained("upskyy/kf-deberta-multitask")
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
+ ## Evaluation Results
75
+
76
+ <!--- Describe how your model was evaluated -->
77
+
78
+ KorSTS, KorNLI 학습 데이터셋으로 멀티 태스크 학습을 진행한 후 KorSTS 평가 데이터셋으로 평가한 결과입니다.
79
+
80
+ - Cosine Pearson: 85.75
81
+ - Cosine Spearman: 86.25
82
+ - Manhattan Pearson: 84.80
83
+ - Manhattan Spearman: 85.27
84
+ - Euclidean Pearson: 84.79
85
+ - Euclidean Spearman: 85.25
86
+ - Dot Pearson: 82.93
87
+ - Dot Spearman: 82.86
88
+
89
+ ## Training
90
+
91
+ The model was trained with the parameters:
92
+
93
+ **DataLoader**:
94
+
95
+ `sentence_transformers.datasets.NoDuplicatesDataLoader.NoDuplicatesDataLoader` of length 4442 with parameters:
96
+
97
+ ```
98
+ {'batch_size': 128}
99
+ ```
100
+
101
+ **Loss**:
102
+
103
+ `sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss` with parameters:
104
+
105
+ ```
106
+ {'scale': 20.0, 'similarity_fct': 'cos_sim'}
107
+ ```
108
+
109
+ **DataLoader**:
110
+
111
+ `torch.utils.data.dataloader.DataLoader` of length 719 with parameters:
112
+
113
+ ```
114
+ {'batch_size': 8, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
115
+ ```
116
+
117
+ **Loss**:
118
+
119
+ `sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
120
+
121
+ Parameters of the fit()-Method:
122
+
123
+ ```
124
+ {
125
+ "epochs": 10,
126
+ "evaluation_steps": 1000,
127
+ "evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
128
+ "max_grad_norm": 1,
129
+ "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
130
+ "optimizer_params": {
131
+ "lr": 2e-05
132
+ },
133
+ "scheduler": "WarmupLinear",
134
+ "steps_per_epoch": null,
135
+ "warmup_steps": 719,
136
+ "weight_decay": 0.01
137
+ }
138
+ ```
139
+
140
+ ## Full Model Architecture
141
+
142
+ ```
143
+ SentenceTransformer(
144
+ (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: DebertaV2Model
145
+ (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, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False})
146
+ )
147
+ ```
148
+
149
+ ## Citing & Authors
150
+
151
+ <!--- Describe where people can find more information -->
152
+
153
+ ```bibtex
154
+ @proceedings{jeon-etal-2023-kfdeberta,
155
+ title = {KF-DeBERTa: Financial Domain-specific Pre-trained Language Model},
156
+ author = {Eunkwang Jeon, Jungdae Kim, Minsang Song, and Joohyun Ryu},
157
+ booktitle = {Proceedings of the 35th Annual Conference on Human and Cognitive Language Technology},
158
+ moth = {oct},
159
+ year = {2023},
160
+ publisher = {Korean Institute of Information Scientists and Engineers},
161
+ url = {http://www.hclt.kr/symp/?lnb=conference},
162
+ pages = {143--148},
163
+ }
164
+ ```
165
+
166
+ ```bibtex
167
+ @article{ham2020kornli,
168
+ title={KorNLI and KorSTS: New Benchmark Datasets for Korean Natural Language Understanding},
169
+ author={Ham, Jiyeon and Choe, Yo Joong and Park, Kyubyong and Choi, Ilji and Soh, Hyungjoon},
170
+ journal={arXiv preprint arXiv:2004.03289},
171
+ year={2020}
172
+ }
173
+ ```
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "kakaobank/kf-deberta-base",
3
+ "architectures": [
4
+ "DebertaV2Model"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "conv_act": "gelu",
8
+ "conv_kernel_size": 0,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-07,
15
+ "max_position_embeddings": 512,
16
+ "max_relative_positions": -1,
17
+ "model_type": "deberta-v2",
18
+ "norm_rel_ebd": "layer_norm",
19
+ "num_attention_heads": 12,
20
+ "num_hidden_layers": 12,
21
+ "pad_token_id": 0,
22
+ "pooler_dropout": 0,
23
+ "pooler_hidden_act": "gelu",
24
+ "pooler_hidden_size": 768,
25
+ "pos_att_type": [
26
+ "p2c",
27
+ "c2p"
28
+ ],
29
+ "position_biased_input": false,
30
+ "position_buckets": 256,
31
+ "relative_attention": true,
32
+ "share_att_key": true,
33
+ "torch_dtype": "float32",
34
+ "transformers_version": "4.36.1",
35
+ "type_vocab_size": 0,
36
+ "vocab_size": 130000
37
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.36.1",
5
+ "pytorch": "1.11.0"
6
+ }
7
+ }
eval/similarity_evaluation_sts-dev_results.csv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ epoch,steps,cosine_pearson,cosine_spearman,euclidean_pearson,euclidean_spearman,manhattan_pearson,manhattan_spearman,dot_pearson,dot_spearman
2
+ 0,-1,0.8662204956565079,0.8701433627944452,0.8565443779563348,0.8613773571708476,0.8560883635989125,0.8606584545362987,0.8202927967048539,0.8194888085039882
3
+ 1,-1,0.8739205955213473,0.8758925251709859,0.8653773959530131,0.8692820156859796,0.8647304570456534,0.8685202340180903,0.8314283990734999,0.8297083397755294
4
+ 2,-1,0.873226762046955,0.8742324546170553,0.861951917180206,0.8673471958368025,0.8610252712798507,0.8664120314862117,0.8305024207148536,0.8302137280264562
5
+ 3,-1,0.8748335444633338,0.8761404940944174,0.8666428028248511,0.8715341827306609,0.8659880687821292,0.8707590362848057,0.8329152465384382,0.8299645392415027
6
+ 4,-1,0.8751374826185992,0.875617777648221,0.8628455122246389,0.8685438059808782,0.8621695407968285,0.867591484262702,0.8386198188718612,0.8382529150976307
7
+ 5,-1,0.8757745589038899,0.8748982130889459,0.863903994123835,0.8692367380744607,0.8636271881511799,0.8688871933476968,0.8378372858859178,0.8365435829510706
8
+ 6,-1,0.8749608603797978,0.875302211591622,0.8651230938909044,0.870590183854361,0.8644454465711514,0.8697119537070153,0.8394965792357566,0.8371347185924382
9
+ 7,-1,0.8756642281042165,0.8754720764788898,0.8655350874061635,0.8707828014258668,0.8648885722256727,0.8700175677982847,0.8387960733830822,0.8356778955178322
10
+ 8,-1,0.8764719870550455,0.8762953653098642,0.8664626408021754,0.8717207397997367,0.865835356014391,0.8710521094420978,0.8403957938235846,0.8376097829789138
11
+ 9,-1,0.8761662638270564,0.8756781922811445,0.8662225168104593,0.8713532075159957,0.865570210666156,0.8706111322674874,0.8409601713130908,0.8385279740072908
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:acb29ec9aa58f05568fa6e42b8621fa701fc8fd1873f1a4a5f9122b907596c66
3
+ size 741185640
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:3390b04cd5ca99e759732e19660344e27e5107a09c755bfb6cf7a6e48afc92bd
3
+ size 741238901
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 128,
3
+ "do_lower_case": false
4
+ }
similarity_evaluation_sts-test_results.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ epoch,steps,cosine_pearson,cosine_spearman,euclidean_pearson,euclidean_spearman,manhattan_pearson,manhattan_spearman,dot_pearson,dot_spearman
2
+ -1,-1,0.8574826210027622,0.8625167208630782,0.8478939146405619,0.8524540783146085,0.8480117776348778,0.8527497844953591,0.8293372739387574,0.8286020232145503
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "[CLS]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "[SEP]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "[MASK]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "[PAD]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "[SEP]",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "[UNK]",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "[CLS]",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "[CLS]",
47
+ "do_basic_tokenize": true,
48
+ "do_lower_case": false,
49
+ "eos_token": "[SEP]",
50
+ "mask_token": "[MASK]",
51
+ "model_max_length": 512,
52
+ "never_split": null,
53
+ "pad_token": "[PAD]",
54
+ "sep_token": "[SEP]",
55
+ "strip_accents": null,
56
+ "tokenize_chinese_chars": true,
57
+ "tokenizer_class": "BertTokenizer",
58
+ "unk_token": "[UNK]"
59
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff