---
language:
- gl
licence:
- MIT
tags:
- galician
- Cerebras
license: mit
inference:
parameters:
top_k: 10
do_sample: true
temperature: 0.4
widget:
- 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
---
# Carballo-cerebras-1.3B
## Table of Contents
Click to expand
- [Carballo-cerebras-1.3B](#Carballo-cerebras-13B)
- [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)
- [Language adaptation and training](#language-adaptation-and-training)
- [Training data](#training-data)
- [Training hyperparameters](#training-hyperparameters)
- [Framework](#framework)
- [Evaluation](#evaluation)
- [Additional information](#additional-information)
- [Contact](#contact)
- [Copyright](#copyright)
- [License](#license)
- [Funding](#funding)
- [Citation information](#citation-information)
## Model description
**Carballo-cerebras-1.3BL** is a 1.3B-parameter transformer-based causal language model for Galician.
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/).
## Intended uses and limitations
The **Carballo-cerebras-1.3BL** 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/Carballo-cerebras-1.3B"
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) and DeepSpeed with ZeRO level 2 optimizations.
### Language adaptation and training
The language adaptation technique used to train Carballo-cerebras-1.3B is based in the used to train FLOR-1.3B, which is explained by their authors in this [Medium Post](https://medium.com/@mpamies247/flor-6-3b-a-chinchilla-compliant-model-for-catalan-spanish-and-english-7cdb389a9aac). In summary, we proceeded as follows:
1) We trained our own BPE tokenizer for galician and replaced the tokenizer and vocabulary of the base model with it.
2) The embeddings corresponding to tokens that are present in both the original and the target vocabulary (matching tokens) were used for initialization.
3) The embeddings from tokens not present in Carballo-cerebras-1.3B's original vocabulary were initialized as the average of all embeddings.
4) The model was initialized with the original weights and with our adapted tokenizer (step 1) and embeddings (steps 2-3).
5) The model was then trained on a galician corpus.
### Training data
[CorpusNÓS](https://zenodo.org/records/10687642 )
### Training hyperparameters
- seed: 42
- num_devices: 1
- train_batch_size: 2
- eval_batch_size: 2
- gradient_acummulation: 4
- optimizer: AdamW
- betas: (0.9,0.999)
- epsilon: 1e-08
- weight_decay_rate: 0.1
- scheduler: "Linear"
- learning_rate: 5e-05
- num_epochs: 1.2
### Framework
The training was conducted in the Galicia Supercomputing Center ([CESGA](https://www.cesga.es/en/home-2/)), using 4 nodes with 2 GPUs NVIDIA A100 (8GPUS in total)
## Evaluation
TO-DO
## Additional information
### Contact
For further information, please send an email to
### 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 research was funded by “The Nós project: Galician in the society and economy of Artificial Intelligence”, resulting from the agreement 2021-CP080 between the Xunta de Galicia and the University of Santiago de Compostela, and thanks to the Investigo program, within the National Recovery, Transformation and Resilience Plan, within the framework of the European Recovery Fund (NextGenerationEU).
### How to cite this work
If you use this model, please cite this article:
Gamallo, Pablo, Pablo Rodríguez Fernández, Iria de Dios Flores, Susana Sotelo, Silvia Paniagua, José Ramom Pichel, Daniel Bardanca, Marcos Garcia (2024) "Open Generative Large Language Models for Galician", Procesamiento del Lenguaje Natural, 73, pp. 259-270. ISSN: 1135-5948.