File size: 3,837 Bytes
288670d
3a562ab
 
 
c661549
3a562ab
 
 
 
c661549
 
288670d
3a562ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c661549
3a562ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312bef8
3a562ab
 
 
 
312bef8
3a562ab
 
312bef8
3a562ab
 
312bef8
3a562ab
 
 
 
 
312bef8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
language:
- gl
licence:
- MIT
tags:
- galician
- FLOR
- bloom
license: mit
pipeline_tag: text-generation
---

# FLOR-1.3B-GL

## Table of Contents
<details>
<summary>Click to expand</summary>

- [FLOR-1.3B-GL](#flor-13b-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)
    - [Platform](#platform)
    - [Language adaptation and training](#language-adaptation-and-training)
    - [Training data](#training-data)
    - [Training hyperparameters](#training-hyperparameters)
    - [Framework](#framework)
  - [Evaluation](#evaluation)
  - [Additional information](#additional-information)
    - [Author](#author)
    - [Contact](#contact)
    - [Copyright](#copyright)
    - [License](#license)
    - [Funding](#funding)

</details>

## Model description

**FLOR-1.3B-GL** is a 1.3B-parameter transformer-based causal language model for Galician. 
It is the result of continual pretraining of [FLOR-1.3B](https://huggingface.co/projecte-aina/FLOR-1.3B) with the galician corpus [CorpusNos]().

## Intended uses and limitations

The **FLOR-1.3B-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 brilla con forza no ceo, e "

model_id  = "proxectonos/FLOR-1.3B-GL"
tokenizer = AutoTokenizer.from_pretrained(model_id)
generator = pipeline(
    "text-generation",
    model=model_id,
    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

### Platform

HF Tranformers + run_clm.py

### Language adaptation and training

The language adaptation technique used to train FLOR-1.3B-GL is based in the used to train FLOR-1.3B, which is explanied 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 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 FLOR-1.3-GL'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




### 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
CESGA, 1 node with 5GPUs A100

## Evaluation


## Additional information

### Author


### Contact


### Copyright


### License
[MIT]()

### 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).