Llama-Carvalho-PT is a 8B-parameter transformer-based causal language model for Galician, Portuguese, Spanish and English.
It is the result of a continual pretraining of meta-llama/Llama-3.1-8B with a multilingual corpus of 340M tokens with emphasis in Portuguese.
This model is part of the Carvalho familily, a family of LLMs specialized in Portuguese and Galician which can be found here.
Intended uses and limitations
The Llama-Carvalho-PT 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
1import torch
2from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
34input_text ="Hoxe fai un bo día. O sol "56model_id ="Nos-PT/Llama-Carvalho-PT"7tokenizer = AutoTokenizer.from_pretrained(model_id)8model = AutoModelForCausalLM.from_pretrained(model_id)9generator = pipeline(10"text-generation",11 model=model,12 tokenizer=tokenizer,13 torch_dtype=torch.bfloat16,14 trust_remote_code=True,15 device_map="auto",16)17generation = generator(18 input_text,19 do_sample=True,20 top_k=10,21 eos_token_id=tokenizer.eos_token_id
22)2324print(f"Result: {generation[0]['generated_text']}")
Training
Tools
It was trained using HuggingFace Transformers and Pytorch, using the Causal Modeling Language script. We also use DeepSpeed to deal with the huge size of the model.
Training data
The training corpus consists of texts in 4 languages, with an emphasis on Portuguese. 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).
The corpus is composed as follows:
Corpus
gl
pt
es
en
Base plain text corpus
Tokens
30M
250M
29M
29M
Percentage (of the total base corpus)
9%
74%
8,5%
8,5%
Instructions
Tokens
26,7M
44M
804K
623K
Percentage (of the total instructions corpus)
37,01%
61,00%
1,11%
0,86%
Training hyperparameters
seed: 42
num_devices: 1
train_batch_size: 4
eval_batch_size: 4
gradient_acummulation: 4
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 on the Vision Clúster in the University of Evora (BSC, using 1 node with 8 GPUs NVIDIA A100 40G.
Evaluation
In process...
Galician and European Portuguese
Soon...
American Portuguese: Open Portuguese LLM Leaderboard Evaluation Results
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 developed within the projects:
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 with reference 2022/TL22/00215336.
AiBERTA, funded by the Portuguese Foundation for Science and Technology with reference 2022.03882.PTDC
Cite this model
@article{rodriguez-etal-2025-enhancing,
title={Enhancing Large Language Models for Underrepresented Varieties: Pretraining Strategies in the Galician-Portuguese Diasystem},
volume={31},
url={https://journals-sol.sbc.org.br/index.php/jbcs/article/view/5766},
DOI={10.5753/jbcs.2025.5766},
number={1},
journal={Journal of the Brazilian Computer Society},
author={Rodríguez, Pablo and Gamallo, Pablo and Santos, Daniel and Sotelo, Susana and Paniagua, Silvia and Pichel, José Ramom and Salgueiro, Pedro and Nogueira, Vítor and Quaresma, Paulo and Garcia, Marcos and Barro, Senén},
year={2025},
month={Oct.},
pages={1049–1062} }