🚀 gemma-portuguese-2b-luana
The gemma-portuguese-2b-luana is a Portuguese model specialized in text generation and instruction understanding. Trained on a superset dataset with 250,000 instructions, it focuses on understanding Portuguese inferences and can be fine - tuned for specific fields.
🚀 Quick Start
Prerequisites
Ensure you have transformers
and torch
installed in your Python environment.
Installation
pip install transformers torch
Usage Examples
Basic Usage
from transformers import AutoTokenizer, pipeline
import torch
model = "rhaymison/gemma-portuguese-luana-2b"
tokenizer = AutoTokenizer.from_pretrained(model)
pipeline = pipeline(
"text-generation",
model=model,
model_kwargs={"torch_dtype": torch.bfloat16},
device="cuda",
)
messages = [
{
"role": "system",
"content": "Abaixo está uma instrução que descreve uma tarefa, juntamente com uma entrada que fornece mais contexto. Escreva uma resposta que complete adequadamente o pedido."
},
{"role": "user", "content": "Me conte sobre a ida do homem a Lua."},
]
prompt = pipeline.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipeline(
prompt,
max_new_tokens=256,
do_sample=True,
temperature=0.2,
top_k=50,
top_p=0.95
)
print(outputs[0]["generated_text"][len(prompt):].replace("model",""))
Advanced Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer2 = AutoTokenizer.from_pretrained("rhaymison/gemma-portuguese-luana-2b")
model2 = AutoModelForCausalLM.from_pretrained("rhaymison/gemma-portuguese-luana-2b", device_map={"":0})
tokenizer2.pad_token = tokenizer2.eos_token
tokenizer2.add_eos_token = True
tokenizer2.add_bos_token, tokenizer2.add_eos_token
tokenizer2.padding_side = "right"
text = f"""<start_of_turn>user
Abaixo está uma instrução que descreve uma tarefa, juntamente com uma entrada que fornece mais contexto. Escreva uma resposta que complete adequadamente o pedido.
###instrução:Me explique como funciona um computador.<end_of_turn>
<start_of_turn>model """
device = "cuda:0"
inputs = tokenizer2(text, return_tensors="pt").to(device)
outputs = model2.generate(**inputs, max_new_tokens=256, do_sample=False)
output = tokenizer2.decode(outputs[0], skip_special_tokens=True, skip_prompt=True)
print(output.replace("model"," "))
📚 Documentation
Model description
Updated: 2024 - 04 - 10 20:06
The gemma - portuguese - 2b model is a Portuguese model trained with the superset dataset with 250,000 instructions. The model is mainly focused on text generation and instruction. The model was not trained on math and code tasks. The model is generalist with a focus on understanding Portuguese inferences. With this fine - tuning for Portuguese, you can adjust the model for a specific field.
Open Portuguese LLM Leaderboard Evaluation Results
Detailed results can be found here and on the 🚀 Open Portuguese LLM Leaderboard
Metric |
Value |
Average |
34.94 |
ENEM Challenge (No Images) |
24.42 |
BLUEX (No Images) |
24.34 |
OAB Exams |
27.11 |
Assin2 RTE |
70.86 |
Assin2 STS |
1.51 |
FaQuAD NLI |
43.97 |
HateBR Binary |
40.05 |
PT Hate Speech Binary |
51.83 |
tweetSentBR |
30.42 |
Comments
Any idea, help or report will always be welcome.
Email: rhaymisoncristian@gmail.com
📄 License
This project is licensed under the Apache - 2.0 license.