Text Generation
Transformers
PyTorch
Safetensors
Portuguese
llama
LLM
Portuguese
Llama 2
Eval Results (legacy)
text-generation-inference
Instructions to use dominguesm/Canarim-7B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dominguesm/Canarim-7B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dominguesm/Canarim-7B-Instruct")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("dominguesm/Canarim-7B-Instruct") model = AutoModelForCausalLM.from_pretrained("dominguesm/Canarim-7B-Instruct", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use dominguesm/Canarim-7B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dominguesm/Canarim-7B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dominguesm/Canarim-7B-Instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/dominguesm/Canarim-7B-Instruct
- SGLang
How to use dominguesm/Canarim-7B-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "dominguesm/Canarim-7B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dominguesm/Canarim-7B-Instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "dominguesm/Canarim-7B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dominguesm/Canarim-7B-Instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use dominguesm/Canarim-7B-Instruct with Docker Model Runner:
docker model run hf.co/dominguesm/Canarim-7B-Instruct
| 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| | |