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