File size: 13,672 Bytes
164707c
3b52fa4
 
 
 
164707c
f5bbea2
 
1d32322
 
 
f5bbea2
 
3b52fa4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa5879c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164707c
 
 
 
 
 
 
 
 
11f68f2
164707c
11f68f2
164707c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18d34bd
f4789cb
d5240c6
f4789cb
98567cb
f4789cb
 
 
 
 
 
 
 
98567cb
f4789cb
18d34bd
 
 
 
 
 
 
 
 
 
 
 
 
 
164707c
 
3b52fa4
fa5879c
a72b271
 
 
fa5879c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a72b271
fa5879c
3b52fa4
 
 
 
 
 
 
 
 
 
 
 
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
---
language:
- pt
license: llama2
library_name: transformers
tags:
- text-generation
- pytorch
- LLM
- Portuguese
- Llama 2
datasets:
- dominguesm/CC-MAIN-2023-23
inference: false
pipeline_tag: text-generation
model-index:
- name: canarim-7b
  results:
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: AI2 Reasoning Challenge (25-Shot)
      type: ai2_arc
      config: ARC-Challenge
      split: test
      args:
        num_few_shot: 25
    metrics:
    - type: acc_norm
      value: 51.96
      name: normalized accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: HellaSwag (10-Shot)
      type: hellaswag
      split: validation
      args:
        num_few_shot: 10
    metrics:
    - type: acc_norm
      value: 77.52
      name: normalized accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: MMLU (5-Shot)
      type: cais/mmlu
      config: all
      split: test
      args:
        num_few_shot: 5
    metrics:
    - type: acc
      value: 40.92
      name: accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: TruthfulQA (0-shot)
      type: truthful_qa
      config: multiple_choice
      split: validation
      args:
        num_few_shot: 0
    metrics:
    - type: mc2
      value: 40.03
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: Winogrande (5-shot)
      type: winogrande
      config: winogrande_xl
      split: validation
      args:
        num_few_shot: 5
    metrics:
    - type: acc
      value: 71.43
      name: accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: GSM8k (5-shot)
      type: gsm8k
      config: main
      split: test
      args:
        num_few_shot: 5
    metrics:
    - type: acc
      value: 9.93
      name: accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: ENEM (3-shot)
      type: enem_challenge
      config: main
      split: test
      args:
        num_few_shot: 3
    metrics:
    - type: acc
      value: 26.96
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: BLUEX (3-shot)
      type: bluex
      config: main
      split: test
      args:
        num_few_shot: 3
    metrics:
    - type: acc
      value: 29.76
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: OAB Exams (3-shot)
      type: oab_exams
      config: main
      split: test
      args:
        num_few_shot: 3
    metrics:
    - type: acc
      value: 31.48
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: ASSIN2 RTE (15-shot)
      type: assin2_rte
      config: main
      split: test
      args:
        num_few_shot: 15
    metrics:
    - type: acc
      value: 71.96
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: ASSIN2 STS (15-shot)
      type: assin2_sts
      config: main
      split: test
      args:
        num_few_shot: 15
    metrics:
    - type: acc
      value: 13.33
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: FAQUAD NLI (15-shot)
      type: faquad_nli
      config: main
      split: test
      args:
        num_few_shot: 15
    metrics:
    - type: acc
      value: 49.09
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: HateBR (25-shot)
      type: hatebr_offensive
      config: main
      split: test
      args:
        num_few_shot: 25
    metrics:
    - type: acc
      value: 78.48
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: PT Hate Speech (25-shot)
      type: portuguese_hate_speech
      config: main
      split: test
      args:
        num_few_shot: 25
    metrics:
    - type: acc
      value: 63.73
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: tweetSentBR (25-shot)
      type: tweetsentbr
      config: main
      split: test
      args:
        num_few_shot: 25
    metrics:
    - type: acc
      value: 62.38
      name: accuracy
    source:
      url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/canarim-7b
      name: Open PT LLM Leaderboard Evaluation Results
---


<p align="center">
  <img width="250" alt="Camarim Logo" src="https://raw.githubusercontent.com/DominguesM/Canarim-Instruct-PTBR/main/assets/canarim.png">
</p>

<hr>

# Canarim-7B

Canarim-7B is a Portuguese large language model developed by [Maicon Domingues](https://nlp.rocks).

## Model description

The model was pretrained on 16 billion tokens from the Portuguese subset of [CommonCrawl 2023-23](https://huggingface.co/datasets/dominguesm/CC-MAIN-2023-23), starting with the weights of LLaMA2-7B. The pretraining data has cutoff of mid-2023.

## Key Features

-   **Language:** Specialized in understanding and generating Portuguese text, making it ideal for applications targeting Portuguese-speaking audiences.
-   **Architecture:** Inherits the robust architecture from LLaMA2-7B, ensuring efficient performance and accurate results.
-   **Diverse Dataset:** The pretraining dataset includes a wide range of topics and writing styles, enhancing the model's ability to understand various contexts and nuances in Portuguese.

## Applications

Canarim-7B, was trained solely on a language modeling objective and has not been fine-tuned for instruction following. Therefore, it is more suited for few-shot tasks rather than zero-shot tasks. This means the model tends to perform better when provided with a few examples of the desired outcome during use. Here are some practical applications:

-   **Natural Language Understanding (NLU):** Efficient in tasks such as sentiment analysis, topic classification, and entity recognition in Portuguese text, especially when relevant examples are provided.
-   **Natural Language Generation (NLG):** Capable of generating coherent and contextually relevant text, useful for content creation, chatbots, and more, with improved results when provided examples of the desired style or format.
-   **Language Translation:** Suitable for high-quality translation between Portuguese and other languages, especially when examples of desired translations are included during model training or fine-tuning.

### Tips for Efficient Use

-   **Few-shot Learning:** When using Canarim-7B for specific tasks, it is beneficial to provide a few relevant examples. This helps the model better understand the context and purpose of the task.
-   **Contextualization:** Including additional context in the input can significantly improve the quality of the model’s predictions and text generation.

---

## Getting Started

To start using Canarim-7B with the Transformers library, first install the library if you haven't already:

```bash
pip install transformers
```

You can then load the model using the Transformers library. Here's a simple example of how to use the model for text generation using the `pipeline` function:

```python
from transformers import AutoTokenizer, pipeline
import torch

model_id = "dominguesm/canarim-7b"
tokenizer = AutoTokenizer.from_pretrained(model_id)

pipe = pipeline(
    "text-generation",
    model=model_id,
    torch_dtype=torch.float16,
    device_map="auto",
)

prompt = make_prompt(question)
sequences = pipe(
   prompt,
   do_sample=True,
   num_return_sequences=1,
   eos_token_id=tokenizer.eos_token_id,
   max_length=2048,
   temperature=0.9,
   top_p=0.6,
   repetition_penalty=1.15
)
```

This code snippet demonstrates how to generate text with Canarim-7B. You can customize the input text and adjust parameters like `max_length` according to your requirements.

## How to Cite

If you want to cite **Canarim-7B**, you could use this:

```
@misc {maicon_domingues_2023,
	author       = { {Maicon Domingues} },
	title        = { canarim-7b (Revision 08fdd2b) },
	year         = 2023,
	url          = { https://huggingface.co/dominguesm/canarim-7b },
	doi          = { 10.57967/hf/1356 },
	publisher    = { Hugging Face }
}
```


## Citations

```bibtex
@misc{touvron2023llama,
      title={Llama 2: Open Foundation and Fine-Tuned Chat Models},
      author={Hugo Touvron and Louis Martin and Kevin Stone and Peter Albert and Amjad Almahairi and Yasmine Babaei and Nikolay Bashlykov and Soumya Batra and Prajjwal Bhargava and Shruti Bhosale and Dan Bikel and Lukas Blecher and Cristian Canton Ferrer and Moya Chen and Guillem Cucurull and David Esiobu and Jude Fernandes and Jeremy Fu and Wenyin Fu and Brian Fuller and Cynthia Gao and Vedanuj Goswami and Naman Goyal and Anthony Hartshorn and Saghar Hosseini and Rui Hou and Hakan Inan and Marcin Kardas and Viktor Kerkez and Madian Khabsa and Isabel Kloumann and Artem Korenev and Punit Singh Koura and Marie-Anne Lachaux and Thibaut Lavril and Jenya Lee and Diana Liskovich and Yinghai Lu and Yuning Mao and Xavier Martinet and Todor Mihaylov and Pushkar Mishra and Igor Molybog and Yixin Nie and Andrew Poulton and Jeremy Reizenstein and Rashi Rungta and Kalyan Saladi and Alan Schelten and Ruan Silva and Eric Michael Smith and Ranjan Subramanian and Xiaoqing Ellen Tan and Binh Tang and Ross Taylor and Adina Williams and Jian Xiang Kuan and Puxin Xu and Zheng Yan and Iliyan Zarov and Yuchen Zhang and Angela Fan and Melanie Kambadur and Sharan Narang and Aurelien Rodriguez and Robert Stojnic and Sergey Edunov and Thomas Scialom},
      year={2023},
      eprint={2307.09288},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
```

## License

Canarim-7B is released under the [LLAMA 2 COMMUNITY LICENSE AGREEMENT](https://ai.meta.com/llama/license/).

## [Open PT 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/dominguesm/canarim-7b)

|             Metric              |Value|
|---------------------------------|----:|
|Avg.                             |47.36|
|ENEM (3-Shot)                    |25.96|
|BLUEX (3-Shot)                   |29.76|
|OAB Exams (3-Shot)               |31.48|
|ASSIN2 RTE (15-shot)             |71.96|
|ASSIN2 STS (15-shot)             |13.33|
|FAQUAD NLI (15-shot)             |49.09|
|HateBR (25-shot)                 |78.48|
|PT Hate Speech (25-shot)         |63.73|
|tweetSentBR (25-shot)            |62.38|


## [Open LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)

Detailed results can be found [here](https://huggingface.co/datasets/open-llm-leaderboard/details_dominguesm__canarim-7b)

|             Metric              |Value|
|---------------------------------|----:|
|Avg.                             |48.63|
|AI2 Reasoning Challenge (25-Shot)|51.96|
|HellaSwag (10-Shot)              |77.52|
|MMLU (5-Shot)                    |40.92|
|TruthfulQA (0-shot)              |40.03|
|Winogrande (5-shot)              |71.43|
|GSM8k (5-shot)                   | 9.93|