Instructions to use QuantFactory/sabia-7b-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use QuantFactory/sabia-7b-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/sabia-7b-GGUF", filename="sabia-7b.Q2_K.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/sabia-7b-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/sabia-7b-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/sabia-7b-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/sabia-7b-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/sabia-7b-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/sabia-7b-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/sabia-7b-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/sabia-7b-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/sabia-7b-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/sabia-7b-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use QuantFactory/sabia-7b-GGUF with Ollama:
ollama run hf.co/QuantFactory/sabia-7b-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/sabia-7b-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/sabia-7b-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/sabia-7b-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/sabia-7b-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/sabia-7b-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/sabia-7b-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/sabia-7b-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/sabia-7b-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.sabia-7b-GGUF-Q4_K_M
List all available models
lemonade list
QuantFactory/sabia-7b-GGUF
This is quantized version of maritaca-ai/sabia-7b created using llama.cpp
Original Model Card
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.
Paper: For more details, please refer to our paper: Sabiá: Portuguese Large Language Models
Few-shot Example
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.
import torch
from transformers import LlamaTokenizer, LlamaForCausalLM
tokenizer = LlamaTokenizer.from_pretrained("maritaca-ai/sabia-7b")
model = LlamaForCausalLM.from_pretrained(
"maritaca-ai/sabia-7b",
device_map="auto", # Automatically loads the model in the GPU, if there is one. Requires pip install acelerate
low_cpu_mem_usage=True,
torch_dtype=torch.bfloat16 # If your GPU does not support bfloat16, change to torch.float16
)
prompt = """Classifique a resenha de filme como "positiva" ou "negativa".
Resenha: Gostei muito do filme, é o melhor do ano!
Classe: positiva
Resenha: O filme deixa muito a desejar.
Classe: negativa
Resenha: Apesar de longo, valeu o ingresso.
Classe:"""
input_ids = tokenizer(prompt, return_tensors="pt")
output = model.generate(
input_ids["input_ids"].to("cuda"),
max_length=1024,
eos_token_id=tokenizer.encode("\n")) # Stop generation when a "\n" token is dectected
# The output contains the input tokens, so we have to skip them.
output = output[0][len(input_ids["input_ids"][0]):]
print(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.
model = LlamaForCausalLM.from_pretrained(
"maritaca-ai/sabia-7b",
device_map="auto",
low_cpu_mem_usage=True,
load_in_8bit=True, # Requires pip install bitsandbytes
)
Results in Portuguese
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"
}
Open Portuguese LLM Leaderboard Evaluation Results
Detailed results can be found here
| Metric | Value |
|---|---|
| Average | 47.09 |
| ENEM Challenge (No Images) | 55.07 |
| BLUEX (No Images) | 47.71 |
| OAB Exams | 41.41 |
| Assin2 RTE | 46.68 |
| Assin2 STS | 1.89 |
| FaQuAD NLI | 58.34 |
| HateBR Binary | 61.93 |
| PT Hate Speech Binary | 64.13 |
| tweetSentBR | 46.64 |
- Downloads last month
- 14
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
Paper for QuantFactory/sabia-7b-GGUF
Evaluation results
- accuracy on ENEM Challenge (No Images)Open Portuguese LLM Leaderboard55.070
- accuracy on BLUEX (No Images)Open Portuguese LLM Leaderboard47.710
- accuracy on OAB ExamsOpen Portuguese LLM Leaderboard41.410
- f1-macro on Assin2 RTEtest set Open Portuguese LLM Leaderboard46.680
- pearson on Assin2 STStest set Open Portuguese LLM Leaderboard1.890
- f1-macro on FaQuAD NLItest set Open Portuguese LLM Leaderboard58.340
- f1-macro on HateBR Binarytest set Open Portuguese LLM Leaderboard61.930
- f1-macro on PT Hate Speech Binarytest set Open Portuguese LLM Leaderboard64.130
- f1-macro on tweetSentBRtest set Open Portuguese LLM Leaderboard46.640