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