hf_mirrors/Carballo-bloom-1.3B
Model Introduction
Files & versions
Analysis

Carballo-bloom-1.3B

Table of Contents

Click to expand
  • Carballo-bloom-1.3B
    • Table of Contents
    • Model description
    • Intended uses and limitations
    • How to use
    • Training
      • Tools
      • Language adaptation and training
      • Training data
      • Training hyperparameters
      • Framework
    • Evaluation
    • Additional information
      • Contact
      • Copyright
      • License
      • Funding
    • Citation information

Model description

Carballo-bloom-1.3B is a 1.3B-parameter transformer-based causal language model for Galician. It is the result of a continual pretraining of [FLOR-1.3B] (developed by AINA Project and based in [BLOOM-1.7B]) with the galician corpus CorpusNos.

Intended uses and limitations

The Carballo-bloom-1.3B 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

import argparse
from openmind import is_torch_npu_available,import pipeline, AutoTokenizer, AutoModelForCausalLM

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--model_name_or_path",
        type=str,
        help="Path to model",
        default=None,
    )
    args = parser.parse_args()
    return args

def main():
    args = parse_args()
    model_id = args.model_name_or_path
    if is_torch_npu_available():
        device = "npu:0"
    else:
        device = "cpu"

    input_text = "Hoxe fai un bo día. O sol  "

    tokenizer = AutoTokenizer.from_pretrained(model_id)
    model = AutoModelForCausalLM.from_pretrained(model_id)
    model.to(device)
    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']}")
if __name__ == "__main__":
  main()

Training

Tools

It was trained using HuggingFace Transformers and Pytorch, using the [Causal Modeling Language script]

Language adaptation and training

The language adaptation technique used to train Carballo-bloom-1.3B is based in the used to train FLOR-1.3B, which is explained by their authors in this Medium Post. In summary, we proceeded as follows:

  1. We trained our own BPE tokenizer for galician and replaced the original FLOR-1.3B tokenizer and vocabulary 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-bloom-1.3B's original vocabulary were initialized as the average of all embeddings.
  4. The model was initialized with the weights from FLOR-1.3B 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 is a massive Galician corpus made up of 2.1B words primarily devised for training large language models. The corpus sources are varied and represent a relatively wide range of genres.

The corpus is structured as follows:

SubcorpusGenreNº tokensNº documents
Data obtained via transfer agreementBooks7,255,784104
Research articles2,665,351664
Press124,253,084224,419
Governmental245,897,880654,505
Web contents15,946,68644,165
Encyclopedic4,799,21447,396
Subtotal400,817,999971,253
SubcorpusGenreNº tokensNº documents
Public dataPress and blogs153,497,883665,265
Encyclopedic57,164,848184,628
Web crawls1,384,015,6643,366,449
Translation corpora133,726,0044,745,799
Subtotal1,728,404,3998,777,514
Total2,129,222,3989,748,767
Download (Zenodo)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 traininf was conducted in the Galicia Supercomputing Center (CESGA), using 1 node with 5 GPUs NVIDIA A100.

Evaluation

TO-DO

Additional information

Contact

For further information, please send an email to proxecto.nos@usc.gal

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.