Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,140 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
library_name: transformers
|
3 |
-
tags: []
|
4 |
---
|
5 |
|
6 |
-
#
|
7 |
|
8 |
-
|
|
|
|
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
|
|
11 |
|
12 |
-
## Model
|
13 |
|
14 |
-
|
|
|
15 |
|
16 |
-
|
|
|
17 |
|
18 |
-
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
##
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
41 |
|
42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
|
44 |
-
|
45 |
|
46 |
-
### Downstream Use [optional]
|
47 |
|
48 |
-
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
|
56 |
-
|
57 |
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
[More Information Needed]
|
63 |
-
|
64 |
-
### Recommendations
|
65 |
-
|
66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
-
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
-
|
70 |
-
## How to Get Started with the Model
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
|
103 |
## Evaluation
|
|
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
|
187 |
-
|
188 |
|
189 |
-
|
|
|
|
|
190 |
|
191 |
-
|
192 |
|
193 |
-
|
194 |
|
195 |
-
|
196 |
|
197 |
-
|
198 |
|
199 |
-
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- gl
|
4 |
+
- es
|
5 |
+
- en
|
6 |
+
- pt
|
7 |
+
licence:
|
8 |
+
- MIT
|
9 |
+
tags:
|
10 |
+
- Llama
|
11 |
+
license: llama3.1
|
12 |
+
base_model:
|
13 |
+
- meta-llama/Llama-3.1-8B
|
14 |
+
pipeline_tag: text-generation
|
15 |
library_name: transformers
|
|
|
16 |
---
|
17 |
|
18 |
+
# Llama-Carvalho-HQ_75
|
19 |
|
20 |
+
## Table of Contents
|
21 |
+
<details>
|
22 |
+
<summary>Click to expand</summary>
|
23 |
|
24 |
+
- [Llama-Carvalho-HQ\_75](#llama-carvalho-hq_75)
|
25 |
+
- [Table of Contents](#table-of-contents)
|
26 |
+
- [Model description](#model-description)
|
27 |
+
- [Intended uses and limitations](#intended-uses-and-limitations)
|
28 |
+
- [How to use](#how-to-use)
|
29 |
+
- [Training](#training)
|
30 |
+
- [Tools](#tools)
|
31 |
+
- [Training data](#training-data)
|
32 |
+
- [Training hyperparameters](#training-hyperparameters)
|
33 |
+
- [Framework](#framework)
|
34 |
+
- [Evaluation](#evaluation)
|
35 |
+
- [Additional information](#additional-information)
|
36 |
+
- [Contact](#contact)
|
37 |
+
- [License](#license)
|
38 |
+
- [Funding](#funding)
|
39 |
|
40 |
+
</details>
|
41 |
|
42 |
+
## Model description
|
43 |
|
44 |
+
**Llama-Carvalho-HQ** is a 8B-parameter transformer-based causal language model for Galician, Portuguese, Spanish and English.
|
45 |
+
It is the result of a continual pretraining of [meta-llama/Llama-3.1-8B](https://huggingface.co/meta-llama/Llama-3.1-8B) with a multilingual corpus consisting of 540M tokens of plain text and 72M tokens of instructions (formated as plain text)
|
46 |
|
47 |
+
This model is part of the **Carvalho familily**, a family of LLMs specialized in Portuguese and Galician. Smaller models can be found [here](https://huggingface.co/Nos-PT/Carvalho_pt-gl-1.3B)
|
48 |
+
## Intended uses and limitations
|
49 |
|
50 |
+
The **Llama-Carvalho-HQ** model is ready-to-use only for causal language modeling.
|
51 |
+
It can perform text-generation tasks and be fine-tuned for specific scenarios.
|
52 |
|
53 |
+
## How to use
|
54 |
+
```python
|
55 |
+
import torch
|
56 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
|
|
|
|
|
|
|
57 |
|
58 |
+
input_text = "Hoxe fai un bo d铆a. O sol "
|
59 |
|
60 |
+
model_id = "Nos-PT/Llama-Carvalho-HQ_75"
|
61 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
62 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
63 |
+
generator = pipeline(
|
64 |
+
"text-generation",
|
65 |
+
model=model,
|
66 |
+
tokenizer=tokenizer,
|
67 |
+
torch_dtype=torch.bfloat16,
|
68 |
+
trust_remote_code=True,
|
69 |
+
device_map="auto",
|
70 |
+
)
|
71 |
+
generation = generator(
|
72 |
+
input_text,
|
73 |
+
do_sample=True,
|
74 |
+
top_k=10,
|
75 |
+
eos_token_id=tokenizer.eos_token_id
|
76 |
+
)
|
77 |
|
78 |
+
print(f"Result: {generation[0]['generated_text']}")
|
79 |
+
```
|
|
|
80 |
|
81 |
+
## Training
|
82 |
|
83 |
+
### Tools
|
84 |
|
85 |
+
It was trained using HuggingFace Transformers and Pytorch, using the [Causal Modeling Language script](https://github.com/huggingface/transformers/blob/main/examples/pytorch/language-modeling/run_clm.py). We also use [DeepSpeed](https://github.com/microsoft/DeepSpeed) to deal with the huge size of the model.
|
86 |
|
|
|
87 |
|
88 |
+
### Training data
|
89 |
|
|
|
90 |
|
91 |
+
The training corpus consists of texts in 4 languages, with an emphasis on Portuguese and Galician. The main aim of this is to ensure that the model learns to work with this language perfectly, while maintaining knowledge of languages already known (Spanish, English), learning others (Galician) or adapting existing language varieties (Portuguese-PT instead of Portuguese-BR).
|
92 |
|
93 |
+
The corpus is composed as follows:
|
94 |
|
95 |
+
| **Corpus** | | **gl** | **pt** | **es** | **en** |
|
96 |
+
|----------------------------|-----------------------------------------------|--------|--------|--------|--------|
|
97 |
+
| **Base plain text corpus** | Tokens | 232M | 250M | 29M | 29M |
|
98 |
+
| | Percentage (of the total base corpus) | 42,96% | 46,29% | 5,37% | 5,37% |
|
99 |
+
| **Instructions** | Tokens | 26,7M | 44M | 804K | 623K |
|
100 |
+
| | Percentage (of the total instructions corpus) | 37,01% | 61,00% | 1,11% | 0,86% |
|
101 |
|
|
|
102 |
|
103 |
+
### Training hyperparameters
|
104 |
|
105 |
+
- seed: 42
|
106 |
+
- num_devices: 5
|
107 |
+
- train_batch_size: 4
|
108 |
+
- eval_batch_size: 4
|
109 |
+
- gradient_acummulation: 8
|
110 |
+
- optimizer: AdamW
|
111 |
+
- betas: (0.9,0.999)
|
112 |
+
- epsilon: 1e-08
|
113 |
+
- weight_decay_rate: 0.1
|
114 |
+
- scheduler: "Linear"
|
115 |
+
- learning_rate: 1e-04
|
116 |
+
- num_epochs: 1.0
|
117 |
|
118 |
+
### Framework
|
119 |
+
The training was conducted on the MareNostrum V in the Barcelona Supercomputing Center ([BSC](https://www.bsc.es/ca/marenostrum/marenostrum-5)), using 10 nodes with 4 GPUs NVIDIA H100 64GB each one.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
## Evaluation
|
122 |
+
In process...
|
123 |
|
124 |
+
## Additional information
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
+
### Contact
|
127 |
|
128 |
+
For further information, please send an email to
|
129 |
+
### License
|
130 |
+
MIT License
|
131 |
|
132 |
+
Copyright (c) 2024
|
133 |
|
134 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
135 |
|
136 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
137 |
|
138 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
139 |
|
140 |
+
### Funding
|