afrideva commited on
Commit
79b8d52
1 Parent(s): bb18b0d

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +389 -0
README.md ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: nicholasKluge/TeenyTinyLlama-460m-Chat
3
+ co2_eq_emissions:
4
+ emissions: 2.53
5
+ geographical_location: United States of America
6
+ hardware_used: NVIDIA A100-SXM4-40GB
7
+ source: CodeCarbon
8
+ training_type: fine-tuning
9
+ datasets:
10
+ - nicholasKluge/instruct-aira-dataset-v2
11
+ inference: true
12
+ language:
13
+ - pt
14
+ library_name: transformers
15
+ license: apache-2.0
16
+ metrics:
17
+ - accuracy
18
+ model-index:
19
+ - name: TeenyTinyLlama-460m-Chat
20
+ results:
21
+ - dataset:
22
+ args:
23
+ num_few_shot: 3
24
+ name: ENEM Challenge (No Images)
25
+ split: train
26
+ type: eduagarcia/enem_challenge
27
+ metrics:
28
+ - name: accuracy
29
+ type: acc
30
+ value: 20.29
31
+ source:
32
+ name: Open Portuguese LLM Leaderboard
33
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
34
+ task:
35
+ name: Text Generation
36
+ type: text-generation
37
+ - dataset:
38
+ args:
39
+ num_few_shot: 3
40
+ name: BLUEX (No Images)
41
+ split: train
42
+ type: eduagarcia-temp/BLUEX_without_images
43
+ metrics:
44
+ - name: accuracy
45
+ type: acc
46
+ value: 25.45
47
+ source:
48
+ name: Open Portuguese LLM Leaderboard
49
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
50
+ task:
51
+ name: Text Generation
52
+ type: text-generation
53
+ - dataset:
54
+ args:
55
+ num_few_shot: 3
56
+ name: OAB Exams
57
+ split: train
58
+ type: eduagarcia/oab_exams
59
+ metrics:
60
+ - name: accuracy
61
+ type: acc
62
+ value: 26.74
63
+ source:
64
+ name: Open Portuguese LLM Leaderboard
65
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
66
+ task:
67
+ name: Text Generation
68
+ type: text-generation
69
+ - dataset:
70
+ args:
71
+ num_few_shot: 15
72
+ name: Assin2 RTE
73
+ split: test
74
+ type: assin2
75
+ metrics:
76
+ - name: f1-macro
77
+ type: f1_macro
78
+ value: 43.77
79
+ source:
80
+ name: Open Portuguese LLM Leaderboard
81
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
82
+ task:
83
+ name: Text Generation
84
+ type: text-generation
85
+ - dataset:
86
+ args:
87
+ num_few_shot: 15
88
+ name: Assin2 STS
89
+ split: test
90
+ type: eduagarcia/portuguese_benchmark
91
+ metrics:
92
+ - name: pearson
93
+ type: pearson
94
+ value: 4.52
95
+ source:
96
+ name: Open Portuguese LLM Leaderboard
97
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
98
+ task:
99
+ name: Text Generation
100
+ type: text-generation
101
+ - dataset:
102
+ args:
103
+ num_few_shot: 15
104
+ name: FaQuAD NLI
105
+ split: test
106
+ type: ruanchaves/faquad-nli
107
+ metrics:
108
+ - name: f1-macro
109
+ type: f1_macro
110
+ value: 34.0
111
+ source:
112
+ name: Open Portuguese LLM Leaderboard
113
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
114
+ task:
115
+ name: Text Generation
116
+ type: text-generation
117
+ - dataset:
118
+ args:
119
+ num_few_shot: 25
120
+ name: HateBR Binary
121
+ split: test
122
+ type: ruanchaves/hatebr
123
+ metrics:
124
+ - name: f1-macro
125
+ type: f1_macro
126
+ value: 33.49
127
+ source:
128
+ name: Open Portuguese LLM Leaderboard
129
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
130
+ task:
131
+ name: Text Generation
132
+ type: text-generation
133
+ - dataset:
134
+ args:
135
+ num_few_shot: 25
136
+ name: PT Hate Speech Binary
137
+ split: test
138
+ type: hate_speech_portuguese
139
+ metrics:
140
+ - name: f1-macro
141
+ type: f1_macro
142
+ value: 22.99
143
+ source:
144
+ name: Open Portuguese LLM Leaderboard
145
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
146
+ task:
147
+ name: Text Generation
148
+ type: text-generation
149
+ - dataset:
150
+ args:
151
+ num_few_shot: 25
152
+ name: tweetSentBR
153
+ split: test
154
+ type: eduagarcia-temp/tweetsentbr
155
+ metrics:
156
+ - name: f1-macro
157
+ type: f1_macro
158
+ value: 18.13
159
+ source:
160
+ name: Open Portuguese LLM Leaderboard
161
+ url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=nicholasKluge/TeenyTinyLlama-460m-Chat
162
+ task:
163
+ name: Text Generation
164
+ type: text-generation
165
+ model_creator: nicholasKluge
166
+ model_name: TeenyTinyLlama-460m-Chat
167
+ pipeline_tag: text-generation
168
+ quantized_by: afrideva
169
+ tags:
170
+ - alignment
171
+ - instruction tuned
172
+ - text generation
173
+ - conversation
174
+ - assistant
175
+ - gguf
176
+ - ggml
177
+ - quantized
178
+ widget:
179
+ - example_title: Exemplo
180
+ text: <s><instruction>Cite algumas bandas de rock famosas da década de 1960.</instruction>
181
+ - example_title: Exemplo
182
+ text: <s><instruction>Quantos planetas existem no sistema solar?</instruction>
183
+ - example_title: Exemplo
184
+ text: <s><instruction>Qual é o futuro do ser humano?</instruction>
185
+ - example_title: Exemplo
186
+ text: <s><instruction>Qual o sentido da vida?</instruction>
187
+ - example_title: Exemplo
188
+ text: <s><instruction>Como imprimir hello world em python?</instruction>
189
+ - example_title: Exemplo
190
+ text: <s><instruction>Invente uma história sobre um encanador com poderes mágicos.</instruction>
191
+ ---
192
+
193
+ # TeenyTinyLlama-460m-Chat-GGUF
194
+
195
+ Quantized GGUF model files for [TeenyTinyLlama-460m-Chat](https://huggingface.co/nicholasKluge/TeenyTinyLlama-460m-Chat) from [nicholasKluge](https://huggingface.co/nicholasKluge)
196
+
197
+ ## Original Model Card:
198
+
199
+ # TeenyTinyLlama-460m-Chat
200
+
201
+ TeenyTinyLlama is a pair of small foundational models trained in Brazilian Portuguese.
202
+
203
+ This repository contains a version of [TeenyTinyLlama-460m](https://huggingface.co/nicholasKluge/TeenyTinyLlama-460m) (`TeenyTinyLlama-460m-Chat`) fine-tuned on the [Instruct-Aira Dataset version 2.0](https://huggingface.co/datasets/nicholasKluge/instruct-aira-dataset-v2).
204
+
205
+ ## Details
206
+
207
+ - **Number of Epochs:** 3
208
+ - **Batch size:** 4
209
+ - **Optimizer:** `torch.optim.AdamW` (warmup_steps = 1e3, learning_rate = 1e-5, epsilon = 1e-8)
210
+ - **GPU:** 1 NVIDIA A100-SXM4-40GB
211
+ - **Carbon emissions** stats are logged in this [file](emissions.csv).
212
+
213
+ This repository has the [source code](https://github.com/Nkluge-correa/TeenyTinyLlama) used to train this model.
214
+
215
+ ## Intended Uses
216
+
217
+ The primary intended use of TeenyTinyLlama is to research the challenges related to developing language models for low-resource languages. Checkpoints saved during training are intended to provide a controlled setting for performing scientific experiments. You may also further fine-tune and adapt TeenyTinyLlama for deployment, as long as your use is following the Apache 2.0 license. If you decide to use pre-trained TeenyTinyLlama as a basis for your fine-tuned model, please conduct your own risk and bias assessment.
218
+
219
+ ## Out-of-scope Use
220
+
221
+ TeenyTinyLlama is not intended for deployment. It is not a product and should not be used for human-facing interactions.
222
+
223
+ TeenyTinyLlama models are Brazilian Portuguese language only and are not suitable for translation or generating text in other languages.
224
+
225
+ TeenyTinyLlama has not been fine-tuned for downstream contexts in which language models are commonly deployed.
226
+
227
+ ## Usage
228
+
229
+ The following special tokens are used to mark the user side of the interaction and the model's response:
230
+
231
+ `<instruction>`What is a language model?`</instruction>`A language model is a probability distribution over a vocabulary.`</s>`
232
+
233
+ ```python
234
+ from transformers import AutoTokenizer, AutoModelForCausalLM
235
+ import torch
236
+
237
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
238
+
239
+ tokenizer = AutoTokenizer.from_pretrained('nicholasKluge/TeenyTinyLlama-460m-Chat')
240
+ model = AutoModelForCausalLM.from_pretrained('nicholasKluge/TeenyTinyLlama-460m-Chat')
241
+
242
+ model.eval()
243
+ model.to(device)
244
+
245
+ question = input("Entre seu prompt aqui: ")
246
+
247
+ inputs = tokenizer("<instruction>" + question + "</instruction>", return_tensors="pt").to(device)
248
+
249
+ responses = model.generate(**inputs, num_return_sequences=2)
250
+
251
+ print(f"Pergunta: 👤 {question}\n")
252
+
253
+ for i, response in enumerate(responses):
254
+ print(f'Resposta {i+1}: 🤖 {tokenizer.decode(response, skip_special_tokens=True).replace(question, "")}')
255
+ ```
256
+
257
+ The model will output something like:
258
+
259
+ ```markdown
260
+ >>>Question: 👤 Qual a capital do Brasil?
261
+
262
+ >>>Response 1: 🤖 A capital do Brasil é Brasília.
263
+ >>>Response 2: 🤖 A capital do Brasil é Brasília.
264
+ ```
265
+
266
+ The chat template for this model is:
267
+
268
+ ```bash
269
+ {{bos_token}}
270
+ {% for message in messages %}
271
+ {% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
272
+ {{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
273
+ {% endif %}
274
+ {% if message['role'] == 'user' %}
275
+ {{ '<instruction>' + message['content'].strip() + '</instruction>'}}
276
+ {% elif message['role'] == 'assistant' %}
277
+ {{ message['content'].strip() + eos_token}}
278
+ {% else %}
279
+ {{ raise_exception('Only user and assistant roles are supported!') }}
280
+ {% endif %}
281
+ {% endfor %}
282
+ ```
283
+
284
+ ## Limitations
285
+
286
+ Like almost all other language models trained on large text datasets scraped from the web, the TTL pair exhibited behavior that does not make them an out-of-the-box solution to many real-world applications, especially those requiring factual, reliable, nontoxic text generation. Our models are all subject to the following:
287
+
288
+ - **Hallucinations:** This model can produce content that can be mistaken for truth but is, in fact, misleading or entirely false, i.e., hallucination.
289
+
290
+ - **Biases and Toxicity:** This model inherits the social and historical stereotypes from the data used to train it. Given these biases, the model can produce toxic content, i.e., harmful, offensive, or detrimental to individuals, groups, or communities.
291
+
292
+ - **Unreliable Code:** The model may produce incorrect code snippets and statements. These code generations should not be treated as suggestions or accurate solutions.
293
+
294
+ - **Language Limitations:** The model is primarily designed to understand standard Brazilian Portuguese. Other languages might challenge its comprehension, leading to potential misinterpretations or errors in response.
295
+
296
+ - **Repetition and Verbosity:** The model 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.
297
+
298
+ Hence, even though our models are released with a permissive license, we urge users to perform their risk analysis on these models if intending to use them for real-world applications and 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.
299
+
300
+ ## Evaluations
301
+
302
+ During our training runs, both models showed consistent convergence. At no point did our evaluation curves show signs of overfitting or saturation. In the case of our 460m parameter model, we intentionally trained past the optimal point by approximately 75,000 steps to assess if there were any signs of saturation, but our evaluations consistently gave better results. We hypothesize that our models are under-trained but can improve if further trained to pass the Chinchilla optimal range.
303
+
304
+ | Processed Tokens | Perplexity | Energy Consumption (kWh) | Emissions (KgCO2eq) |
305
+ |------------------|------------|---------------------------|----------------------|
306
+ | 8.1M | 20.49 | 9.40 | 3.34 |
307
+ | 1.6B | 16.90 | 18.82 | 6.70 |
308
+ | 2.4B | 15.43 | 28.59 | 10.16 |
309
+ | 3.2B | 14.64 | 38.20 | 13.57 |
310
+ | 4.0B | 14.08 | 48.04 | 17.07 |
311
+ | 4.9B | 13.61 | 57.74 | 20.52 |
312
+ | 5.7B | 13.25 | 67.32 | 23.92 |
313
+ | 6.5B | 12.87 | 76.84 | 27.30 |
314
+ | 7.3B | 12.57 | 86.40 | 30.70 |
315
+ | 8.1B | 12.27 | 96.19 | 34.18 |
316
+ | 9.0B | 11.96 | 106.06 | 37.70 |
317
+ | 9.8B | 11.77 | 115.69 | 41.31 |
318
+
319
+ ## Benchmarks
320
+
321
+ Evaluations on benchmarks were performed using the [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) (by [EleutherAI](https://www.eleuther.ai/)). [Laiviet](https://github.com/laiviet/lm-evaluation-harness) translated the tasks from the LM-Evaluation-Harness we used. The results of models marked with an "*" were extracted from the [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
322
+
323
+ | | **ARC** | **HellaSwag** | **MMLU** | **TruthfulQA** | **Average** |
324
+ |------------------|-----------|---------------|-----------|----------------|-------------|
325
+ | Pythia-410m | 24.83* | 41.29* | 25.99* | 40.95* | 33.26 |
326
+ | **TTL-460m** | 29.40 | 33.00 | 28.55 | 41.10 | 33.01 |
327
+ | Bloom-560m | 24.74* | 37.15* | 24.22* | 42.44* | 32.13 |
328
+ | Xglm-564M | 25.56 | 34.64* | 25.18* | 42.53 | 31.97 |
329
+ | OPT-350m | 23.55* | 36.73* | 26.02* | 40.83* | 31.78 |
330
+ | **TTL-160m** | 26.15 | 29.29 | 28.11 | 41.12 | 31.16 |
331
+ | Pythia-160m | 24.06* | 31.39* | 24.86* | 44.34* | 31.16 |
332
+ | OPT-125m | 22.87* | 31.47* | 26.02* | 42.87* | 30.80 |
333
+ | GPorTuguese-2 | 22.48 | 29.62 | 27.36 | 41.44 | 30.22 |
334
+ | Gpt2-small | 21.48* | 31.60* | 25.79* | 40.65* | 29.97 |
335
+ | Multilingual GPT | 23.81 | 26.37* | 25.17* | 39.62 | 28.73 |
336
+
337
+ Evaluations on Brazilian Portuguese benchmarks were performed using a [Portuguese implementation of the EleutherAI LM Evaluation Harness](https://github.com/eduagarcia/lm-evaluation-harness-pt) (created by [Eduardo Garcia](https://github.com/eduagarcia/lm-evaluation-harness-pt)).
338
+
339
+ | | **ASSIN2 RTE** | **ASSIN2 STS** | **BLUEX** | **ENEM** | **FAQUAD NLI** | **HateBR** | **OAB Exams** | **Average** |
340
+ |----------------|----------------|----------------|-----------|----------|----------------|------------|---------------|-------------|
341
+ | Qwen-1.8B | 64.83 | 19.53 | 26.15 | 30.23 | 43.97 | 33.33 | 27.20 | 35.03 |
342
+ | TinyLlama-1.1B | 58.93 | 13.57 | 22.81 | 22.25 | 43.97 | 36.92 | 23.64 | 31.72 |
343
+ | **TTL-460m** | 53.93 | 12.66 | 22.81 | 19.87 | 49.01 | 33.59 | 27.06 | 31.27 |
344
+ | XGLM-564m | 49.61 | 22.91 | 19.61 | 19.38 | 43.97 | 33.99 | 23.42 | 30.41 |
345
+ | Bloom-1b7 | 53.60 | 4.81 | 21.42 | 18.96 | 43.97 | 34.89 | 23.05 | 28.67 |
346
+ | **TTL-160m** | 53.36 | 2.58 | 21.84 | 18.75 | 43.97 | 36.88 | 22.60 | 28.56 |
347
+ | OPT-125m | 39.77 | 2.00 | 21.84 | 17.42 | 43.97 | 47.04 | 22.78 | 27.83 |
348
+ | Pythia-160 | 33.33 | 12.81 | 16.13 | 16.66 | 50.36 | 41.09 | 22.82 | 27.60 |
349
+ | OLMo-1b | 34.12 | 9.28 | 18.92 | 20.29 | 43.97 | 41.33 | 22.96 | 27.26 |
350
+ | Bloom-560m | 33.33 | 8.48 | 18.92 | 19.03 | 43.97 | 37.07 | 23.05 | 26.26 |
351
+ | Pythia-410m | 33.33 | 4.80 | 19.47 | 19.45 | 43.97 | 33.33 | 23.01 | 25.33 |
352
+ | OPT-350m | 33.33 | 3.65 | 20.72 | 17.35 | 44.71 | 33.33 | 23.01 | 25.15 |
353
+ | GPT-2 small | 33.26 | 0.00 | 10.43 | 11.20 | 43.52 | 33.68 | 13.12 | 20.74 |
354
+ | GPorTuguese | 33.33 | 3.85 | 14.74 | 3.01 | 28.81 | 33.33 | 21.23 | 19.75 |
355
+ | Samba-1.1B | 33.33 | 1.30 | 8.07 | 10.22 | 17.72 | 35.79 | 15.03 | 17.35 |
356
+
357
+ ## Fine-Tuning Comparisons
358
+
359
+ To further evaluate the downstream capabilities of our models, we decided to employ a basic fine-tuning procedure for our TTL pair on a subset of tasks from the Poeta benchmark. We apply the same procedure for comparison purposes on both [BERTimbau](https://huggingface.co/neuralmind/bert-base-portuguese-cased) models, given that they are also LLM trained from scratch in Brazilian Portuguese and have a similar size range to our models. We used these comparisons to assess if our pre-training runs produced LLM capable of producing good results ("good" here means "close to BERTimbau") when utilized for downstream applications.
360
+
361
+ | Models | IMDB | FaQuAD-NLI | HateBr | Assin2 | AgNews | Average |
362
+ |-----------------|-----------|------------|-----------|-----------|-----------|---------|
363
+ | BERTimbau-large | **93.58** | 92.26 | 91.57 | **88.97** | 94.11 | 92.10 |
364
+ | BERTimbau-small | 92.22 | **93.07** | 91.28 | 87.45 | 94.19 | 91.64 |
365
+ | **TTL-460m** | 91.64 | 91.18 | **92.28** | 86.43 | **94.42** | 91.19 |
366
+ | **TTL-160m** | 91.14 | 90.00 | 90.71 | 85.78 | 94.05 | 90.34 |
367
+
368
+ All the shown results are the higher accuracy scores achieved on the respective task test sets after fine-tuning the models on the training sets. All fine-tuning runs used the same hyperparameters, and the code implementation can be found in the [model cards](https://huggingface.co/nicholasKluge/TeenyTinyLlama-460m-HateBR) of our fine-tuned models.
369
+
370
+ ## Cite as 🤗
371
+
372
+ ```latex
373
+
374
+ @misc{correa24ttllama,
375
+ title = {TeenyTinyLlama: open-source tiny language models trained in Brazilian Portuguese},
376
+ author = {Corr{\^e}a, Nicholas Kluge and Falk, Sophia and Fatimah, Shiza and Sen, Aniket and De Oliveira, Nythamar},
377
+ journal={arXiv preprint arXiv:2401.16640},
378
+ year={2024}
379
+ }
380
+
381
+ ```
382
+
383
+ ## Funding
384
+
385
+ This repository was built as part of the RAIES ([Rede de Inteligência Artificial Ética e Segura](https://www.raies.org/)) initiative, a project supported by FAPERGS - ([Fundação de Amparo à Pesquisa do Estado do Rio Grande do Sul](https://fapergs.rs.gov.br/inicial)), Brazil.
386
+
387
+ ## License
388
+
389
+ TeenyTinyLlama-460m-Chat is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more details.