nicholasKluge commited on
Commit
acc1aa4
·
verified ·
1 Parent(s): 61c6d83

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +180 -0
README.md ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - pt
4
+ license: apache-2.0
5
+ library_name: transformers
6
+ tags:
7
+ - text-generation-inference
8
+ datasets:
9
+ - nicholasKluge/instruct-aira-dataset-v3
10
+ - cnmoro/GPT4-500k-Augmented-PTBR-Clean
11
+ - rhaymison/orca-math-portuguese-64k
12
+ metrics:
13
+ - perplexity
14
+ pipeline_tag: text-generation
15
+ widget:
16
+ - text: "<instruction>Cite algumas bandas de rock brasileiras famosas.</instruction>"
17
+ example_title: Exemplo
18
+ - text: "<instruction>Invente uma história sobre um encanador com poderes mágicos.</instruction>"
19
+ example_title: Exemplo
20
+ - text: "<instruction>Qual cidade é a capital do estado do Rio Grande do Sul?</instruction>"
21
+ example_title: Exemplo
22
+ - text: "<instruction>Diga o nome de uma maravilha culinária característica da cosinha Portuguesa?</instruction>"
23
+ example_title: Exemplo
24
+ inference:
25
+ parameters:
26
+ repetition_penalty: 1.2
27
+ temperature: 0.2
28
+ top_k: 20
29
+ top_p: 0.2
30
+ max_new_tokens: 150
31
+ co2_eq_emissions:
32
+ emissions: 20000
33
+ source: CodeCarbon
34
+ training_type: pre-training
35
+ geographical_location: Germany
36
+ hardware_used: NVIDIA A100-SXM4-80GB
37
+ ---
38
+ # Tucano-1b1-Instruct
39
+
40
+ <img src="./logo.png" alt="An illustration of a Tucano bird showing vibrant colors like yellow, orange, blue, green, and black." height="200">
41
+
42
+ ## Model Summary
43
+
44
+ Tucano-1b1-Instruct is a fine-tuned version of [Tucano-1b1](https://huggingface.co/TucanoBR/Tucano-1b1). **[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.
45
+
46
+ Read our preprint [here](https://arxiv.org/abs/xxxx.xxxxx).
47
+
48
+ ## Details
49
+
50
+ - **Architecture:** a Transformer-based model pre-trained via causal language modeling
51
+ - **Size:** 1,100,048,384 parameters
52
+ - **Context length:** 2048 tokens
53
+ - **Dataset:** [nicholasKluge/instruct-aira-dataset-v3](https://huggingface.co/datasets/nicholasKluge/instruct-aira-dataset-v3),[cnmoro/GPT4-500k-Augmented-PTBR-Clean](https://huggingface.co/datasets/cnmoro/GPT4-500k-Augmented-PTBR-Clean), [rhaymison/orca-math-portuguese-64k](https://huggingface.co/datasets/rhaymison/orca-math-portuguese-64k)
54
+ - **Language:** Portuguese
55
+ - **Number of steps:** 20,000
56
+ - **GPU:** 8 NVIDIA A100-SXM4-80GB
57
+ - **Training time**: ~ 10 hours
58
+ - **Emissions:** 20 KgCO2 (Germany)
59
+ - **Total energy consumption:** 54 kWh
60
+
61
+ This repository has the [source code](https://github.com/Nkluge-correa/Tucano) used to train this model. The main libraries used are:
62
+
63
+ - [PyTorch](https://github.com/pytorch/pytorch)
64
+ - [Transformers](https://github.com/huggingface/transformers)
65
+ - [Datasets](https://github.com/huggingface/datasets)
66
+ - [Tokenizers](https://github.com/huggingface/tokenizers)
67
+ - [Sentencepiece](https://github.com/google/sentencepiece)
68
+ - [Accelerate](https://github.com/huggingface/accelerate)
69
+ - [FlashAttention](https://github.com/Dao-AILab/flash-attention)
70
+ - [Liger Kernel](https://github.com/linkedin/Liger-Kernel)
71
+ - [Codecarbon](https://github.com/mlco2/codecarbon)
72
+
73
+ ## Intended Uses
74
+
75
+ 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.
76
+
77
+ ## Out-of-scope Use
78
+
79
+ - 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.
80
+
81
+ - Tucano models are for **the Portuguese language only** and are unsuitable for text generation tasks in other languages.
82
+
83
+ - Tucano models have **not been fine-tuned** for downstream tasks.
84
+
85
+ ## Basic usage
86
+
87
+ Using the `pipeline`:
88
+
89
+ ```python
90
+ from transformers import pipeline
91
+
92
+ generator = pipeline("text-generation", model="TucanoBR/Tucano-1b1-Instruct")
93
+
94
+ completions = generator("<instruction>Qual cidade é a capital do estado do Rio Grande do Sul?</instruction>", num_return_sequences=2, max_new_tokens=100)
95
+
96
+ for comp in completions:
97
+ print(f"🤖 {comp['generated_text']}")
98
+ ```
99
+
100
+ Using the `AutoTokenizer` and `AutoModelForCausalLM`:
101
+
102
+ ```python
103
+ from transformers import AutoTokenizer, AutoModelForCausalLM
104
+ import torch
105
+
106
+ tokenizer = AutoTokenizer.from_pretrained("TucanoBR/Tucano-1b1-Instruct", revision='main')
107
+ model = AutoModelForCausalLM.from_pretrained("TucanoBR/Tucano-1b1-Instruct", revision='main')
108
+
109
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
110
+
111
+ model.eval()
112
+ model.to(device)
113
+
114
+ inputs = tokenizer("<instruction>Qual cidade é a capital do estado do Rio Grande do Sul?</instruction>", return_tensors="pt").to(device)
115
+
116
+ completions = model.generate(**inputs, num_return_sequences=2, max_new_tokens=100)
117
+
118
+ for i, completion in enumerate(completions):
119
+ print(f'🤖 {tokenizer.decode(completion)}')
120
+ ```
121
+
122
+ ## Limitations
123
+
124
+ 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:
125
+
126
+ - **Hallucinations:** Tucano models can produce content that can be mistaken as true facts, but are misleading or entirely false, i.e., hallucination.
127
+
128
+ - **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.
129
+
130
+ - **Unreliable Code:** Tucano models may produce incorrect code snippets and statements. These code generations should not be treated as suggestions or accurate solutions.
131
+
132
+ - **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.
133
+
134
+ - **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.
135
+
136
+ 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.
137
+
138
+ ## Evaluations
139
+
140
+ 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).
141
+
142
+ | | Average | Calame-PT | Lambada-PT | Enem | Bluex | OAB Exams | Assin2 RTE | Assin2 STS | FAQUAD-NLI | HateBR | HateSpeech-PT | TweetBR | ARC-PT | HellaSwag-PT | TruthfulQA-PT |
143
+ |-------------------------|---------|-----------|------------|-------|-------|-----------|------------|------------|------------|--------|---------------|---------|--------|--------------|---------------|
144
+ | Llama-3.2-3B | 52.38 | 58.43 | 49.1 | 53.04 | 50.35 | 39.45 | 83.64 | 33.19 | 43.97 | 74.58 | 41.99 | 61.43 | 43.25 | 57.2 | 43.64 |
145
+ | Llama-2-7b | 48.14 | 54.87 | 46.59 | 31.91 | 31.29 | 35.44 | 67.02 | 31.1 | 53.87 | 75.16 | 55.26 | 59.06 | 38.72 | 53.83 | 39.91 |
146
+ | Sabiá-7b | 48.03 | 60.79 | 49.16 | 55.07 | 47.71 | 41.41 | 46.68 | 1.89 | 58.34 | 61.93 | 64.13 | 46.64 | 43.25 | 61.98 | 33.39 |
147
+ | Gervásio-7b | 41.43 | 51.83 | 44.34 | 21.34 | 21 | 26.29 | 83.15 | 69.55 | 18.59 | 53.8 | 47.24 | 14.21 | 37.26 | 52.9 | 38.57 |
148
+ | Llama-3.2-1B | 38.67 | 51.83 | 41.02 | 23.37 | 24.2 | 25.88 | 50.77 | 19.48 | 43.97 | 59.43 | 38.57 | 42.34 | 33.5 | 45.44 | 41.63 |
149
+ | **Tucano-1b1** | 36.45 | 58.24 | 34.7 | 21.41 | 23.37 | 25.97 | 60.82 | 24.63 | 43.97 | 29 | 41.19 | 32.18 | 30.43 | 42.84 | 41.59 |
150
+ | **Tucano-630m** | 34.16 | 56.55 | 33.13 | 19.17 | 24.76 | 25.28 | 57.79 | 1.99 | 43.97 | 53.73 | 30.01 | 20.73 | 28.89 | 39.41 | 42.76 |
151
+ | **Tucano-1b1-Instruct** | 33.66 | 56.74 | 34.66 | 21.06 | 24.61 | 26.2 | 33.42 | 0.87 | 43.97 | 33.33 | 41.23 | 40.65 | 30.6 | 42.83 | 41.17 |
152
+ | Bloom-1b1 | 33.04 | 52.94 | 30.22 | 19.87 | 22.11 | 24.74 | 54.32 | 14.64 | 43.97 | 38.45 | 35.64 | 15.07 | 29.83 | 39.74 | 41.04 |
153
+ | Bloom-1b7 | 32.88 | 55.64 | 31.98 | 18.96 | 21.42 | 23.05 | 53.6 | 4.81 | 43.97 | 34.89 | 41.23 | 15.07 | 30.34 | 43.52 | 41.86 |
154
+ | Xglm-564m | 31.42 | 50.58 | 27.42 | 19.03 | 19.75 | 23.55 | 49.9 | 23.35 | 43.97 | 33.99 | 24.9 | 20.73 | 25.56 | 34.64 | 42.53 |
155
+ | TTL-460m | 31.14 | 49.42 | 23.29 | 20.15 | 25.73 | 27.02 | 53.61 | 13 | 46.41 | 33.59 | 22.99 | 17.28 | 29.4 | 33 | 41.1 |
156
+ | TTL-160m | 29.86 | 46.72 | 20.98 | 19.24 | 23.09 | 22.37 | 53.97 | 0.24 | 43.97 | 36.92 | 42.63 | 11.39 | 26.15 | 29.29 | 41.12 |
157
+ | **Tucano-160m** | 29.52 | 52.31 | 28.16 | 19.03 | 22.11 | 25.1 | 33.51 | 11.02 | 43.97 | 36.56 | 22.99 | 16.86 | 27.01 | 33.07 | 41.53 |
158
+ | Bloom-560m | 29.19 | 49.95 | 25.44 | 19.03 | 18.92 | 23.05 | 33.33 | 8.48 | 43.97 | 37.07 | 24.29 | 20.74 | 24.74 | 37.15 | 42.44 |
159
+ | GPorTuguese | 25.14 | 40.61 | 22.98 | 19.31 | 21.42 | 3.14 | 33.59 | 3.44 | 43.97 | 33.33 | 22.99 | 13.62 | 22.48 | 29.62 | 41.44 |
160
+ | mGPT-1b3 | 18.1 | 47.14 | 29.92 | 16.66 | 10.43 | 8.56 | 0 | 0.58 | 0 | 10.79 | 28.12 | 11.36 | 23.81 | 26.37 | 39.62 |
161
+ | GlórIA-1b3 | 15.96 | 52.79 | 27.71 | 1.89 | 3.2 | 5.19 | 0 | 2.32 | 0.26 | 0.28 | 23.52 | 0.19 | 26.67 | 37.04 | 42.44 |
162
+
163
+ ## Cite as 🤗
164
+
165
+ ```latex
166
+ @misc{correa24tucano,
167
+ title = {{Tucano: Advancing Neural Text Generation for Portuguese}},
168
+ author = {Corr{\^e}a, Nicholas Kluge and Sen, Aniket and Falk, Sophia and Fatimah, Shiza},
169
+ journal={arXiv preprint arXiv:xxxx.xxxxx},
170
+ year={2024}
171
+ }
172
+ ```
173
+
174
+ ## Aknowlegments
175
+
176
+ 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.
177
+
178
+ ## License
179
+
180
+ Tucano is licensed under the Apache License, Version 2.0. For more details, see the [LICENSE](./LICENSE) file.