File size: 10,408 Bytes
aad46c6
 
 
 
 
 
7a9f3c8
 
 
aad46c6
 
7a9f3c8
a9e7a5c
7a9f3c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9e7a5c
 
 
 
7a9f3c8
 
8a1b811
7a9f3c8
 
 
 
 
78957ff
7a9f3c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8a1b811
8413d77
7a9f3c8
78957ff
7a9f3c8
 
8a1b811
7a9f3c8
 
 
 
 
 
 
 
 
8a1b811
7a9f3c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8413d77
7a9f3c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78957ff
7a9f3c8
 
8413d77
7a9f3c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32d49dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
---
language:
- gl
- es
- en
- cat
- pt
licence:
- MIT
tags:
- galician
- Llama
license: llama3.1
inference:
  parameters:
    top_k: 10
    do_sample: true
    temperature: 0.4
widget:
- text: |-
    Traduce ao galego esta frase en inglés:
    Inglés: "my sister is studying Biology at the university."
    Galego: "a miña irmá está a estudar bioloxía na universidade."
    ----
    Traduce ao galego esta frase en inglés:
    Inglés: "You are working with my mother on a very interesting project."
    Galego: "Estás a traballar coa miña nai nun proxecto moi interesante"
    ----
    Traduce ao galego esta frase en inglés:
    Inglés: "You have to fix the computer now"
    Galego:
  example_title: Translation
- text: |-
    Responde á seguinte pregunta.
    Pregunta: "Cal é a capital de Noruega?"
    Resposta: "A capital de Noruega é Oslo."
    ----
    Responde á seguinte pregunta.
    Pregunta: "Cal é a moeda de Portugal"
    Resposta: "A moeda de Portugal é o euro."
    ----
    Responde á seguinte pregunta.
    Pregunta: "Cal é a capital de Suecia?"
    Resposta:
  example_title: Question&Answering
- text: |-
    Cualifica como Positivo ou Negativo o sentimento da seguinte frase:
    Texto: "Estou moi feliz"
    Polaridade: Positivo
    ----
    Cualifica como Positivo ou Negativo o sentimento da seguinte frase:
    Texto: "Non me gusta beber cervexa"
    Polaridade: Negativo
    ----
    Cualifica como Positivo ou Negativo o sentimento da seguinte frase:
    Texto: "O meu pai detesta o seu traballo"
    Polaridade: Negativo
    ----
    Cualifica como Positivo ou Negativo  o sentimento da seguinte frase:
    Texto: "Uxía desfruta xogando ao fútbol"
    Polaridade: Positivo
    ----
    Cualifica como Positivo ou Negativo  o sentimento da seguinte frase:
    Texto: "O neno non está contento coas notas"
    Polaridade:
  example_title: Sentiment Analysis
- text: |-
    Extrae as entidades nomeadas do seguinte texto:
    Texto: "Chámome Wolfgang e vivo en Berlin"
    Entidades: Wolfgang:PER, Berlin:LOC
    ----
    Extrae as entidades nomeadas do seguinte texto:
    Texto: "María e Miguel non teñen ningún problema"
    Entidades: María:PER, Miguel:PER
    ----
    Extrae as entidades nomeadas do seguinte texto:
    Texto: "O mellor de Barcelona é o bar do meu amigo Pablo"
    Entidades: Pablo:PER, Barcelona:LOC
    ----
    Extrae as entidades nomeadas do seguinte texto:
    Texto: "Carlos comparte cuarto con Marc"
    Entidades:
  example_title: Name Entity Recognition (NER)
- text: A receita tradicional das filloas é
  example_title: Filloas
- text: O neno vivía preto de
  example_title: O neno
base_model:
- meta-llama/Llama-3.1-8B
pipeline_tag: text-generation
library_name: transformers
---

# Llama-3.1-Carballo

## Table of Contents
<details>
<summary>Click to expand</summary>

- [Llama-3.1-Carballo](#llama-31-carballo)
  - [Table of Contents](#table-of-contents)
  - [Model description](#model-description)
  - [Intended uses and limitations](#intended-uses-and-limitations)
  - [How to use](#how-to-use)
  - [Training](#training)
    - [Tools](#tools)
    - [Training data](#training-data)
    - [Training hyperparameters](#training-hyperparameters)
    - [Framework](#framework)
  - [Evaluation](#evaluation)
  - [Additional information](#additional-information)
    - [Contact](#contact)
    - [License](#license)
    - [Funding](#funding)

</details>

## Model description

**Llama-3.1-Carballo** is a 8B-parameter transformer-based causal language model for Galician, Portuguese, Spanish, Catalan and English. 
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 of almost 20B tokens, with an emphasis on Galician texts.

This model is part of the **Carballo familily**, a family of LLMs specialized in Galician. Smaller models can be found [here](https://huggingface.co/collections/proxectonos/text-models-65d49fa54e358ce02a9699c8)
## Intended uses and limitations

The **Llama-3.1-Carballo** model is ready-to-use only for causal language modeling. 
It can perform text-generation tasks and be fine-tuned for specific scenarios.

## How to use
```python
import torch
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM

input_text = "Hoxe fai un bo día. O sol  "

model_id  = "proxectonos/Llama-3.1-Carballo"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
generator = pipeline(
    "text-generation",
    model=model,
    tokenizer=tokenizer,
    torch_dtype=torch.bfloat16,
    trust_remote_code=True,
    device_map="auto",
)
generation = generator(
    input_text,
    do_sample=True,
    top_k=10,
    eos_token_id=tokenizer.eos_token_id
)

print(f"Result: {generation[0]['generated_text']}")
```

## Training

### Tools

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.


### Training data


The training corpus consists of texts in 5 languages, with an emphasis on 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 (Catalan) or adapting existing language varieties (Portuguese-PT instead of Portuguese-BR).

The corpus is structured as follows:

|            | Nº Tokens | Main Source                                                      |
|------------|-----------|------------------------------------------------------------------|
| Galician   | 5B        | [CorpusNós](https://zenodo.org/records/11655219)                 |
| Portuguese | 3B        | Various                                                          |
| Spanish    | 3.5B      | Various                                                          |
| English    | 3.4B      | Various                                                          |
| Catalan    | 3.6B      | [CATalog](https://huggingface.co/datasets/projecte-aina/CATalog) |                                 


### Training hyperparameters

- seed: 42
- num_devices: 5
- train_batch_size: 4
- eval_batch_size:  4
- gradient_acummulation: 8
- optimizer: AdamW
- betas: (0.9,0.999)
- epsilon: 1e-08
- weight_decay_rate: 0.1
- scheduler: "Linear" 
- learning_rate: 1e-04
- num_epochs: 1.0

### Framework
The training was conducted in the Galicia Supercomputing Center ([CESGA](https://www.cesga.es/en/home-2/)), using 5 nodes with 2 GPUs NVIDIA A100 each one.

## Evaluation
In process...

## Additional information

### Contact

For further information, please send an email to <[email protected]>
### License
MIT License

Copyright (c) 2024 Proxecto Nós

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.

### Funding
This model was development within the Nós Project, funded by the Ministerio para la Transformación Digital y de la Función Pública - Funded by EU – NextGenerationEU within the framework of the [project ILENIA](https://proyectoilenia.es/) with reference 2022/TL22/00215336. 

### Citation
```
@inproceedings{rodriguez-etal-2025-continued,
    title = "Continued Pretraining and Interpretability-Based Evaluation for Low-Resource Languages: A {G}alician Case Study",
    author = "Rodr{\'i}guez, Pablo  and
      Su{\'a}rez, Silvia Paniagua  and
      Gamallo, Pablo  and
      Docio, Susana Sotelo",
    editor = "Che, Wanxiang  and
      Nabende, Joyce  and
      Shutova, Ekaterina  and
      Pilehvar, Mohammad Taher",
    booktitle = "Findings of the Association for Computational Linguistics: ACL 2025",
    month = jul,
    year = "2025",
    address = "Vienna, Austria",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2025.findings-acl.240/",
    doi = "10.18653/v1/2025.findings-acl.240",
    pages = "4622--4637",
    ISBN = "979-8-89176-256-5",
    abstract = "Recent advances in Large Language Models (LLMs) have led to remarkable improvements in language understanding and text generation. However, challenges remain in enhancing their performance for underrepresented languages, ensuring continual learning without catastrophic forgetting, and developing robust evaluation methodologies. This work addresses these issues by investigating the impact of Continued Pretraining (CPT) on multilingual models and proposing a comprehensive evaluation framework for LLMs, focusing on the case of Galician language. Our first contribution explores CPT strategies for languages with limited representation in multilingual models. We analyze how CPT with Galician corpora improves text generation while assessing the trade-offs between linguistic enrichment and task-solving capabilities. Our findings show that CPT with small, high-quality corpora and diverse instructions enhances both task performance and linguistic quality. Our second contribution is a structured evaluation framework based on distinguishing task-based and language-based assessments, leveraging existing and newly developed benchmarks for Galician. Additionally, we contribute new Galician LLMs, datasets for evaluation and instructions, and an evaluation framework."
}
```