Llama-Carvalho-PT / README.md
pablo-rf's picture
Update README.md
4308e2b verified
metadata
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
    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
          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
          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: 87.5
            name: f1-macro
        source:
          url: >-
            https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT
          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: 75.7
            name: pearson
        source:
          url: >-
            https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT
          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: 43.97
            name: f1-macro
        source:
          url: >-
            https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT
          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: 76.93
            name: f1-macro
        source:
          url: >-
            https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT
          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: 49.21
            name: f1-macro
        source:
          url: >-
            https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT
          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: 60.88
            name: f1-macro
        source:
          url: >-
            https://huggingface.co/spaces/eduagarcia/open_pt_llm_leaderboard?query=Nos-PT/Llama-Carvalho-PT
          name: Open Portuguese LLM Leaderboard

Llama-Carvalho-PT

Table of Contents

Click to expand

Model description

Llama-Carvalho-PT 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 with a multilingual corpus of 340M tokens with emphasis in Portuguese.

This model is part of the Carvalho familily, a family of LLMs specialized in Portuguese and Galician which can be found here.

Intended uses and limitations

The Llama-Carvalho-PT 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 torch
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM

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

model_id  = "Nos-PT/Llama-Carvalho-PT"
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. We also use 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. 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 30M 250M 29M 29M
Percentage (of the total base corpus) 9% 74% 8,5% 8,5%
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: 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 Vision Clúster in the University of Evora (BSC, using 1 node with 8 GPUs NVIDIA A100 40G.

Evaluation

In process...

Galician and European Portuguese

Soon...

American Portuguese: Open Portuguese LLM Leaderboard Evaluation Results

Detailed results can be found here and on the 🚀 Open Portuguese LLM Leaderboard

Metric Value
Average 54.06
ENEM Challenge (No Images) 19.38
BLUEX (No Images) 18.92
Assin2 RTE 87.50
Assin2 STS 75.70
FaQuAD NLI 43.97
HateBR Binary 76.93
PT Hate Speech Binary 49.21
tweetSentBR 60.88

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 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 with reference 2022/TL22/00215336.