Sabiá-7B is Portuguese language model developed by Maritaca AI.
Input: The model accepts only text input.
Output: The Model generates text only.
Model Architecture: Sabiá-7B is an auto-regressive language model that uses the same architecture of LLaMA-1-7B.
Tokenizer: It uses the same tokenizer as LLaMA-1-7B.
Maximum sequence length: 2048 tokens.
Pretraining data: The model was pretrained on 7 billion tokens from the Portuguese subset of ClueWeb22, starting with the weights of LLaMA-1-7B and further trained for an additional 10 billion tokens, approximately 1.4 epochs of the training dataset.
Data Freshness: The pretraining data has a cutoff of mid-2022.
License: The licensing is the same as LLaMA-1's, restricting the model's use to research purposes only.
Given that Sabiá-7B was trained solely on a language modeling objective without fine-tuning for instruction following, it is recommended for few-shot tasks rather than zero-shot tasks, like in the example below.
python
1import torch
2from transformers import LlamaTokenizer, LlamaForCausalLM
34tokenizer = LlamaTokenizer.from_pretrained("maritaca-ai/sabia-7b")5model = LlamaForCausalLM.from_pretrained(6"maritaca-ai/sabia-7b",7 device_map="auto",# Automatically loads the model in the GPU, if there is one. Requires pip install acelerate8 low_cpu_mem_usage=True,9 torch_dtype=torch.bfloat16 # If your GPU does not support bfloat16, change to torch.float1610)1112prompt ="""Classifique a resenha de filme como "positiva" ou "negativa".
1314Resenha: Gostei muito do filme, é o melhor do ano!
15Classe: positiva
1617Resenha: O filme deixa muito a desejar.
18Classe: negativa
1920Resenha: Apesar de longo, valeu o ingresso.
21Classe:"""2223input_ids = tokenizer(prompt, return_tensors="pt")2425output = model.generate(26 input_ids["input_ids"].to("cuda"),27 max_length=1024,28 eos_token_id=tokenizer.encode("\n"))# Stop generation when a "\n" token is dectected2930# The output contains the input tokens, so we have to skip them.31output = output[0][len(input_ids["input_ids"][0]):]3233print(tokenizer.decode(output, skip_special_tokens=True))
If your GPU does not have enough RAM, try using int8 precision.
However, expect some degradation in the model output quality when compared to fp16 or bf16.
Below we show the results on the Poeta benchmark, which consists of 14 Portuguese datasets.
For more information on the Normalized Preferred Metric (NPM), please refer to our paper.
Model
NPM
LLaMA-1-7B
33.0
LLaMA-2-7B
43.7
Sabiá-7B
48.5
Results in English
Below we show the average results on 6 English datasets: PIQA, HellaSwag, WinoGrande, ARC-e, ARC-c, and OpenBookQA.
Model
NPM
LLaMA-1-7B
50.1
Sabiá-7B
49.0
Citation
Please use the following bibtex to cite our paper:
@InProceedings{10.1007/978-3-031-45392-2_15,
author="Pires, Ramon
and Abonizio, Hugo
and Almeida, Thales Sales
and Nogueira, Rodrigo",
editor="Naldi, Murilo C.
and Bianchi, Reinaldo A. C.",
title="Sabi{\'a}: Portuguese Large Language Models",
booktitle="Intelligent Systems",
year="2023",
publisher="Springer Nature Switzerland",
address="Cham",
pages="226--240",
isbn="978-3-031-45392-2"
}