tgsc commited on
Commit
1755f1e
1 Parent(s): 823b0cb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +172 -0
README.md CHANGED
@@ -1,3 +1,175 @@
1
  ---
 
 
 
 
 
 
 
 
 
2
  license: mit
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/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 | Backbone + Embeddings = Total Parameters |
25
+ | :-: | :-: | :-: | :-: |
26
+ | [ult5-pt-small](https://huggingface.co/tgsc/ult5-pt-small) | encoder-decoder | 65k | 56.6M + 25.8M = 82.4M |
27
+ | [sentence-transformer-ult5-pt-small](https://huggingface.co/tgsc/sentence-transformer-ult5-pt-small) | sentence-transformer | 65k | 25.2 + 25.8M = 51M |
28
+ | [DeBERTina-base](https://huggingface.co/tgsc/debertina-base) | encoder | 32k | 85.5M + 24.6M = 110.0M |
29
+ | [DeBERTina-base-128k-vocab](https://huggingface.co/tgsc/debertina-base-128k-vocab) | encoder | 128k | 85.5M + 98.3M = 183.8M |
30
+ | [DeBERTina-xsmall](https://huggingface.co/tgsc/debertina-xsmall) | encoder | 128k | 21.5M + 49.2M = 70.6M |
31
+
32
+ - **Developed by:** Thacio Garcia Scandaroli
33
+ - **Model type:** DeBERTa-v3
34
+ - **Language(s) (NLP):** Português
35
+ - **License:** MIT
36
+
37
+
38
+ Benchmarks e tutorial de fine-tune: [https://github.com/thacio/LLM-Notebooks](https://github.com/thacio/LLM-Notebooks)
39
+
40
+ *Benchmarks e fine-tune notebook*: [https://github.com/thacio/LLM-Notebooks](https://github.com/thacio/LLM-Notebooks)
41
+
42
+ Special tokens:
43
+ '[PAD]', '[CLS]', '[SEP]', '[UNK]'
44
+
45
+ ## Treino
46
+
47
+ O modelo foi treinado com o corpus C4 em português, utilizando um tokenizer sentencepiece com vocabulário de tamanho 128k.
48
+
49
+ 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
50
+ predições do gerador, e o discriminador é treinado de forma a identificar quais tokens são originais e quais foram substítudos.
51
+
52
+ *The model was trained with the C4 corpus in portuguese with a sentencepiece tokenizer with a vocabulary of 128.*
53
+
54
+ *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.*
55
+
56
+ *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.*
57
+
58
+
59
+ ## Fine-tunning
60
+
61
+ O fine-tunning é feito com o discriminador.
62
+
63
+ Para carregar o modelo para classificações:
64
+
65
+ *Fine-tunning should be done with the discrimnator.*
66
+
67
+ *Loading the model for classification:*
68
+
69
+ ```python
70
+ from transformers import AutoModelForSequenceClassification
71
+
72
+ num_labels = 2 # number of labels in classes
73
+ model = AutoModelForSequenceClassification.from_pretrained("tgsc/debertina-base",num_labels=num_labels)
74
+ ```
75
+
76
+ ## Citation
77
+
78
+ ``` latex
79
+ @inproceedings{
80
+ 2023debertina,
81
+ title={DeBERTina: A portuguese DeBERTa-v3 model.},
82
+ author = {Thacio Garcia Scandaroli},
83
+ year={2023},
84
+ url={https://huggingface.co/tgsc/debertina-base}
85
+ }
86
+ ```
87
+
88
+ ---
89
+
90
+ ## DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing
91
+
92
+ [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.
93
+
94
+ 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).
95
+
96
+ Please check the [official repository](https://github.com/microsoft/DeBERTa) for more implementation details and updates.
97
+
98
+ 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.
99
+
100
+
101
+ #### Fine-tuning on NLU tasks
102
+
103
+ We present the dev results on SQuAD 2.0 and MNLI tasks.
104
+
105
+ | Model |Vocabulary(K)|Backbone #Params(M)| SQuAD 2.0(F1/EM) | MNLI-m/mm(ACC)|
106
+ |-------------------|----------|-------------------|-----------|----------|
107
+ | RoBERTa-base |50 |86 | 83.7/80.5 | 87.6/- |
108
+ | XLNet-base |32 |92 | -/80.2 | 86.8/- |
109
+ | ELECTRA-base |30 |86 | -/80.5 | 88.8/ |
110
+ | DeBERTa-base |50 |100 | 86.2/83.1| 88.8/88.5|
111
+ | DeBERTa-v3-base |128|86 | **88.4/85.4** | **90.6/90.7**|
112
+ | DeBERTa-v3-base + SiFT |128|86 | -/- | 91.0/-|
113
+
114
+ We present the dev results on SQuAD 1.1/2.0 and MNLI tasks.
115
+
116
+ #### Fine-tuning with HF transformers
117
+
118
+ ```bash
119
+ #!/bin/bash
120
+
121
+ cd transformers/examples/pytorch/text-classification/
122
+
123
+ pip install datasets
124
+ export TASK_NAME=mnli
125
+
126
+ output_dir="ds_results"
127
+
128
+ num_gpus=8
129
+
130
+ batch_size=8
131
+
132
+ python -m torch.distributed.launch --nproc_per_node=${num_gpus} \
133
+ run_glue.py \
134
+ --model_name_or_path microsoft/deberta-v3-base \
135
+ --task_name $TASK_NAME \
136
+ --do_train \
137
+ --do_eval \
138
+ --evaluation_strategy steps \
139
+ --max_seq_length 256 \
140
+ --warmup_steps 500 \
141
+ --per_device_train_batch_size ${batch_size} \
142
+ --learning_rate 2e-5 \
143
+ --num_train_epochs 3 \
144
+ --output_dir $output_dir \
145
+ --overwrite_output_dir \
146
+ --logging_steps 1000 \
147
+ --logging_dir $output_dir
148
+
149
+ ```
150
+
151
+ ### Citation
152
+
153
+ If you find DeBERTa useful for your work, please cite the following papers:
154
+
155
+ ``` latex
156
+ @misc{he2021debertav3,
157
+ title={DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing},
158
+ author={Pengcheng He and Jianfeng Gao and Weizhu Chen},
159
+ year={2021},
160
+ eprint={2111.09543},
161
+ archivePrefix={arXiv},
162
+ primaryClass={cs.CL}
163
+ }
164
+ ```
165
+
166
+ ``` latex
167
+ @inproceedings{
168
+ he2021deberta,
169
+ title={DEBERTA: DECODING-ENHANCED BERT WITH DISENTANGLED ATTENTION},
170
+ author={Pengcheng He and Xiaodong Liu and Jianfeng Gao and Weizhu Chen},
171
+ booktitle={International Conference on Learning Representations},
172
+ year={2021},
173
+ url={https://openreview.net/forum?id=XPZIaotutsD}
174
+ }
175
+ ```