File size: 14,941 Bytes
b3ac905
661ec62
 
b3ac905
661ec62
6f5f2b9
 
 
 
661ec62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58ca939
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
661ec62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
---
language:
- pt
license: apache-2.0
library_name: transformers
datasets:
- wikimedia/wikipedia
metrics:
- accuracy
model-index:
- name: periquito-3B
  results:
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: ENEM Challenge (No Images)
      type: eduagarcia/enem_challenge
      split: train
      args:
        num_few_shot: 3
    metrics:
    - type: acc
      value: 17.98
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: BLUEX (No Images)
      type: eduagarcia-temp/BLUEX_without_images
      split: train
      args:
        num_few_shot: 3
    metrics:
    - type: acc
      value: 21.14
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: OAB Exams
      type: eduagarcia/oab_exams
      split: train
      args:
        num_few_shot: 3
    metrics:
    - type: acc
      value: 22.69
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: Assin2 RTE
      type: assin2
      split: test
      args:
        num_few_shot: 15
    metrics:
    - type: f1_macro
      value: 43.01
      name: f1-macro
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: Assin2 STS
      type: eduagarcia/portuguese_benchmark
      split: test
      args:
        num_few_shot: 15
    metrics:
    - type: pearson
      value: 8.92
      name: pearson
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: FaQuAD NLI
      type: ruanchaves/faquad-nli
      split: test
      args:
        num_few_shot: 15
    metrics:
    - type: f1_macro
      value: 43.97
      name: f1-macro
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: HateBR Binary
      type: ruanchaves/hatebr
      split: test
      args:
        num_few_shot: 25
    metrics:
    - type: f1_macro
      value: 50.46
      name: f1-macro
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: PT Hate Speech Binary
      type: hate_speech_portuguese
      split: test
      args:
        num_few_shot: 25
    metrics:
    - type: f1_macro
      value: 41.19
      name: f1-macro
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: tweetSentBR
      type: eduagarcia-temp/tweetsentbr
      split: test
      args:
        num_few_shot: 25
    metrics:
    - type: f1_macro
      value: 47.96
      name: f1-macro
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=wandgibaut/periquito-3B
      name: Open Portuguese LLM Leaderboard
---
# Model Card for Model ID

<!-- Provide a quick summary of what the model is/does. -->

## Model Details

### Model Description

 Periquito-3B is a large language model (LLM) trained by Wandgibaut. It is built upon the OpenLlama-3B architecture and specifically fine-tuned using Portuguese Wikipedia (pt-br) data. This specialization makes it particularly adept at understanding and generating text in Brazilian Portuguese.

- **Developed by:** Wandemberg Gibaut
- **Model type:** Llama
- **Language(s) (NLP):** Portuguese
- **License:** Apache License 2.0
- **Finetuned from model [optional]:** openlm-research/open_llama_3b


### Loading the Weights with Hugging Face Transformers

```python
import torch
from transformers import LlamaTokenizer, LlamaForCausalLM
model_path = 'wandgibaut/periquito-3B'
tokenizer = LlamaTokenizer.from_pretrained(model_path)
model = LlamaForCausalLM.from_pretrained(
    model_path, torch_dtype=torch.float16, device_map='auto',
)
prompt = 'Q: Qual o maior animal terrestre?\nA:'
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
generation_output = model.generate(
    input_ids=input_ids, max_new_tokens=32
)
print(tokenizer.decode(generation_output[0]))
```

For more advanced usage, please follow the [transformers LLaMA documentation](https://huggingface.co/docs/transformers/main/model_doc/llama).

### Evaluating with LM-Eval-Harness
The model can be evaluated with [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness). However, we used a custom version, that has some translated tasks and the ENEM suit. This can be found in [wandgibaut/lm-evaluation-harness-PTBR](https://github.com/wandgibaut/lm-evaluation-harness-PTBR).



## Dataset and Training

We finetunned the model on Wikipedia-pt dataset with LoRA, in Google's TPU-v3 in the [Google's TPU Research program](https://sites.research.google/trc/about/).


## Evaluation
We evaluated OpenLLaMA on a wide range of tasks using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness).  The LLaMA results are generated by running the original LLaMA model on the same evaluation metrics. We note that our results for the LLaMA model differ slightly from the original LLaMA paper, which we believe is a result of different evaluation protocols. Similar differences have been reported in [this issue of lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness/issues/443). Additionally, we present the results of GPT-J, a 6B parameter model trained on the [Pile](https://pile.eleuther.ai/) dataset by [EleutherAI](https://www.eleuther.ai/).

hf-causal (pretrained=wandgibaut/periquito-3B), limit: None, provide_description: False, num_fewshot: 0, batch_size: None

|  Task   |Version|   Metric   | Value |   |Stderr|
|---------|------:|------------|------:|---|-----:|
|agnews_pt|      0|acc         | 0.6184|±  |0.0056|
|boolq_pt |      1|acc         | 0.6333|±  |0.0084|
|faquad   |      1|exact       | 7.9365|   |      |
|         |       |f1          |45.6971|   |      |
|         |       |HasAns_exact| 7.9365|   |      |
|         |       |HasAns_f1   |45.6971|   |      |
|         |       |NoAns_exact | 0.0000|   |      |
|         |       |NoAns_f1    | 0.0000|   |      |
|         |       |best_exact  | 7.9365|   |      |
|         |       |best_f1     |45.6971|   |      |
|imdb_pt  |      0|acc         | 0.6338|±  |0.0068|
|sst2_pt  |      1|acc         | 0.6823|±  |0.0158|
|toldbr   |      0|acc         | 0.4629|±  |0.0109|
|         |       |f1_macro    | 0.3164|   |      |


hf-causal (pretrained=wandgibaut/periquito-3B,dtype=float), limit: None, provide_description: False, num_fewshot: 3, batch_size: None

|  Task   |Version|   Metric   | Value |   |Stderr|
|---------|------:|------------|------:|---|-----:|
|agnews_pt|      0|acc         | 0.6242|±  |0.0056|
|boolq_pt |      1|acc         | 0.6477|±  |0.0084|
|faquad   |      1|exact       |34.9206|   |      |
|         |       |f1          |70.3968|   |      |
|         |       |HasAns_exact|34.9206|   |      |
|         |       |HasAns_f1   |70.3968|   |      |
|         |       |NoAns_exact | 0.0000|   |      |
|         |       |NoAns_f1    | 0.0000|   |      |
|         |       |best_exact  |34.9206|   |      |
|         |       |best_f1     |70.3968|   |      |
|imdb_pt  |      0|acc         | 0.8408|±  |0.0052|
|sst2_pt  |      1|acc         | 0.7775|±  |0.0141|
|toldbr   |      0|acc         | 0.5143|±  |0.0109|
|         |       |f1_macro    | 0.5127|   |      |


hf-causal (pretrained=wandgibaut/periquito-3B), limit: None, provide_description: False, num_fewshot: 0, batch_size: None

|    Task     |Version|     Metric     |Value |   |Stderr|
|-------------|------:|----------------|-----:|---|-----:|
|enem         |      0|acc             |0.1976|±  |0.0132|
|             |       |2009            |0.2022|±  |0.0428|
|             |       |2016            |0.1809|±  |0.0399|
|             |       |2015            |0.1348|±  |0.0364|
|             |       |2016_2_         |0.2366|±  |0.0443|
|             |       |2017            |0.2022|±  |0.0428|
|             |       |2013            |0.1647|±  |0.0405|
|             |       |2012            |0.2174|±  |0.0432|
|             |       |2011            |0.2292|±  |0.0431|
|             |       |2010            |0.2157|±  |0.0409|
|             |       |2014            |0.1839|±  |0.0418|
|enem_2022    |      0|acc             |0.2373|±  |0.0393|
|             |       |2022            |0.2373|±  |0.0393|
|             |       |human-sciences  |0.2703|±  |0.0740|
|             |       |mathematics     |0.1818|±  |0.0842|
|             |       |natural-sciences|0.1538|±  |0.0722|
|             |       |languages       |0.3030|±  |0.0812|
|enem_CoT     |      0|acc             |0.1812|±  |0.0127|
|             |       |2009            |0.1348|±  |0.0364|
|             |       |2016            |0.1596|±  |0.0380|
|             |       |2015            |0.1124|±  |0.0337|
|             |       |2016_2_         |0.1290|±  |0.0350|
|             |       |2017            |0.2247|±  |0.0445|
|             |       |2013            |0.1765|±  |0.0416|
|             |       |2012            |0.2391|±  |0.0447|
|             |       |2011            |0.1979|±  |0.0409|
|             |       |2010            |0.2451|±  |0.0428|
|             |       |2014            |0.1839|±  |0.0418|
|enem_CoT_2022|      0|acc             |0.2119|±  |0.0378|
|             |       |2022            |0.2119|±  |0.0378|
|             |       |human-sciences  |0.2703|±  |0.0740|
|             |       |mathematics     |0.1818|±  |0.0842|
|             |       |natural-sciences|0.2308|±  |0.0843|
|             |       |languages       |0.1515|±  |0.0634|

hf-causal (pretrained=wandgibaut/periquito-3B,dtype=float), limit: None, provide_description: False, num_fewshot: 1, batch_size: None

|    Task     |Version|     Metric     |Value |   |Stderr|
|-------------|------:|----------------|-----:|---|-----:|
|enem         |      0|acc             |0.1790|±  |0.0127|
|             |       |2009            |0.1573|±  |0.0388|
|             |       |2016            |0.2021|±  |0.0416|
|             |       |2015            |0.1573|±  |0.0388|
|             |       |2016_2_         |0.1935|±  |0.0412|
|             |       |2017            |0.2247|±  |0.0445|
|             |       |2013            |0.1412|±  |0.0380|
|             |       |2012            |0.1739|±  |0.0397|
|             |       |2011            |0.1979|±  |0.0409|
|             |       |2010            |0.1961|±  |0.0395|
|             |       |2014            |0.1379|±  |0.0372|
|enem_2022    |      0|acc             |0.1864|±  |0.0360|
|             |       |2022            |0.1864|±  |0.0360|
|             |       |human-sciences  |0.2432|±  |0.0715|
|             |       |mathematics     |0.1364|±  |0.0749|
|             |       |natural-sciences|0.1154|±  |0.0639|
|             |       |languages       |0.2121|±  |0.0723|
|enem_CoT     |      0|acc             |0.2009|±  |0.0132|
|             |       |2009            |0.2135|±  |0.0437|
|             |       |2016            |0.2340|±  |0.0439|
|             |       |2015            |0.1348|±  |0.0364|
|             |       |2016_2_         |0.2258|±  |0.0436|
|             |       |2017            |0.2360|±  |0.0453|
|             |       |2013            |0.1529|±  |0.0393|
|             |       |2012            |0.1957|±  |0.0416|
|             |       |2011            |0.2500|±  |0.0444|
|             |       |2010            |0.1667|±  |0.0371|
|             |       |2014            |0.1954|±  |0.0428|
|enem_CoT_2022|      0|acc             |0.2542|±  |0.0403|
|             |       |2022            |0.2542|±  |0.0403|
|             |       |human-sciences  |0.2703|±  |0.0740|
|             |       |mathematics     |0.2273|±  |0.0914|
|             |       |natural-sciences|0.3846|±  |0.0973|
|             |       |languages       |0.1515|±  |0.0634|


## Use Cases: 
The model is suitable for text generation, language understanding, and various natural language processing tasks in Brazilian Portuguese.

## Limitations: 
Like many language models, Periquito-3B might exhibit biases present in its training data. Additionally, its performance is primarily optimized for Portuguese, potentially limiting its effectiveness with other languages.

## Ethical Considerations: 
Users are encouraged to use the model ethically, particularly by avoiding the generation of harmful or biased content.


## Acknowledgment
We thank the [Google TPU Research Cloud](https://sites.research.google/trc/about/) program for providing part of the computation resources. 



## Citation [optional]

If you found periquito-3B useful in your research or applications, please cite using the following BibTeX:

**BibTeX:**

```
@software{wandgibautperiquito3B,
  author = {Gibaut, Wandemberg},
  title = {Periquito-3B},
  month = Sep,
  year = 2023,
  url = {https://huggingface.co/wandgibaut/periquito-3B}
}
```

# [Open Portuguese LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard)
Detailed results can be found [here](https://huggingface.co/datasets/eduagarcia-temp/llm_pt_leaderboard_raw_results/tree/main/wandgibaut/periquito-3B)

|          Metric          |  Value  |
|--------------------------|---------|
|Average                   |**33.04**|
|ENEM Challenge (No Images)|    17.98|
|BLUEX (No Images)         |    21.14|
|OAB Exams                 |    22.69|
|Assin2 RTE                |    43.01|
|Assin2 STS                |     8.92|
|FaQuAD NLI                |    43.97|
|HateBR Binary             |    50.46|
|PT Hate Speech Binary     |    41.19|
|tweetSentBR               |    47.96|