Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- pt
|
4 |
+
metrics:
|
5 |
+
- accuracy
|
6 |
+
- f1
|
7 |
+
- pearsonr
|
8 |
+
base_model:
|
9 |
+
- Qwen/Qwen2.5-1.5B-Instruct
|
10 |
+
pipeline_tag: text-generation
|
11 |
+
library_name: transformers
|
12 |
+
tags:
|
13 |
+
- text-generation-inference
|
14 |
+
license: apache-2.0
|
15 |
+
---
|
16 |
+
|
17 |
+
### Amadeus-Verbo-FI-Qwen2.5-1.5B-PT-BR-Instruct
|
18 |
+
#### Introduction
|
19 |
+
Amadeus-Verbo-FI-Qwen2.5-1.5B-PT-BR-Instruct is a Brazilian-Portuguese language model (PT-BR-LLM) developed from the base model Qwen2.5-1.5B-Instruct through fine-tuning, for 2 epochs, with 600k instructions dataset.
|
20 |
+
Read our article [here](https://www.).
|
21 |
+
|
22 |
+
## Details
|
23 |
+
|
24 |
+
- **Architecture:** a Transformer-based model with RoPE, SwiGLU, RMSNorm, and Attention QKV bias pre-trained via Causal Language Modeling
|
25 |
+
- **Parameters:** 1.54B parameters
|
26 |
+
- **Number of Parameters (Non-Embedding):** 1.31B
|
27 |
+
- **Number of Layers:** 28
|
28 |
+
- **Number of Attention Heads (GQA):** 12 for Q and 2 for KV
|
29 |
+
- **Context length:** 32,768 tokens
|
30 |
+
- **Number of steps:** 78838
|
31 |
+
- **Language:** Brazilian Portuguese
|
32 |
+
|
33 |
+
#### Usage
|
34 |
+
|
35 |
+
You can use Amadeus-Verbo-FI-Qwen2.5-1.5B-PT-BR-Instruct with the latest HuggingFace Transformers library and we advise you to use the latest version of Transformers.
|
36 |
+
|
37 |
+
With transformers<4.37.0, you will encounter the following error:
|
38 |
+
|
39 |
+
KeyError: 'qwen2'
|
40 |
+
|
41 |
+
Below, we have provided a simple example of how to load the model and generate text:
|
42 |
+
|
43 |
+
#### Quickstart
|
44 |
+
The following code snippet uses `pipeline`, `AutoTokenizer`, `AutoModelForCausalLM` and apply_chat_template to show how to load the tokenizer, the model, and how to generate content.
|
45 |
+
|
46 |
+
Using the pipeline:
|
47 |
+
```python
|
48 |
+
from transformers import pipeline
|
49 |
+
|
50 |
+
messages = [
|
51 |
+
{"role": "user", "content": "Faça uma planilha nutricional para uma alimentação fitness e mediterrânea com todos os dias da semana"},
|
52 |
+
]
|
53 |
+
pipe = pipeline("text-generation", model="amadeusai/AV-FI-Qwen2.5-1.5B-PT-BR-Instruct")
|
54 |
+
pipe(messages)
|
55 |
+
```
|
56 |
+
OR
|
57 |
+
```python
|
58 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
59 |
+
|
60 |
+
model_name = "amadeusai/AV-FI-Qwen2.5-1.5B-PT-BR-Instruct"
|
61 |
+
|
62 |
+
model = AutoModelForCausalLM.from_pretrained(
|
63 |
+
model_name,
|
64 |
+
torch_dtype="auto",
|
65 |
+
device_map="auto"
|
66 |
+
)
|
67 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
68 |
+
|
69 |
+
prompt = "Faça uma planilha nutricional para uma alimentação fitness e mediterrânea com todos os dias da semana."
|
70 |
+
messages = [
|
71 |
+
{"role": "system", "content": "Você é um assistente útil."},
|
72 |
+
{"role": "user", "content": prompt}
|
73 |
+
]
|
74 |
+
text = tokenizer.apply_chat_template(
|
75 |
+
messages,
|
76 |
+
tokenize=False,
|
77 |
+
add_generation_prompt=True
|
78 |
+
)
|
79 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
80 |
+
|
81 |
+
generated_ids = model.generate(
|
82 |
+
**model_inputs,
|
83 |
+
max_new_tokens=512
|
84 |
+
)
|
85 |
+
generated_ids = [
|
86 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
87 |
+
]
|
88 |
+
|
89 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
90 |
+
```
|
91 |
+
OR
|
92 |
+
```python
|
93 |
+
from transformers import GenerationConfig, TextGenerationPipeline, AutoTokenizer, AutoModelForCausalLM
|
94 |
+
import torch
|
95 |
+
|
96 |
+
# Specify the model and tokenizer
|
97 |
+
model_id = "amadeusai/AV-FI-Qwen2.5-1.5B-PT-BR-Instruct"
|
98 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
99 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
100 |
+
|
101 |
+
# Specify the generation parameters as you like
|
102 |
+
generation_config = GenerationConfig(
|
103 |
+
**{
|
104 |
+
"do_sample": True,
|
105 |
+
"max_new_tokens": 512,
|
106 |
+
"renormalize_logits": True,
|
107 |
+
"repetition_penalty": 1.2,
|
108 |
+
"temperature": 0.1,
|
109 |
+
"top_k": 50,
|
110 |
+
"top_p": 1.0,
|
111 |
+
"use_cache": True,
|
112 |
+
}
|
113 |
+
)
|
114 |
+
|
115 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
116 |
+
generator = TextGenerationPipeline(model=model, task="text-generation", tokenizer=tokenizer, device=device)
|
117 |
+
|
118 |
+
# Generate text
|
119 |
+
prompt = "Faça uma planilha nutricional para uma alimentação fitness e mediterrânea com todos os dias da semana"
|
120 |
+
completion = generator(prompt, generation_config=generation_config)
|
121 |
+
print(completion[0]['generated_text'])
|
122 |
+
```
|
123 |
+
|
124 |
+
#### Citation
|
125 |
+
|
126 |
+
If you find our work helpful, feel free to cite it.
|
127 |
+
```
|
128 |
+
@misc{Amadeus AI,
|
129 |
+
title = {Amadeus Verbo: A Brazilian Portuguese large language model.},
|
130 |
+
url = {https://amadeus-ai.com},
|
131 |
+
author = {Amadeus AI},
|
132 |
+
month = {November},
|
133 |
+
year = {2024}
|
134 |
+
}
|
135 |
+
```
|