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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# top_k: null
|
| 27 |
# max_new_tokens: null
|
| 28 |
---
|
| 29 |
+
|
| 30 |
+
# Model Card for Lucie-7B
|
| 31 |
+
|
| 32 |
+
<!-- inspired from the following template:
|
| 33 |
+
https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1
|
| 34 |
+
-->
|
| 35 |
+
|
| 36 |
+
* [Model Description](#model-description)
|
| 37 |
+
<!-- * [Uses](#uses) -->
|
| 38 |
+
* [Example code in python](#example-code-in-python)
|
| 39 |
+
* [Sentence completion](#sentence-completion)
|
| 40 |
+
* [Load a checkpoint](#load-a-checkpoint)
|
| 41 |
+
* [Training Details](#training-details)
|
| 42 |
+
* [Training Data](#training-data)
|
| 43 |
+
* [Training Procedure](#training-procedure)
|
| 44 |
+
<!-- * [Evaluation](#evaluation) -->
|
| 45 |
+
* [Acknowledgements](#acknowledgements)
|
| 46 |
+
* [Contact](#contact)
|
| 47 |
+
|
| 48 |
+
## Model Description
|
| 49 |
+
|
| 50 |
+
Lucie-7B is a pretrained 7B parameter causal language model built by [LINAGORA](https://labs.linagora.com/) and [OpenLLM-France](https://github.com/OpenLLM-France),
|
| 51 |
+
available under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0).
|
| 52 |
+
|
| 53 |
+
Lucie-7B was trained on 3 trillion tokens of multilingual data, including
|
| 54 |
+
English聽(33.2%),
|
| 55 |
+
French聽(32.4%),
|
| 56 |
+
German聽(6.9%),
|
| 57 |
+
Spanish聽(6.6%),
|
| 58 |
+
Italian聽(3.8%),
|
| 59 |
+
and parallel data from those languages聽(2.5%),
|
| 60 |
+
as well as several programming languages聽(14.7%).
|
| 61 |
+
|
| 62 |
+
## Example code in python
|
| 63 |
+
|
| 64 |
+
### Sentence completion
|
| 65 |
+
|
| 66 |
+
Load the model (quantized version on GPU if possible, for efficient inference):
|
| 67 |
+
```python
|
| 68 |
+
import transformers
|
| 69 |
+
|
| 70 |
+
model_name = "OpenLLM-France/Lucie-7B"
|
| 71 |
+
|
| 72 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
|
| 73 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(model_name,
|
| 74 |
+
device_map="auto",
|
| 75 |
+
load_in_4bit=True # For efficient inference, if quantization is supported by the GPU card
|
| 76 |
+
)
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
Wrap the model in a text generation pipeline, and prepare some generation parameters:
|
| 80 |
+
```
|
| 81 |
+
pipeline = transformers.pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 82 |
+
|
| 83 |
+
generation_kwargs = dict(
|
| 84 |
+
num_return_sequences=1, # Number of variants to generate.
|
| 85 |
+
return_full_text= False, # Do not include the prompt in the generated text.
|
| 86 |
+
do_sample=True,
|
| 87 |
+
temperature=1.0, top_p=1, top_k=None, # Sampling parameters.
|
| 88 |
+
max_new_tokens=200, # Maximum length for the output text (in number of tokens).
|
| 89 |
+
)
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
Try 1-shot question answering:
|
| 93 |
+
```python
|
| 94 |
+
prompt = """\
|
| 95 |
+
Quelle est la capitale de l'Espagne ? Madrid\n\
|
| 96 |
+
Quelle est la capitale de la France ?\
|
| 97 |
+
"""
|
| 98 |
+
completions = pipeline(prompt, **generation_kwargs)
|
| 99 |
+
for completion in completions:
|
| 100 |
+
print(prompt + " [鈥" + completion['generated_text'])
|
| 101 |
+
```
|
| 102 |
+
This will print something like:
|
| 103 |
+
```
|
| 104 |
+
Quelle est la capitale de l'Espagne ? Madrid
|
| 105 |
+
Quelle est la capitale de la France ? [鈥 Paris
|
| 106 |
+
Quelle est la capitale de l'Italie? Rome
|
| 107 |
+
Quelle est la capitale de la Grande-Bretagne? Londres
|
| 108 |
+
Quelle est la capitale de la Suisse? Berne
|
| 109 |
+
Quelle est la capitale du Portugal? Lisbonne
|
| 110 |
+
Quelle est la capitale de l'Alg茅rie? Alger
|
| 111 |
+
...
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
If running on GPU (`cuda` device), you will need at least 6GB of VRAM to run inference using 4bit quantization (16GB of VRAM without 4bit quantization).
|
| 115 |
+
|
| 116 |
+
### Load a checkpoint
|
| 117 |
+
|
| 118 |
+
Checkpoints at several training steps are available under revision tags,
|
| 119 |
+
every 5000 steps during the first 25000 steps, and then every 25000 steps.
|
| 120 |
+
|
| 121 |
+
Intermediate checkpoints can be loaded using the `revision` parameter:
|
| 122 |
+
```python
|
| 123 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(model_name,
|
| 124 |
+
revision="step0400000",
|
| 125 |
+
...
|
| 126 |
+
)
|
| 127 |
+
```
|
| 128 |
+
where `revision` can be one of: "`step0005000`", "`step0010000`", ..., "`step0025000`", "`step0050000`", "`step0075000`", ...
|
| 129 |
+
|
| 130 |
+
## Training Details
|
| 131 |
+
|
| 132 |
+
### Training Data
|
| 133 |
+
|
| 134 |
+
The training dataset will be made available soon.
|
| 135 |
+
<!-- at [OpenLLM-France/Lucie-Training-Dataset](https://huggingface.co/datasets/OpenLLM-France/Lucie-Training-Dataset)
|
| 136 |
+
and described in ["The Lucie Training Dataset" (2024/5)](https://arxiv.org/abs/xxxx.xxxxx). -->
|
| 137 |
+
|
| 138 |
+
### Training Procedure
|
| 139 |
+
|
| 140 |
+
The training code is available at [https://github.com/OpenLLM-France/Lucie-Training](https://github.com/OpenLLM-France/Lucie-Training),
|
| 141 |
+
and this based on [this fork of Megatron-DeepSpeed](https://github.com/OpenLLM-France/Megatron-DeepSpeed).
|
| 142 |
+
|
| 143 |
+
Lucie-7B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
|
| 144 |
+
|
| 145 |
+
It was trained on 512 H100 80GB GPUs for about <<TODO>> GPU hours on [Jean Zay supercomputer](http://www.idris.fr/eng/jean-zay/jean-zay-presentation-eng.html).
|
| 146 |
+
|
| 147 |
+
#### Neural Network Architecture
|
| 148 |
+
|
| 149 |
+
Lucie-7B has the same neural network architecture as Llama3.
|
| 150 |
+
It has exactly 6聽706聽958聽336 free parameters,
|
| 151 |
+
with the following hyperparameters:
|
| 152 |
+
| **Hyperparameter** | **Value** |
|
| 153 |
+
|---------------------------|---------|
|
| 154 |
+
| Vocabulary size (\# tokens)| 65聽024|
|
| 155 |
+
| ROPE theta | 500聽000|
|
| 156 |
+
| \# transformer blocks | 32|
|
| 157 |
+
| \# attention heads | 32|
|
| 158 |
+
| \# key-value heads | 8|
|
| 159 |
+
| Hidden size | 4聽096|
|
| 160 |
+
| Feed-Forward hidden size | 12聽288|
|
| 161 |
+
| Activation | `silu`|
|
| 162 |
+
| RMS norm epsilon | 1e-5|
|
| 163 |
+
|
| 164 |
+
#### Training Hyperparameters
|
| 165 |
+
|
| 166 |
+
Training hyperparameters in torch/Megatron-DeepSpeed were the following:
|
| 167 |
+
| **Hyperparameter** | **Value** |
|
| 168 |
+
|------------------------|------------|
|
| 169 |
+
| Optimizer | `AdamW` |
|
| 170 |
+
| Precision | `bfloat16` |
|
| 171 |
+
| Initial batch size | 256 |
|
| 172 |
+
| Final batch size | 1024 |
|
| 173 |
+
| Batch size rampup | by steps of 64 over 10M samples |
|
| 174 |
+
| Context length | 4096 |
|
| 175 |
+
| Learning rate schedule | warmup + cosine annealing |
|
| 176 |
+
| Maximum Learning rate | 3e-4 |
|
| 177 |
+
| Final Learning rate | 3e-5 |
|
| 178 |
+
| Weight decay | 0.1 |
|
| 179 |
+
| Dropout | _ |
|
| 180 |
+
| Gradient clipping | 1 |
|
| 181 |
+
| Initializer range | 0.2 |
|
| 182 |
+
| Tensor Parallelism (with 512 GPUs) | 4 |
|
| 183 |
+
| Pipeline Parallelism (with 512 GPUs) | 4 |
|
| 184 |
+
| Data Parallelism (with 512 GPUs) | 32 |
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
## Acknowledgements
|
| 188 |
+
|
| 189 |
+
This work was performed using HPC resources from GENCI鈥揑DRIS (Grant 2024-GC011015444).
|
| 190 |
+
|
| 191 |
+
Lucie-7B was created by members of [LINAGORA](https://labs.linagora.com/) and OpenLLM-France community, including in alphabetical order:
|
| 192 |
+
Christophe Cerisara (LORIA),
|
| 193 |
+
Evan Dufraisse (CEA),
|
| 194 |
+
Julie Hunter (LINAGORA),
|
| 195 |
+
Jean-Pierre Lorr茅 (LINAGORA),
|
| 196 |
+
J茅r么me Louradour (LINAGORA),
|
| 197 |
+
Michel-Marie Maudet (LINAGORA),
|
| 198 |
+
Olivier Gouvert (LINAGORA),
|
| 199 |
+
Pierre-Carl Langlais (OpSci),
|
| 200 |
+
Yaya Sy (LORIA).
|
| 201 |
+
|
| 202 |
+
## Contact
|
| 203 |
+
|
| 204 |