初始化项目,由ModelHub XC社区提供模型

Model: Nos-PT/Carvalho_pt-gl-1.3B
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-06-12 03:21:17 +08:00
commit 5adf448aee
11 changed files with 150742 additions and 0 deletions

35
.gitattributes vendored Normal file
View File

@@ -0,0 +1,35 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text

275
README.md Normal file
View File

@@ -0,0 +1,275 @@
---
language:
- gl
- pt
tags:
- galician
- portuguese
- gpt2
license: apache-2.0
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-gl
- text: >-
Traduz para o português esta frase en inglês:
Inglês: "my sister is studying Biology at the university."
Português: "a minha irmã está a estudar biologia na universidade."
----
Traduz para o português esta frase en inglês:
Inglês: "You are working with my mother on a very interesting project."
Português: "Estás a trabalhar com a minha mãe em um projeto muito
interessante"
----
Traduz para o português esta frase en inglês:
Inglês: "You have to fix the computer now"
Português:
example_title: Translation-pt
- 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: QA-GL
- text: |-
Responda a seguinte questão.
Pergunta: "Qual é a capital da Noruega?"
Resposta: "A capital da Noruega é Oslo."
----
Responda a seguinte questão.
Pergunta: "Qual é a moeda de Portugal"
Resposta: “A moeda de Portugal é o euro”.
----
Responda a seguinte questão.
Pergunta: "Qual é a capital da Suécia?"
Responder:
example_title: QA-PT
- 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-GL
- text: |-
Classifique como Positivo ou Negativo o sentimento da seguinte frase:
Texto: "Estou muito feliz"
Polaridade: Positiva
----
Classifique como Positivo ou Negativo o sentimento da seguinte frase:
Texto: "Não gosto de beber cerveja"
Polaridade: Negativa
----
Classifique como Positivo ou Negativo o sentimento da seguinte frase:
Texto: "Meu pai odeia seu trabalho"
Polaridade: Negativa
----
Classifique como Positivo ou Negativo o sentimento da seguinte frase:
Texto: "Uxía gosta de jogar futebol"
Polaridade: Positiva
----
Classifique como Positivo ou Negativo o sentimento da seguinte frase:
Texto: “O menino não está feliz com as notas”
Polaridade:
example_title: Sentiment-PT
- 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: "María axudou a Carlos na empresa"
Entidades:
example_title: NER-GL
- text: |-
Extraia as entidades nomeadas do seguinte texto:
Texto: "Meu nome é Wolfgang e moro em Berlim"
Entidades: Wolfgang:PER, Berlim:LOC
----
Extraia as entidades nomeadas do seguinte texto:
Texto: "Maria e Miguel não têm problemas"
Entidades: Maria:PER, Miguel:PER
----
Extraia as entidades nomeadas do seguinte texto:
Texto: "A melhor coisa de Barcelona é o bar do meu amigo Pablo"
Entidades: Pablo:PER, Barcelona:LOC
----
Extraia as entidades nomeadas do seguinte texto:
Texto: "Maria ajudou Carlos na empresa"
Entidades:
example_title: NER-PT
- text: A receita tradicional das filloas é
example_title: Receita-GL
- text: A receita tradicional de panquecas é
example_title: Receita-PT
- text: O neno vivía preto
example_title: O neno-GL
- text: O menino morava perto
example_title: O menino-PT
datasets:
- proxectonos/corpusnos
---
# Carvalho_pt-gl-1.3B
**Carvalho_pt-gl-1.3B** is a 1.3B-parameter transformer-based causal language model for Galician and European Portuguese.
It is the result of a continual pretraining of a [Cerebras-GPT-1.3B](https://huggingface.co/cerebras/Cerebras-GPT-1.3B) adapted to catalan, spanish and english previously by the [AINA Project](https://projecteaina.cat/).
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).
## How to use
```python
import torch
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
token_HF=""#Obter na páxina de HuggingFace
input_text = "Hoxe fai un bo día. O sol "
model_id = "Nos-PT/Carvalho_pt-gl-1.3B"
tokenizer = AutoTokenizer.from_pretrained(model_id, use_auth_token=token_HF)
model = AutoModelForCausalLM.from_pretrained(model_id, use_auth_token=token_HF)
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 5B tokens of texts in Galician and European Portuguese, whose main sources are [CorpusNÓS](https://zenodo.org/records/11655219) for Galician and [Arquivo.pt](https://arquivo.pt/) for Portuguese.
### Training hyperparameters
- seed: 42
- 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: 5e-05
- num_epochs: 1.0
### Framework
The training was conducted on the Galician Supercomputing Center ([CESGA](https://www.cesga.es/)), using various nodes with 2 GPUs NVIDIA A100 40G.
## Evaluation
The evaluation was carried out using the Calame dataset, in its [Portuguese](https://huggingface.co/datasets/NOVA-vision-language/calame-pt) and Galician versions, and in the GLUE benchmark. In the latter case, the evaluated models were fine-tuned to rotate the tasks.
| **Models** | **CALAME-GL** | **CALAME-PT** |
|-----------------------|----------|----------|
| Carvalho\_pt-gl 1.3B | 0.397 | 0.455 |
| GlorIA 1.3B | 0.219 | 0.488 |
| Gervasio-PTPT 7B | 0.265 | 0.434 |
| mGPT 1.3B | 0.264 | 0.425 |
| Bloom-1b1 | 0.262 | 0.456 |
| Cerebras-GPT 1.3B | 0.177 | 0.167 |
| Models | RTE | MRPC | STS-B | WNLI |
|-------------------------|------|-------|--------|-------|
| | Acc | F1 | Pearson| Acc |
| **Encoder-only** | | | | |
| AiBERTa Base | 55.3 | 83.2 | 80.2 | 58.9 |
| Albertina-PTPT 100m | 55.4 | 87.6 | 84.5 | 65.1 |
| Albertina-PTPT 900m | 80.6 | 89.8 | 88.7 | 65.1 |
| Albertina-PTPT 1.5B | 82.9 | 90.3 | 88.7 | 59.6 |
| **Decoder-only** | | | | |
| Carvalho\_pt-gl 1.3B | 68.0 | 86.0 | 82.6 | 65.1 |
| Gloria 1.3B | 63.8 | 85.2 | 82.0 | 65.1 |
| Gervásio 7B | 83.2 | 90.5 | 87.9 | 64.4 |
| Bloom 1.1B | 71.5 | 87.7 | 85.7 | 63.6 |
| mGPT 1.3B | 58.9 | 85.5 | 78.3 | 65.1 |
## 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
```latex
@inproceedings{gamallo2024galician,
title={A Galician-Portuguese Generative Model},
author={Gamallo, Pablo and Rodr{\'\i}guez, Pablo and Santos, Daniel and Sotelo, Susana and Miquelina, Nuno and Paniagua, Silvia and Schmidt, Daniela and de-Dios-Flores, Iria and Quaresma, Paulo and Bardanca, Daniel and others},
booktitle={EPIA Conference on Artificial Intelligence},
pages={292--304},
year={2024},
organization={Springer}
}
```

33
config.json Normal file
View File

@@ -0,0 +1,33 @@
{
"_name_or_path": "/mnt/netapp1/Proxecto_NOS/adestramentos/tools/tmp/model_fp16",
"activation_function": "gelu",
"architectures": [
"GPT2LMHeadModel"
],
"attn_pdrop": 0.0,
"bos_token_id": 50256,
"embd_pdrop": 0.0,
"eos_token_id": 50256,
"initializer_range": 0.02,
"layer_norm_epsilon": 1e-05,
"model_type": "gpt2",
"n_embd": 2048,
"n_head": 16,
"n_inner": 8192,
"n_layer": 24,
"n_positions": 2048,
"pad_token_id": 50256,
"reorder_and_upcast_attn": false,
"resid_pdrop": 0.0,
"scale_attn_by_inverse_layer_idx": false,
"scale_attn_weights": true,
"summary_activation": null,
"summary_first_dropout": 0.1,
"summary_proj_to_labels": true,
"summary_type": "cls_index",
"summary_use_proj": true,
"torch_dtype": "float16",
"transformers_version": "4.33.2",
"use_cache": true,
"vocab_size": 50257
}

6
generation_config.json Normal file
View File

@@ -0,0 +1,6 @@
{
"_from_model_config": true,
"bos_token_id": 50256,
"eos_token_id": 50256,
"transformers_version": "4.33.2"
}

50001
merges.txt Normal file

File diff suppressed because it is too large Load Diff

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4aea73ff17444ee47312be9e9b62c06199aa5cabdc0ae114a90fb8a948de90b2
size 2631477040

3
pytorch_model.bin Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:28351f2c6b3ebf4c3ef5d0ebbdabcc882b1974d9db55b992811674abd1623e9b
size 2631537629

30
special_tokens_map.json Normal file
View File

@@ -0,0 +1,30 @@
{
"bos_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false
},
"eos_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false
},
"pad_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false
},
"unk_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false
}
}

100305
tokenizer.json Normal file

File diff suppressed because it is too large Load Diff

50
tokenizer_config.json Normal file
View File

@@ -0,0 +1,50 @@
{
"add_bos_token": false,
"add_prefix_space": false,
"added_tokens_decoder": {
"50256": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false,
"special": true
}
},
"bos_token": {
"__type": "AddedToken",
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false
},
"clean_up_tokenization_spaces": true,
"eos_token": {
"__type": "AddedToken",
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false
},
"errors": "replace",
"model_max_length": 1000000000000000019884624838656,
"pad_token": {
"__type": "AddedToken",
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false
},
"tokenizer_class": "GPT2Tokenizer",
"unk_token": {
"__type": "AddedToken",
"content": "<|endoftext|>",
"lstrip": false,
"normalized": true,
"rstrip": false,
"single_word": false
}
}

1
vocab.json Normal file

File diff suppressed because one or more lines are too long