jarodrigues
commited on
Commit
•
1f8a574
1
Parent(s):
6e0258c
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,179 @@
|
|
1 |
---
|
2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
+
language:
|
4 |
+
- pt
|
5 |
+
tags:
|
6 |
+
- gervasio-pt*
|
7 |
+
- gervasio-ptpt
|
8 |
+
- gervasio-ptbr
|
9 |
+
- gervasio-ptpt-base
|
10 |
+
- gervasio-ptbr-base
|
11 |
+
- portulan
|
12 |
+
- albertina-pt*
|
13 |
+
- albertina-ptpt
|
14 |
+
- albertina-ptbr
|
15 |
+
- albertina-ptbr-nobrwac
|
16 |
+
- albertina-ptpt-base
|
17 |
+
- albertina-ptbr-base
|
18 |
+
- clm
|
19 |
+
- gpt
|
20 |
+
- portuguese
|
21 |
+
- decoder
|
22 |
+
- foundation model
|
23 |
+
datasets:
|
24 |
+
- PORTULAN/glue-ptpt
|
25 |
+
- PORTULAN/extraglue
|
26 |
---
|
27 |
+
</br>
|
28 |
+
</br>
|
29 |
+
<img align="left" width="40" height="40" src="https://github.githubassets.com/images/icons/emoji/unicode/1f917.png">
|
30 |
+
<p style="text-align: center;"> This is the model card for Gervásio 7B PT-BR Decoder.
|
31 |
+
You may be interested in some of the other models in the <a href="https://huggingface.co/PORTULAN">Albertina (encoders) and Gervásio (decoders) families</a>.
|
32 |
+
</p>
|
33 |
+
</br>
|
34 |
+
</br>
|
35 |
+
|
36 |
+
# Gervásio 7B PT-PT
|
37 |
+
|
38 |
+
</br>
|
39 |
+
|
40 |
+
**Gervásio PT-*** is a **fully open** decoder for the **Portuguese language**.
|
41 |
+
|
42 |
+
|
43 |
+
It is a **decoder** of the LLaMA family, based on the neural architecture Transformer and developed over the LLaMA~2 7B model.
|
44 |
+
Its further improvement through additional training was done over language resources that include new instruction data sets of Portuguese prepared for this purpose.
|
45 |
+
|
46 |
+
It has different versions that were trained for different variants of Portuguese (PT),
|
47 |
+
namely for the European variant, spoken in Portugal ([**gervasio-7b-portuguese-ptpt-decoder**](https://huggingface.co/PORTULAN/gervasio-7b-portuguese-ptpt-decoder)), and for the American variant, spoken in Brazil ([**gervasio-7b-portuguese-ptbr-decoder**](https://huggingface.co/PORTULAN/gervasio-7b-portuguese-ptbr-decoder)).
|
48 |
+
|
49 |
+
All versions of Gervásio are **openly distributed for free under an open license**, including thus for research and commercial purposes, and given its size, can
|
50 |
+
be run on consumer-grade hardware.
|
51 |
+
|
52 |
+
**Gervásio 7B PT-BR** is developed by NLX-Natural Language and Speech Group, at the University of Lisbon, Faculty of Sciences, Department of Informatics, Portugal.
|
53 |
+
|
54 |
+
For the record, its full name is **Gervásio Produz Textos em Português**, to which corresponds the natural acronym **GPT PT**,
|
55 |
+
and which is know tough more shortly as **Gervásio PT-***, or even more briefly just as **Gervásio**, among his acquaintances.
|
56 |
+
|
57 |
+
These models are fully documented in the respective [publication](https://arxiv.org/abs/?):
|
58 |
+
|
59 |
+
``` latex
|
60 |
+
@misc{albertina-pt,
|
61 |
+
title={Advancing Generative AI for Portuguese with Open Decoder Gervásio~PT*},
|
62 |
+
author={Rodrigo Santos, João Silva, Luís Gomes, João Rodrigues, António Branco},
|
63 |
+
year={2024},
|
64 |
+
eprint={?},
|
65 |
+
archivePrefix={arXiv},
|
66 |
+
primaryClass={cs.CL}
|
67 |
+
}
|
68 |
+
```
|
69 |
+
|
70 |
+
Please use the above cannonical reference when using or citing this model.
|
71 |
+
|
72 |
+
|
73 |
+
<br>
|
74 |
+
|
75 |
+
|
76 |
+
# Model Description
|
77 |
+
|
78 |
+
**This model card is for Gervásio 7B PT-BR**, with 7 billion parameters, a hidden size of 4096 units, an intermediate size of 11,008 units, 32 attention heads, 32 hidden layers, and a tokenizer obtained using the Byte-Pair Encoding (BPE) algorithm implemented with SentencePiece, featuring a vocabulary size of 32,000.
|
79 |
+
Gervásio-7B-PTPT-Decoder is distributed under an [MIT license](https://huggingface.co/PORTULAN/albertina-ptpt/blob/main/LICENSE).
|
80 |
+
|
81 |
+
|
82 |
+
<br>
|
83 |
+
|
84 |
+
# Training Data
|
85 |
+
|
86 |
+
**Gervásio 7B PT-PT** was trained over standard supervised fine-tuning, and to keep some alignment with mainstream benchmarks for English, we resorted to tasks and respective datasets in the GLUE and the SuperGLUE collections.
|
87 |
+
|
88 |
+
|
89 |
+
We selected those datasets where the outcome of their machine translation into American Portuguese could preserve, in the target language, the linguistic properties at stake.
|
90 |
+
|
91 |
+
From GLUE, we resorted to the following four tasks:
|
92 |
+
- MRPC (paraphrase Detection).
|
93 |
+
- RTE (recognizing Textual Entailment).
|
94 |
+
- STS-B (semantic textual similarity).
|
95 |
+
- WNLI (coreference and natural language inference).
|
96 |
+
|
97 |
+
And from SuperGLUE, we included these other four tasks:
|
98 |
+
- BoolQ (yes/no question answering).
|
99 |
+
- CB (inference with 3 labels).
|
100 |
+
- COPA (reasoning)
|
101 |
+
- MultiRC (question answering).
|
102 |
+
|
103 |
+
|
104 |
+
Instruction templates have been manually crafted for each task.
|
105 |
+
These take the various fields in the dataset and arrange them into a prompt.
|
106 |
+
These templates are listed in full detail in the [Extraglue dataset](https://huggingface.co/datasets/PORTULAN/extraglue).
|
107 |
+
|
108 |
+
# Training Details
|
109 |
+
|
110 |
+
We applied supervised fine-tuning with a causal language modeling (CLM) training objective following a zero-out technique during the fine-tuning process.
|
111 |
+
Specifically, while the entire prompt received attention during fine-tuning, only the response tokens were subjected to back-propagation.
|
112 |
+
|
113 |
+
In terms of hyper-parameters, both models were trained with a learning rate of 2 * 10^-5, a weight decay of 0.1, a two-epoch training regime without warm-up, and to ensure the same number of tokens back-propagated per step, we employed an input sequence of 512 tokens with a batch size of 16 and 16 accumulation steps.
|
114 |
+
|
115 |
+
Due to hardware limitations that imposed a shorter sequence length (512) compared to the base model (4096), instead of the typical practice of concatenating all training examples and then dividing them into batches with the same input sequence length, we separate each example individually.
|
116 |
+
In other words, each example occupies the full input sequence length.
|
117 |
+
|
118 |
+
To achieve this, we adapted the tokenizer of the base model to accept padding to allow grouping examples with different size into batches while preserving the original input sequence length.
|
119 |
+
|
120 |
+
For the model training process, we resorted to an a2-megagpu-16gb Google Cloud A2 VM, equipped with 16 GPUs, 96 vCPUs, and 1.360 GB of RAM.
|
121 |
+
The training of each model took approximately two hours.
|
122 |
+
|
123 |
+
# Evaluation
|
124 |
+
|
125 |
+
For testing, we reserved the translated datasets MRPC (similarity) and RTE (inference), from GLUE, and COPA (reasoning/qa), from SuperGLUE, which were taking as representatives of three major types of tasks, and were not seen during training.
|
126 |
+
We also employ data augmentation techniques to enhance the size and diversity of our dataset.
|
127 |
+
This involves repurposing the tasks in various ways, such as generation of answers from MultiRC, question generation from BoolQ, and other relevant modifications.
|
128 |
+
|
129 |
+
|
130 |
+
| Model | MRPC (F1) | RTE (F1) | COPA (F1) |
|
131 |
+
|--------------------------|----------------|----------------|-----------|
|
132 |
+
| **Gervásio 7B PT-BR** | **0.7822** | **0.8321** | 0.2134 |
|
133 |
+
| **LLaMA 2** | 0.0369 | 0.0516 | 0.4867 |
|
134 |
+
| **LLaMA 2 Chat** | 0.5432 | 0.3807 | **0.5493**|
|
135 |
+
<br>
|
136 |
+
|
137 |
+
For further testing our decoder, in addition to the testing data described above, we also reused some of the datasets that had been resorted for American Portuguese to test the state-of-the-art Sabiá model and that were originally developed with materials from Portuguese: ASSIN2 RTE (entailment) and ASSIN2 STS (similarity), BLUEX (question answering), ENEM~2022 (question answering) and FaQuAD (extractive question-answering).
|
138 |
+
The scores of Sabiá invite to contrast them with Gervásio's but such comparison needs to be taken with some caution.
|
139 |
+
First, these are a repetition of the scores presented in the respective paper, which only provide results for a single run of each task, while scores of Gervásio are the average of three runs, with different seeds.
|
140 |
+
Second, the evaluation methods adopted by Sabiá are *sui generis*, and different from the one's adopted for Gervásio.
|
141 |
+
Third, to evaluate Sabiá, the examples included in the few-shot prompt are hand picked, and identical for every test instance in each task.
|
142 |
+
To evaluate Gervásio, the examples were randomly selected to be included in the prompts.
|
143 |
+
|
144 |
+
|
145 |
+
| Model | ENEM 2022 (Accuracy) | BLUEX (Accuracy)| RTE (F1) | STS (Pearson) |
|
146 |
+
|--------------------------|----------------------|-----------------|-----------|---------------|
|
147 |
+
| **Gervásio 7B PT-BR** | 0.1977 | 0.2640 | **0.7469**| **0.2136** |
|
148 |
+
| **LLaMA 2** | 0.2458 | 0.2903 | 0.0913 | 0.1034 |
|
149 |
+
| **LLaMA 2 Chat** | 0.2231 | 0.2959 | 0.5546 | 0.1750 |
|
150 |
+
|--------------------------|----------------------|-----------------|-----------|---------------|
|
151 |
+
| **Sabiá-7B** | **0.6017** | **0.7743** | 0.6847 | 0.1363 |
|
152 |
+
|
153 |
+
<br>
|
154 |
+
|
155 |
+
|
156 |
+
# How to use
|
157 |
+
|
158 |
+
You can use this model directly with a pipeline for causal language modeling (CLM):
|
159 |
+
|
160 |
+
```python3
|
161 |
+
>>> from transformers import pipeline
|
162 |
+
>>> generator = pipeline(model='PORTULAN/gervasio-7b-portuguese-ptbr-decoder')
|
163 |
+
>>> generator("A música brasileira é", max_new_tokens=10)
|
164 |
+
[{'generated_text': 'A música brasileira é uma das mais ricas do mundo'}]
|
165 |
+
|
166 |
+
|
167 |
+
|
168 |
+
```
|
169 |
+
<br>
|
170 |
+
|
171 |
+
# Acknowledgments
|
172 |
+
|
173 |
+
The research reported here was partially supported by: PORTULAN CLARIN—Research Infrastructure for the Science and Technology of Language,
|
174 |
+
funded by Lisboa 2020, Alentejo 2020 and FCT—Fundação para a Ciência e Tecnologia under the
|
175 |
+
grant PINFRA/22117/2016; research project GPT-PT - Transformer-based Decoder for the Portuguese Language, funded by FCT—Fundação para a Ciência e Tecnologia under the
|
176 |
+
grant CPCA-IAC/AV/478395/2022; innovation project
|
177 |
+
ACCELERAT.AI - Multilingual Intelligent Contact Centers, funded by IAPMEI, I.P. - Agência para a Competitividade e Inovação
|
178 |
+
under the grant C625734525-00462629, of Plano de Recuperação e Resiliência,
|
179 |
+
call RE-C05-i01.01 – Agendas/Alianças Mobilizadoras para a Reindustrialização.
|