| --- |
| 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-Instruct |
| 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: 27.5 |
| name: accuracy |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| 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: 26.15 |
| name: accuracy |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| 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: 29.93 |
| name: accuracy |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| 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: 75.74 |
| name: f1-macro |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| 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: 12.08 |
| name: pearson |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| 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.92 |
| name: f1-macro |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| 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: 79.57 |
| name: f1-macro |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| 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: 64.01 |
| name: f1-macro |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| 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: 66.0 |
| name: f1-macro |
| source: |
| url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=dominguesm/Canarim-7B-Instruct |
| name: Open Portuguese LLM Leaderboard |
| --- |
| |
| <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-Instruct |
|
|
| Canarim-7B-Instruct is a 7 billion parameter language model, initialized from the [Canarim-7B](https://huggingface.co/dominguesm/canarim-7b) model and trained on a variety of publicly available instruction datasets. |
|
|
| ## Usage |
|
|
| ```python |
| from transformers import AutoTokenizer, pipeline |
| import torch |
| |
| model_id = "dominguesm/Canarim-7B-Instruct" |
| |
| tokenizer = AutoTokenizer.from_pretrained(model_id) |
| pipe = pipeline( |
| "text-generation", |
| model=model_id, |
| torch_dtype=torch.float16, |
| device_map="auto", |
| ) |
| |
| |
| def make_prompt(instruction, input=None): |
| if input: |
| return f"""Abaixo está uma instrução que descreve uma tarefa, emparelhada com uma entrada que fornece mais contexto. Escreva uma resposta que conclua adequadamente a solicitação. |
| |
| ### Instruções: |
| {instruction} |
| |
| ### Entrada: |
| {input} |
| |
| ### Resposta:""" |
| else: |
| return f"""Abaixo está uma instrução que descreve uma tarefa. Escreva uma resposta que conclua adequadamente a solicitação. |
| |
| ### Instruções: |
| {instruction} |
| |
| ### Resposta:""" |
| |
| instruction = "Faça um resumo conciso do seguinte texto." |
| context = """ |
| No início da obra, o narrador Bentinho explica como escolheu o título para o seu livro. Assim, ele conta que conheceu um poeta em uma viagem de trem. O jovem recitou alguns versos, mas Bentinho, já velho, fechou os olhos algumas vezes. O poeta, então, achou que ele estava cochilando e, ofendido, lhe chamou de Dom Casmurro. |
| |
| Em seguida, o narrador inicia a narrativa de suas memórias, que começa quando ele tem 15 anos. Nessa época, Capitu, uma jovem de 14 anos, é sua vizinha. Os adolescentes têm uma forte amizade, o que incomoda o agregado da família, o amante de superlativos José Dias. |
| |
| Desconfiado da relação entre os jovens, ele sugere à D. Glória, mãe de Bentinho, que já é hora de enviar o rapaz para o seminário. Isso porque, quando o menino nasceu, sua mãe fez uma promessa de que ele seria padre. Dessa forma, se apresenta um obstáculo ao amor do jovem casal, o que, enganosamente, faz parecer que o livro é um romance romântico. |
| """ |
| |
| 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 |
| ) |
| ``` |
|
|
| ### Model Result |
|
|
| ``` |
| O trabalho retrata as memórias de Bentinho, um jovem de 15 anos. Ele conta |
| sobre sua infância na casa de seus pais, onde vive com sua mãe, a dona |
| Glória, e sua governanta, a governanta Josefa. No entanto, no outono de |
| 1860, sua vida mudará drasticamente. Durante essa temporada, ele conhece |
| Capitu, uma moça de 14 anos, que se tornará sua companheira por muitos anos. |
| ``` |
|
|
| **NOTE**: README under construction |
| # [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/dominguesm/Canarim-7B-Instruct) |
|
|
| | Metric | Value | |
| |--------------------------|---------| |
| |Average |**47.21**| |
| |ENEM Challenge (No Images)| 27.50| |
| |BLUEX (No Images) | 26.15| |
| |OAB Exams | 29.93| |
| |Assin2 RTE | 75.74| |
| |Assin2 STS | 12.08| |
| |FaQuAD NLI | 43.92| |
| |HateBR Binary | 79.57| |
| |PT Hate Speech Binary | 64.01| |
| |tweetSentBR | 66| |
|
|
|
|