tgsc commited on
Commit
bc79320
1 Parent(s): 6a59481

Upload 6 files

Browse files
Files changed (6) hide show
  1. DeBERTina.png +0 -0
  2. README.md +185 -0
  3. config.json +23 -0
  4. pytorch_model.bin +3 -0
  5. spm.model +3 -0
  6. tokenizer_config.json +4 -0
DeBERTina.png ADDED
README.md ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: pt
3
+ tags:
4
+ - deberta
5
+ - deberta-v3
6
+ - pt
7
+ - pt-br
8
+ datasets:
9
+ - allenai/c4
10
+ library_name: transformers
11
+ license: mit
12
+ ---
13
+
14
+ # DeBERTina
15
+
16
+ <p align="center">
17
+ <img src="https://huggingface.co/tgsc/debertina-base-32k-vocab/resolve/main/DeBERTina.png" alt="DeBERTina"/>
18
+ </p>
19
+
20
+ DeBERTina é um modelo [DeBERTa-v3](https://arxiv.org/abs/2111.09543) em português treinado no estilo [ELECTRA](https://arxiv.org/abs/2003.10555), com RTD (Replaced Token Detection) e *gradient-disentangled embedding sharing* (GDES).
21
+
22
+ *DeBERTina is a portuguese [DeBERTa-v3](https://arxiv.org/abs/2111.09543) model trained electra-style [ELECTRA](https://arxiv.org/abs/2003.10555) (with Replaced Token Detection - RTD) and gradient-disentangled embedding sharing (GDES).*
23
+
24
+ | Model | type | Vocabulary | Parameters | Context length |
25
+ | :-: | :-: | :-: | :-: | :-: |
26
+ | [ult5-pt-small](https://huggingface.co/tgsc/ult5-pt-small) | encoder-decoder | 65k |82.4M | 1024 |
27
+ | [sentence-transformer-ult5-pt-small](https://huggingface.co/tgsc/ult5-pt-small) | sentence-transformer | 65k | 51M | 1024 |
28
+ | [DeBERTina-base](https://huggingface.co/tgsc/debertina-base) | encoder | 32k | 100M | 512 |
29
+
30
+ - **Developed by:** Thacio Garcia Scandaroli
31
+ - **Model type:** DeBERTa-v3
32
+ - **Language(s) (NLP):** Português
33
+ - **License:** MIT
34
+
35
+
36
+ Benchmarks e tutorial de fine-tune: [https://github.com/thacio/LLM-Notebooks](https://github.com/thacio/LLM-Notebooks)
37
+
38
+ *Benchmarks e fine-tune notebook*: [https://github.com/thacio/LLM-Notebooks](https://github.com/thacio/LLM-Notebooks)
39
+
40
+ Special tokens:
41
+ '[PAD]', '[CLS]', '[SEP]', '[UNK]'
42
+
43
+ ## Treino
44
+
45
+ O modelo foi treinado com uma parte do corpus C4 em português, utilizando um tokenizer sentencepiece com vocabulário de tamanho 32k.
46
+
47
+ O treino consiste em um gerador e um discriminador. O gerador é treinado com *masked language modeling* em 15% dos tokens. Em seguida, tokens são substituídos pelas
48
+ predições do gerador, e o discriminador é treinado de forma a identificar quais tokens são originais e quais foram substítudos.
49
+
50
+ *The model was trained with a subset of C4 corpus in portuguese with a sentencepiece tokenizer with a vocabulary of 32k.*
51
+
52
+ *The training is done with a generator and a discriminator. The generator is trained with maskeed language modeling as BERT, but without next sentence prediction, by masking 15% of the tokens.*
53
+
54
+ *The masked tokens are then replaced by the generators prediction, and the discriminator is trained with the objective of identifying the which are the original and replaced tokens.*
55
+
56
+
57
+ ## Fine-tunning
58
+
59
+ O fine-tunning é feito com o discriminador.
60
+ *Fine-tunning should be done with the discrimnator.*
61
+
62
+ *Note: Transformers commit 'bd94b0f6f215f6bc0f70e61eba075eb9196f9ef' 4.31.0 replaced DataLoader logic for accelerate in Trainer, which may cause the model to not converge properly.*
63
+
64
+ *It can be solved by installingprior version, such as 4.30.2;*
65
+
66
+ Obs: Há um commit na versão transformers 4.31 que alterou a lógica do DataLoader com o accelerate que pode causar problemas na convergência de um dataset.
67
+
68
+ A solução é utilizar uma versão anterior.
69
+
70
+ ```python
71
+ pip install transformers==4.30.2
72
+ ```
73
+
74
+
75
+ Para carregar o modelo para classificações:
76
+
77
+ *Loading the model for classification:*
78
+
79
+ ```python
80
+ from transformers import AutoModelForSequenceClassification
81
+
82
+ num_labels = 2 # number of labels in classes
83
+ model = AutoModelForSequenceClassification.from_pretrained("tgsc/debertina-base",num_labels=num_labels)
84
+ ```
85
+
86
+ ## Citation
87
+
88
+ ``` latex
89
+ @inproceedings{
90
+ 2023debertina,
91
+ title={DeBERTina: A portuguese DeBERTa-v3 model.},
92
+ author = {Thacio Garcia Scandaroli},
93
+ year={2023},
94
+ url={https://huggingface.co/tgsc/debertina-base}
95
+ }
96
+ ```
97
+
98
+ ---
99
+
100
+ ## DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing
101
+
102
+ [DeBERTa](https://arxiv.org/abs/2006.03654) improves the BERT and RoBERTa models using disentangled attention and enhanced mask decoder. With those two improvements, DeBERTa out perform RoBERTa on a majority of NLU tasks with 80GB training data.
103
+
104
+ In [DeBERTa V3](https://arxiv.org/abs/2111.09543), we further improved the efficiency of DeBERTa using ELECTRA-Style pre-training with Gradient Disentangled Embedding Sharing. Compared to DeBERTa, our V3 version significantly improves the model performance on downstream tasks. You can find more technique details about the new model from our [paper](https://arxiv.org/abs/2111.09543).
105
+
106
+ Please check the [official repository](https://github.com/microsoft/DeBERTa) for more implementation details and updates.
107
+
108
+ The DeBERTa V3 base model comes with 12 layers and a hidden size of 768. It has only 86M backbone parameters with a vocabulary containing 128K tokens which introduces 98M parameters in the Embedding layer. This model was trained using the 160GB data as DeBERTa V2.
109
+
110
+
111
+ #### Fine-tuning on NLU tasks
112
+
113
+ We present the dev results on SQuAD 2.0 and MNLI tasks.
114
+
115
+ | Model |Vocabulary(K)|Backbone #Params(M)| SQuAD 2.0(F1/EM) | MNLI-m/mm(ACC)|
116
+ |-------------------|----------|-------------------|-----------|----------|
117
+ | RoBERTa-base |50 |86 | 83.7/80.5 | 87.6/- |
118
+ | XLNet-base |32 |92 | -/80.2 | 86.8/- |
119
+ | ELECTRA-base |30 |86 | -/80.5 | 88.8/ |
120
+ | DeBERTa-base |50 |100 | 86.2/83.1| 88.8/88.5|
121
+ | DeBERTa-v3-base |128|86 | **88.4/85.4** | **90.6/90.7**|
122
+ | DeBERTa-v3-base + SiFT |128|86 | -/- | 91.0/-|
123
+
124
+ We present the dev results on SQuAD 1.1/2.0 and MNLI tasks.
125
+
126
+ #### Fine-tuning with HF transformers
127
+
128
+ ```bash
129
+ #!/bin/bash
130
+
131
+ cd transformers/examples/pytorch/text-classification/
132
+
133
+ pip install datasets
134
+ export TASK_NAME=mnli
135
+
136
+ output_dir="ds_results"
137
+
138
+ num_gpus=8
139
+
140
+ batch_size=8
141
+
142
+ python -m torch.distributed.launch --nproc_per_node=${num_gpus} \
143
+ run_glue.py \
144
+ --model_name_or_path microsoft/deberta-v3-base \
145
+ --task_name $TASK_NAME \
146
+ --do_train \
147
+ --do_eval \
148
+ --evaluation_strategy steps \
149
+ --max_seq_length 256 \
150
+ --warmup_steps 500 \
151
+ --per_device_train_batch_size ${batch_size} \
152
+ --learning_rate 2e-5 \
153
+ --num_train_epochs 3 \
154
+ --output_dir $output_dir \
155
+ --overwrite_output_dir \
156
+ --logging_steps 1000 \
157
+ --logging_dir $output_dir
158
+
159
+ ```
160
+
161
+ ### Citation
162
+
163
+ If you find DeBERTa useful for your work, please cite the following papers:
164
+
165
+ ``` latex
166
+ @misc{he2021debertav3,
167
+ title={DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing},
168
+ author={Pengcheng He and Jianfeng Gao and Weizhu Chen},
169
+ year={2021},
170
+ eprint={2111.09543},
171
+ archivePrefix={arXiv},
172
+ primaryClass={cs.CL}
173
+ }
174
+ ```
175
+
176
+ ``` latex
177
+ @inproceedings{
178
+ he2021deberta,
179
+ title={DEBERTA: DECODING-ENHANCED BERT WITH DISENTANGLED ATTENTION},
180
+ author={Pengcheng He and Xiaodong Liu and Jianfeng Gao and Weizhu Chen},
181
+ booktitle={International Conference on Learning Representations},
182
+ year={2021},
183
+ url={https://openreview.net/forum?id=XPZIaotutsD}
184
+ }
185
+ ```
config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "deberta-v2",
3
+ "attention_probs_dropout_prob": 0.1,
4
+ "hidden_act": "gelu",
5
+ "hidden_dropout_prob": 0.1,
6
+ "hidden_size": 768,
7
+ "initializer_range": 0.02,
8
+ "intermediate_size": 3072,
9
+ "max_position_embeddings": 512,
10
+ "relative_attention": true,
11
+ "position_buckets": 256,
12
+ "norm_rel_ebd": "layer_norm",
13
+ "share_att_key": true,
14
+ "pos_att_type": "p2c|c2p",
15
+ "layer_norm_eps": 1e-7,
16
+ "max_relative_positions": -1,
17
+ "position_biased_input": false,
18
+ "num_attention_heads": 12,
19
+ "num_hidden_layers": 12,
20
+ "type_vocab_size": 0,
21
+ "torch_dtype": "float16",
22
+ "vocab_size": 32001
23
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83d70b268463714474b6ed068ee3c7591a0d87a78074bd4a685c272b2deeb735
3
+ size 271997445
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:147466d96bd68d5ae0582c713952359e1bbbff304d658980af92719cd1ef9ed0
3
+ size 815684
tokenizer_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "do_lower_case": false,
3
+ "vocab_type": "spm"
4
+ }