159 lines
6.5 KiB
Markdown
159 lines
6.5 KiB
Markdown
---
|
||
language:
|
||
- gl
|
||
- es
|
||
- en
|
||
- pt
|
||
- ca
|
||
licence:
|
||
- MIT
|
||
tags:
|
||
- Llama
|
||
license: llama3.1
|
||
base_model:
|
||
- meta-llama/Llama-3.1-8B
|
||
pipeline_tag: text-generation
|
||
library_name: transformers
|
||
datasets:
|
||
- proxectonos/corpusnos
|
||
- proxectonos/cpt_instruction_datasets
|
||
---
|
||
|
||
# Carballo-Llama-Instr3
|
||
|
||
|
||
## Table of Contents
|
||
<details>
|
||
<summary>Click to expand</summary>
|
||
|
||
- [Carballo-Llama-Instr3](#llama-carvalho-hq)
|
||
- [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
|
||
|
||
**Carballo-Llama-Instr3** (or **Llama-3.1-Carballo-Instr3**) is a 8B-parameter transformer-based causal language model for Galician, Portuguese, Spanish, English and Catlan.
|
||
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 340M tokens with emphasis in Galician.
|
||
|
||
This model is part of the experiments associated with the paper **Continued Pretraining and Interpretability-Based Evaluation for
|
||
Low-Resource Languages: A Galician Case Study**, accepted in the 2025 ACL Findings.
|
||
|
||
## Intended uses and limitations
|
||
|
||
The **Carballo-Llama-Instr3** 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-Instr3"
|
||
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 4 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 (Galician) or adapting existing language varieties (Portuguese-PT instead of Portuguese-BR).
|
||
|
||
The corpus is composed as follows:
|
||
|
||
| **Corpus** | | **gl** | **pt** | **es** | **en** | **cat** |
|
||
|----------------------------|-----------------------------------------------|--------|--------|--------|--------|---------|
|
||
| **Base plain text corpus** | Tokens | 232M | 29M | 29M | 29M | 29M |
|
||
| | Percentage (of the total base corpus) | 74% | 8.3% | 8.3% | 8.3% | 8.3% |
|
||
| **Instructions** | 30M Tokens (multilingual) |
|
||
|
||
|
||
### 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 Galician Supercomputing Center ([CESGA](https://www.cesga.es/)), using 4 nodes with 2 GPUs NVIDIA A100 40G.
|
||
|
||
## Evaluation
|
||
In process...
|
||
|
||
## Additional information
|
||
|
||
|
||
### 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.
|
||
|
||
### Cite this model
|
||
```
|
||
@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."
|
||
}
|
||
``` |