nicholasKluge commited on
Commit
4ff9c82
1 Parent(s): 53bcba3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +414 -0
README.md ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - pt
4
+ license: apache-2.0
5
+ library_name: transformers
6
+ tags:
7
+ - text-generation-inference
8
+ datasets:
9
+ - TucanoBR/GigaVerbo
10
+ metrics:
11
+ - perplexity
12
+ pipeline_tag: text-generation
13
+ widget:
14
+ - text: "A floresta da Amazônia é conhecida por sua"
15
+ example_title: Exemplo
16
+ - text: "Uma das coisas que Portugal, Angola, Brasil e Moçambique tem em comum é o"
17
+ example_title: Exemplo
18
+ - text: "O Carnaval do Rio de Janeiro é"
19
+ example_title: Exemplo
20
+ inference:
21
+ parameters:
22
+ repetition_penalty: 1.2
23
+ temperature: 0.2
24
+ top_k: 20
25
+ top_p: 0.2
26
+ max_new_tokens: 150
27
+ co2_eq_emissions:
28
+ emissions: 4475000
29
+ source: CodeCarbon
30
+ training_type: pre-training
31
+ geographical_location: Germany
32
+ hardware_used: NVIDIA A100-SXM4-80GB
33
+ model-index:
34
+ - name: Tucano-2b4
35
+ results:
36
+ - task:
37
+ type: text-generation
38
+ name: Text Generation
39
+ dataset:
40
+ name: CALAME-PT
41
+ type: NOVA-vision-language/calame-pt
42
+ split: all
43
+ args:
44
+ num_few_shot: 0
45
+ metrics:
46
+ - type: acc
47
+ value: 59.06
48
+ name: accuracy
49
+ source:
50
+ url: https://huggingface.co/datasets/NOVA-vision-language/calame-pt
51
+ name: Context-Aware LAnguage Modeling Evaluation for Portuguese
52
+ - task:
53
+ type: text-generation
54
+ name: Text Generation
55
+ dataset:
56
+ name: LAMBADA-PT
57
+ type: nicholasKluge/lambada-pt-br
58
+ split: train
59
+ args:
60
+ num_few_shot: 0
61
+ metrics:
62
+ - type: acc
63
+ value: 37.67
64
+ name: accuracy
65
+ source:
66
+ url: https://huggingface.co/datasets/nicholasKluge/lambada-pt-br
67
+ name: LAMBADA-PT-BR
68
+ - task:
69
+ type: text-generation
70
+ name: Text Generation
71
+ dataset:
72
+ name: ENEM Challenge (No Images)
73
+ type: eduagarcia/enem_challenge
74
+ split: train
75
+ args:
76
+ num_few_shot: 3
77
+ metrics:
78
+ - type: acc
79
+ value: 20.5
80
+ name: accuracy
81
+ source:
82
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
83
+ name: Open Portuguese LLM Leaderboard
84
+ - task:
85
+ type: text-generation
86
+ name: Text Generation
87
+ dataset:
88
+ name: BLUEX (No Images)
89
+ type: eduagarcia-temp/BLUEX_without_images
90
+ split: train
91
+ args:
92
+ num_few_shot: 3
93
+ metrics:
94
+ - type: acc
95
+ value: 23.23
96
+ name: accuracy
97
+ source:
98
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
99
+ name: Open Portuguese LLM Leaderboard
100
+ - task:
101
+ type: text-generation
102
+ name: Text Generation
103
+ dataset:
104
+ name: OAB Exams
105
+ type: eduagarcia/oab_exams
106
+ split: train
107
+ args:
108
+ num_few_shot: 3
109
+ metrics:
110
+ - type: acc
111
+ value: 25.47
112
+ name: accuracy
113
+ source:
114
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
115
+ name: Open Portuguese LLM Leaderboard
116
+ - task:
117
+ type: text-generation
118
+ name: Text Generation
119
+ dataset:
120
+ name: Assin2 RTE
121
+ type: assin2
122
+ split: test
123
+ args:
124
+ num_few_shot: 15
125
+ metrics:
126
+ - type: f1_macro
127
+ value: 56.27
128
+ name: f1-macro
129
+ source:
130
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
131
+ name: Open Portuguese LLM Leaderboard
132
+ - task:
133
+ type: text-generation
134
+ name: Text Generation
135
+ dataset:
136
+ name: Assin2 STS
137
+ type: eduagarcia/portuguese_benchmark
138
+ split: test
139
+ args:
140
+ num_few_shot: 10
141
+ metrics:
142
+ - type: pearson
143
+ value: 1.93
144
+ name: pearson
145
+ source:
146
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
147
+ name: Open Portuguese LLM Leaderboard
148
+ - task:
149
+ type: text-generation
150
+ name: Text Generation
151
+ dataset:
152
+ name: FaQuAD NLI
153
+ type: ruanchaves/faquad-nli
154
+ split: test
155
+ args:
156
+ num_few_shot: 15
157
+ metrics:
158
+ - type: f1_macro
159
+ value: 43.97
160
+ name: f1-macro
161
+ source:
162
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
163
+ name: Open Portuguese LLM Leaderboard
164
+ - task:
165
+ type: text-generation
166
+ name: Text Generation
167
+ dataset:
168
+ name: HateBR Binary
169
+ type: ruanchaves/hatebr
170
+ split: test
171
+ args:
172
+ num_few_shot: 25
173
+ metrics:
174
+ - type: f1_macro
175
+ value: 29.49
176
+ name: f1-macro
177
+ source:
178
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
179
+ name: Open Portuguese LLM Leaderboard
180
+ - task:
181
+ type: text-generation
182
+ name: Text Generation
183
+ dataset:
184
+ name: PT Hate Speech Binary
185
+ type: hate_speech_portuguese
186
+ split: test
187
+ args:
188
+ num_few_shot: 25
189
+ metrics:
190
+ - type: f1_macro
191
+ value: 41.98
192
+ name: f1-macro
193
+ source:
194
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
195
+ name: Open Portuguese LLM Leaderboard
196
+ - task:
197
+ type: text-generation
198
+ name: Text Generation
199
+ dataset:
200
+ name: tweetSentBR
201
+ type: eduagarcia-temp/tweetsentbr
202
+ split: test
203
+ args:
204
+ num_few_shot: 25
205
+ metrics:
206
+ - type: f1_macro
207
+ value: 58.0
208
+ name: f1-macro
209
+ source:
210
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard
211
+ name: Open Portuguese LLM Leaderboard
212
+ - task:
213
+ type: text-generation
214
+ name: Text Generation
215
+ dataset:
216
+ name: ARC-Challenge (PT)
217
+ type: arc_pt
218
+ args:
219
+ num_few_shot: 25
220
+ metrics:
221
+ - type: acc_norm
222
+ value: 30.43
223
+ name: normalized accuracy
224
+ source:
225
+ url: https://github.com/nlp-uoregon/mlmm-evaluation
226
+ name: Evaluation Framework for Multilingual Large Language Models
227
+ - task:
228
+ type: text-generation
229
+ name: Text Generation
230
+ dataset:
231
+ name: HellaSwag (PT)
232
+ type: hellaswag_pt
233
+ args:
234
+ num_few_shot: 10
235
+ metrics:
236
+ - type: acc_norm
237
+ value: 47.17
238
+ name: normalized accuracy
239
+ source:
240
+ url: https://github.com/nlp-uoregon/mlmm-evaluation
241
+ name: Evaluation Framework for Multilingual Large Language Models
242
+ - task:
243
+ type: text-generation
244
+ name: Text Generation
245
+ dataset:
246
+ name: TruthfulQA
247
+ type: truthfulqa_pt
248
+ args:
249
+ num_few_shot: 0
250
+ metrics:
251
+ - type: mc2
252
+ value: 39.3
253
+ name: bleurt
254
+ source:
255
+ url: https://github.com/nlp-uoregon/mlmm-evaluation
256
+ name: Evaluation Framework for Multilingual Large Language Models
257
+ ---
258
+ # Tucano-2b4
259
+
260
+ <img src="./logo.png" alt="An illustration of a Tucano bird showing vibrant colors like yellow, orange, blue, green, and black." height="200">
261
+
262
+ ## Model Summary
263
+
264
+ **[Tucano](https://huggingface.co/TucanoBR)** is a series of decoder-transformers based on the Llama 2 architecture, pretrained natively in Portuguese. All Tucano models were trained on **[GigaVerbo](https://huggingface.co/datasets/TucanoBR/GigaVerbo)**, a concatenation of deduplicated Portuguese text corpora amounting to 200 billion tokens.
265
+
266
+ Read our preprint [here](https://arxiv.org/abs/xxxx.xxxxx).
267
+
268
+ ## Details
269
+
270
+ - **Architecture:** a Transformer-based model pre-trained via causal language modeling
271
+ - **Size:** 2,444,618,240 parameters
272
+ - **Context length:** 4096 tokens
273
+ - **Dataset:** [TucanoBR/GigaVerbo](https://huggingface.co/datasets/TucanoBR/GigaVerbo)
274
+ - **Language:** Portuguese
275
+ - **Number of steps:** 1,960,000
276
+ - **GPU:** 16 NVIDIA A100-SXM4-80GB
277
+ - **Training time**: ~ 845 hours
278
+ - **Emissions:** 4,475 KgCO2 (Germany)
279
+ - **Total energy consumption:** 11,749 kWh
280
+
281
+ This repository has the [source code](https://github.com/Nkluge-correa/Tucano) used to train this model. The main libraries used are:
282
+
283
+ - [PyTorch](https://github.com/pytorch/pytorch)
284
+ - [Transformers](https://github.com/huggingface/transformers)
285
+ - [Datasets](https://github.com/huggingface/datasets)
286
+ - [Tokenizers](https://github.com/huggingface/tokenizers)
287
+ - [Sentencepiece](https://github.com/google/sentencepiece)
288
+ - [Accelerate](https://github.com/huggingface/accelerate)
289
+ - [FlashAttention](https://github.com/Dao-AILab/flash-attention)
290
+ - [Liger Kernel](https://github.com/linkedin/Liger-Kernel)
291
+ - [Codecarbon](https://github.com/mlco2/codecarbon)
292
+ - [TRL](https://github.com/huggingface/trl)
293
+
294
+ ## Intended Uses
295
+
296
+ The primary intended use of the Tucano models is to serve as foundations for research and development involving native Portuguese language modeling. Checkpoints saved during training are designed to provide a controlled setting for performing comparative experiments, specifically regarding the effects of active pretraining on the performance of currently available benchmarks. You may also fine-tune and adapt Tucano models for deployment if your use follows the Apache 2.0 license. If you decide to use the Tucano models as a basis for your fine-tuned model, please conduct your own risk and bias assessment.
297
+
298
+ ## Out-of-scope Use
299
+
300
+ - Tucano models are **not intended for deployment**. They are not an out-of-the-box product and should not be used for human-facing interactions.
301
+
302
+ - Tucano models are for **the Portuguese language only** and are unsuitable for text generation tasks in other languages.
303
+
304
+ - Tucano models have **not been fine-tuned** for downstream tasks.
305
+
306
+ ## Basic usage
307
+
308
+ Using the `pipeline`:
309
+
310
+ ```python
311
+ from transformers import pipeline
312
+
313
+ generator = pipeline("text-generation", model="TucanoBR/Tucano-2b4")
314
+
315
+ completions = generator("A floresta da Amazônia é conhecida por sua", num_return_sequences=2, max_new_tokens=100)
316
+
317
+ for comp in completions:
318
+ print(f"🤖 {comp['generated_text']}")
319
+ ```
320
+
321
+ Using the `AutoTokenizer` and `AutoModelForCausalLM`:
322
+
323
+ ```python
324
+ from transformers import GenerationConfig, TextGenerationPipeline, AutoTokenizer, AutoModelForCausalLM
325
+ import torch
326
+
327
+ # Specify the model and tokenizer
328
+ model_id = "TucanoBR/Tucano-2b4"
329
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
330
+ model = AutoModelForCausalLM.from_pretrained(model_id)
331
+
332
+ # Specify the generation parameters as you like
333
+ generation_config = GenerationConfig(
334
+ **{
335
+ "do_sample": True,
336
+ "max_new_tokens": 2048,
337
+ "renormalize_logits": True,
338
+ "repetition_penalty": 1.2,
339
+ "temperature": 0.3,
340
+ "top_k": 30,
341
+ "top_p": 0.3,
342
+ "use_cache": True,
343
+ }
344
+ )
345
+
346
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
347
+ generator = TextGenerationPipeline(model=model, task="text-generation", tokenizer=tokenizer, device=device)
348
+
349
+ # Generate text
350
+ prompt = "A floresta da Amazônia é conhecida por sua"
351
+ completion = generator(prompt, generation_config=generation_config)
352
+ print(completion[0]['generated_text'])
353
+ ```
354
+
355
+ ## Limitations
356
+
357
+ Like almost all other language models trained on large text datasets scraped from the web, the Tucano models show behavior that does not make them an out-of-the-box solution to many real-world applications, especially those requiring factual, reliable, and nontoxic text generation. Tucano models are all subject to the following:
358
+
359
+ - **Hallucinations:** Tucano models can produce content that can be mistaken as true facts, but are misleading or entirely false, i.e., hallucination.
360
+
361
+ - **Biases and Toxicity:** Tucano models inherit the social and historical stereotypes from the data used to train them. Given these biases, the model can produce toxic content, i.e., harmful, offensive, or detrimental to individuals, groups, or communities.
362
+
363
+ - **Unreliable Code:** Tucano models may produce incorrect code snippets and statements. These code generations should not be treated as suggestions or accurate solutions.
364
+
365
+ - **Language Limitations:** Tucano models are primarily designed to interact with Portuguese. Other languages might challenge its comprehension, leading to potential misinterpretations or errors in response.
366
+
367
+ - **Repetition and Verbosity:** Tucano models may get stuck on repetition loops (especially if the repetition penalty during generations is set to a meager value) or produce verbose responses unrelated to the prompt it was given.
368
+
369
+ Hence, even though our models are released with a permissive license, we urge users to perform their risk analysis on them if they intend to use them for real-world applications. We also have humans moderating the outputs of these models in applications where they will interact with an audience, guaranteeing users are always aware they are interacting with a language model.
370
+
371
+ ## Evaluations
372
+
373
+ The table below compares our models against several Portuguese and multilingual language models on the evaluation harness used in our study. More information on it can be found [here](https://github.com/Nkluge-correa/Tucano/tree/main/evaluations/README.md). To learn more about our evaluation harness selection, [read our preprint](https://arxiv.org/abs/xxxx.xxxxx).
374
+
375
+ | | Average | Calame-PT | Lambada-PT | ARC-PT | HellaSwag-PT |
376
+ |-----------------|---------|-----------|------------|--------|--------------|
377
+ | Llama-3.2-3B | 52 | 58.43 | 49.1 | 43.25 | 57.2 |
378
+ | Granite-3.0-2b | 51.63 | 56.36 | 47.55 | 42.56 | 60.05 |
379
+ | **Tucano-2b4** | 43.58 | 59.06 | 37.67 | 30.43 | 47.17 |
380
+ | Llama-3.2-1B | 42.95 | 51.83 | 41.02 | 33.5 | 45.44 |
381
+ | **Tucano-1b1** | 41.55 | 58.24 | 34.7 | 30.43 | 42.84 |
382
+ | Gemma-2b | 40.38 | 51.16 | 39.88 | 37.95 | 32.53 |
383
+ | Bloom-1b7 | 40.37 | 55.64 | 31.98 | 30.34 | 43.52 |
384
+ | **Tucano-630m** | 39.5 | 56.55 | 33.13 | 28.89 | 39.41 |
385
+ | Gemma-2-2b | 39.21 | 56.7 | 47.1 | 24.19 | 28.85 |
386
+ | Bloom-1b1 | 38.18 | 52.94 | 30.22 | 29.83 | 39.74 |
387
+ | GlórIA-1b3 | 36.05 | 52.79 | 27.71 | 26.67 | 37.04 |
388
+ | **Tucano-160m** | 35.14 | 52.31 | 28.16 | 27.01 | 33.07 |
389
+ | Xglm-564m | 34.55 | 50.58 | 27.42 | 25.56 | 34.64 |
390
+ | Bloom-560m | 34.32 | 49.95 | 25.44 | 24.74 | 37.15 |
391
+ | TTL-460m | 33.78 | 49.42 | 23.29 | 29.4 | 33 |
392
+ | mGPT-1b3 | 31.81 | 47.14 | 29.92 | 23.81 | 26.37 |
393
+ | TTL-160m | 30.78 | 46.72 | 20.98 | 26.15 | 29.29 |
394
+ | Lola-v1 | 30.19 | 26.4 | 18.32 | 30.42 | 45.61 |
395
+ | GPorTuguese | 28.92 | 40.61 | 22.98 | 22.48 | 29.62 |
396
+
397
+ ## Cite as 🤗
398
+
399
+ ```latex
400
+ @misc{correa24tucano,
401
+ title = {{Tucano: Advancing Neural Text Generation for Portuguese}},
402
+ author = {Corr{\^e}a, Nicholas Kluge and Sen, Aniket and Falk, Sophia and Fatimah, Shiza},
403
+ journal={arXiv preprint arXiv:xxxx.xxxxx},
404
+ year={2024}
405
+ }
406
+ ```
407
+
408
+ ## Aknowlegments
409
+
410
+ We gratefully acknowledge the granted access to the [Marvin cluster](https://www.hpc.uni-bonn.de/en/systems/marvin) hosted by [University of Bonn](https://www.uni-bonn.de/en) along with the support provided by its High Performance Computing \& Analytics Lab.
411
+
412
+ ## License
413
+
414
+ Tucano is licensed under the Apache License, Version 2.0. For more details, see the [LICENSE](LICENSE) file.