|
--- |
|
language: |
|
- gl |
|
- es |
|
- en |
|
- pt |
|
licence: |
|
- MIT |
|
tags: |
|
- Llama |
|
license: llama3.1 |
|
base_model: |
|
- meta-llama/Llama-3.1-8B |
|
pipeline_tag: text-generation |
|
library_name: transformers |
|
model-index: |
|
- name: Llama-Carvalho-PT-GL |
|
results: |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: ENEM Challenge (No Images) |
|
type: eduagarcia/enem_challenge |
|
split: train |
|
args: |
|
num_few_shot: 3 |
|
metrics: |
|
- type: acc |
|
value: 19.38 |
|
name: accuracy |
|
source: |
|
url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT-GL |
|
name: Open Portuguese LLM Leaderboard |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: BLUEX (No Images) |
|
type: eduagarcia-temp/BLUEX_without_images |
|
split: train |
|
args: |
|
num_few_shot: 3 |
|
metrics: |
|
- type: acc |
|
value: 18.92 |
|
name: accuracy |
|
source: |
|
url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT-GL |
|
name: Open Portuguese LLM Leaderboard |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: Assin2 RTE |
|
type: assin2 |
|
split: test |
|
args: |
|
num_few_shot: 15 |
|
metrics: |
|
- type: f1_macro |
|
value: 89.3 |
|
name: f1-macro |
|
source: |
|
url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT-GL |
|
name: Open Portuguese LLM Leaderboard |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: Assin2 STS |
|
type: eduagarcia/portuguese_benchmark |
|
split: test |
|
args: |
|
num_few_shot: 15 |
|
metrics: |
|
- type: pearson |
|
value: 78.18 |
|
name: pearson |
|
source: |
|
url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT-GL |
|
name: Open Portuguese LLM Leaderboard |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: FaQuAD NLI |
|
type: ruanchaves/faquad-nli |
|
split: test |
|
args: |
|
num_few_shot: 15 |
|
metrics: |
|
- type: f1_macro |
|
value: 65.88 |
|
name: f1-macro |
|
source: |
|
url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT-GL |
|
name: Open Portuguese LLM Leaderboard |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: HateBR Binary |
|
type: ruanchaves/hatebr |
|
split: test |
|
args: |
|
num_few_shot: 25 |
|
metrics: |
|
- type: f1_macro |
|
value: 82.83 |
|
name: f1-macro |
|
source: |
|
url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT-GL |
|
name: Open Portuguese LLM Leaderboard |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: PT Hate Speech Binary |
|
type: hate_speech_portuguese |
|
split: test |
|
args: |
|
num_few_shot: 25 |
|
metrics: |
|
- type: f1_macro |
|
value: 64.84 |
|
name: f1-macro |
|
source: |
|
url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT-GL |
|
name: Open Portuguese LLM Leaderboard |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: tweetSentBR |
|
type: eduagarcia/tweetsentbr_fewshot |
|
split: test |
|
args: |
|
num_few_shot: 25 |
|
metrics: |
|
- type: f1_macro |
|
value: 61.15 |
|
name: f1-macro |
|
source: |
|
url: https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT-GL |
|
name: Open Portuguese LLM Leaderboard |
|
--- |
|
|
|
# Llama-Carvalho-PT-GL |
|
|
|
## Table of Contents |
|
<details> |
|
<summary>Click to expand</summary> |
|
|
|
- [Llama-Carvalho-PT-GL](#llama-carvalho-pt-gl) |
|
- [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-Carvalho-PT-GL** 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](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) |
|
|
|
This model is part of the **Carvalho familily**, a family of LLMs specialized in Portuguese and Galician which can be found [here](https://huggingface.co/collections/Nos-PT/carvalho-family-67e423bf209c732396377b61). |
|
## Intended uses and limitations |
|
|
|
The **Llama-Carvalho-PT-GL** 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 = "Nos-PT/Llama-Carvalho-PT-GL" |
|
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 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). |
|
|
|
The corpus is composed as follows: |
|
|
|
| **Corpus** | | **gl** | **pt** | **es** | **en** | |
|
|----------------------------|-----------------------------------------------|--------|--------|--------|--------| |
|
| **Base plain text corpus** | Tokens | 232M | 250M | 29M | 29M | |
|
| | Percentage (of the total base corpus) | 42,96% | 46,29% | 5,37% | 5,37% | |
|
| **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: 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 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. |
|
|
|
## Evaluation |
|
|
|
### Galician and European Portuguese |
|
Soon... |
|
### American Portuguese: Open Portuguese LLM Leaderboard Evaluation Results |
|
|
|
Detailed results can be found [here](https://huggingface.co/datasets/eduagarcia-temp/llm_pt_leaderboard_raw_results/tree/main/Nos-PT/Llama-Carvalho-PT-GL) and on the [🚀 Open Portuguese LLM Leaderboard](https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard) |
|
|
|
| Metric | Value | |
|
|--------------------------|---------| |
|
|Average |**60.06**| |
|
|ENEM Challenge (No Images)| 19.38| |
|
|BLUEX (No Images) | 18.92| |
|
|Assin2 RTE | 89.30| |
|
|Assin2 STS | 78.18| |
|
|FaQuAD NLI | 65.88| |
|
|HateBR Binary | 82.83| |
|
|PT Hate Speech Binary | 64.84| |
|
|tweetSentBR | 61.15| |
|
|
|
## Additional information |
|
|
|
### Contact |
|
|
|
For further information, please send an email to |
|
### License |
|
MIT License |
|
|
|
Copyright (c) 2024 |
|
|
|
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, 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. |
|
- AiBERTA, funded by the Portuguese Foundation for Science and Technology with reference 2022.03882.PTDC |
|
|