tgsc commited on
Commit
556b98a
1 Parent(s): 2c317c3

Update README.md

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