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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
pipeline_tag: text-generation
|
4 |
+
language:
|
5 |
+
- it
|
6 |
+
- en
|
7 |
+
tags:
|
8 |
+
- sft
|
9 |
+
- dpo
|
10 |
+
base_model:
|
11 |
+
- sapienzanlp/Minerva-7B-cpt-v1.0-mixed_recipe7-3epochs-safety-handcraft
|
12 |
+
datasets:
|
13 |
+
- HuggingFaceH4/ultrafeedback_binarized
|
14 |
+
- Babelscape/ALERT
|
15 |
+
- efederici/evol-dpo-ita
|
16 |
+
inference:
|
17 |
+
parameters:
|
18 |
+
temperature: 0.4
|
19 |
+
do_sample: true
|
20 |
+
widget:
|
21 |
+
- text: Chi sei?
|
22 |
+
example_title: Example 1
|
23 |
+
library_name: transformers
|
24 |
+
---
|
25 |
+
|
26 |
+
<div style="text-align: center; display: flex; flex-direction: column; align-items: center;">
|
27 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/5f0b462819cb630495b814d7/DVA4MnFUs3UHBnTrX9jG6.png" style="max-width: 550px; height: auto;">
|
28 |
+
</div>
|
29 |
+
|
30 |
+
# Model Card for Minerva-7B-cpt-v1.0-dpo
|
31 |
+
|
32 |
+
Minerva is the first family of **LLMs pretrained from scratch on Italian** developed by [Sapienza NLP](https://nlp.uniroma1.it)
|
33 |
+
in collaboration with [Future Artificial Intelligence Research (FAIR)](https://fondazione-fair.it/) and [CINECA](https://www.cineca.it/).
|
34 |
+
Notably, the Minerva models are truly-open (data and model) Italian-English LLMs, with approximately half of the pretraining data
|
35 |
+
including Italian text.
|
36 |
+
|
37 |
+
* [Minerva LLMs - website](https://nlp.uniroma1.it/minerva/)
|
38 |
+
|
39 |
+
## Description
|
40 |
+
|
41 |
+
This is the model card for **Minerva-7B-base-v1.0-dpo**, a 7 billion parameter model trained on almost 2.5 trillion tokens (1.14 trillion in Italian,
|
42 |
+
1.14 trillion in English, and 200 billion in code).
|
43 |
+
|
44 |
+
This model is part of the Minerva LLM family:
|
45 |
+
|
46 |
+
* [Minerva-350M-base-v1.0](https://huggingface.co/sapienzanlp/Minerva-350M-base-v1.0)
|
47 |
+
* [Minerva-1B-base-v1.0](https://huggingface.co/sapienzanlp/Minerva-1B-base-v1.0)
|
48 |
+
* [Minerva-3B-base-v1.0](https://huggingface.co/sapienzanlp/Minerva-3B-base-v1.0)
|
49 |
+
* [Minerva-7B-base-v1.0](https://huggingface.co/sapienzanlp/Minerva-7B-base-v1.0-1110)
|
50 |
+
* [Minerva-7B-base-v1.0-sft](https://huggingface.co/sapienzanlp/Minerva-7B-cpt-v1.0-mixed_recipe7-3epochs-safety-handcraft)
|
51 |
+
* [Minerva-7B-base-v1.0-dpo](https://huggingface.co/sapienzanlp/Minerva-7B-cpt-v1.0-mixed_recipe7-3epochs-safety-handcraft-DPO-alert-uf-evol-temp)
|
52 |
+
|
53 |
+
## 🚨⚠️🚨 Bias, Risks, and Limitations 🚨⚠️🚨
|
54 |
+
|
55 |
+
*This section identifies foreseeable harms and misunderstandings.*
|
56 |
+
|
57 |
+
This is a chat foundation model, subject to some degree of alignment. However the model may still:
|
58 |
+
|
59 |
+
- Overrepresent some viewpoints and underrepresent others
|
60 |
+
- Contain stereotypes
|
61 |
+
- Contain [personal information](#personal-data-and-information)
|
62 |
+
- Generate:
|
63 |
+
- Racist and sexist content
|
64 |
+
- Hateful, abusive, or violent language
|
65 |
+
- Discriminatory or prejudicial language
|
66 |
+
- Content that may not be appropriate for all settings, including sexual content
|
67 |
+
- Make errors, including producing incorrect information or historical facts as if it were factual
|
68 |
+
- Generate irrelevant or repetitive outputs
|
69 |
+
|
70 |
+
We are aware of the biases and potential problematic/toxic content that current pretrained large language models exhibit: more specifically, as probabilistic models of (Italian and English) languages, they reflect and amplify the biases of their training data.
|
71 |
+
For more information about this issue, please refer to our survey:
|
72 |
+
|
73 |
+
* [Biases in Large Language Models: Origins, Inventory, and Discussion](https://dl.acm.org/doi/full/10.1145/3597307)
|
74 |
+
|
75 |
+
## How to use Minerva with Hugging Face transformers
|
76 |
+
|
77 |
+
```python
|
78 |
+
import transformers
|
79 |
+
import torch
|
80 |
+
|
81 |
+
model_id = "sapienzanlp/Minerva-7B-base-v1.0"
|
82 |
+
|
83 |
+
# Initialize the pipeline.
|
84 |
+
pipeline = transformers.pipeline(
|
85 |
+
model=model_id,
|
86 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
87 |
+
device_map="auto",
|
88 |
+
)
|
89 |
+
|
90 |
+
# Input text for the model.
|
91 |
+
input_conv = [{"role": "user", "content": "Qualle è la capitale dell'Italia?"}]
|
92 |
+
|
93 |
+
# Compute the outputs.
|
94 |
+
output = pipeline(
|
95 |
+
input_conv,
|
96 |
+
max_new_tokens=128,
|
97 |
+
)
|
98 |
+
|
99 |
+
output
|
100 |
+
```
|
101 |
+
|
102 |
+
[{'generated_text': "La capitale dell'Italia è la città di Roma, che si trova a [...]"}]
|
103 |
+
|
104 |
+
|
105 |
+
## Model Architecture
|
106 |
+
|
107 |
+
Minerva-7B-base-v1.0 is a Transformer model based on the Mistral architecture.
|
108 |
+
Please look at the configuration file for a detailed breakdown of the hyperparameters we chose for this model.
|
109 |
+
|
110 |
+
The Minerva LLM family is composed of:
|
111 |
+
|
112 |
+
| Model Name | Tokens | Layers | Hidden Size | Attention Heads | KV Heads | Sliding Window | Max Context Length |
|
113 |
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
114 |
+
| Minerva-350M-base-v1.0 | 70B (35B it + 35B en) | 16 | 1152 | 16 | 4 | 2048 | 16384 |
|
115 |
+
| Minerva-1B-base-v1.0 | 200B (100B it + 100B en) | 16 | 2048 | 16 | 4 | 2048 | 16384 |
|
116 |
+
| Minerva-3B-base-v1.0 | 660B (330B it + 330B en) | 32 | 2560 | 32 | 8 | 2048 | 16384 |
|
117 |
+
| Minerva-7B-base-v1.0 | 2.48T (1.14T it + 1.14T en + 200B code) | 32 | 4096 | 32 | 8 | None | 4096 |
|
118 |
+
|
119 |
+
## Model Training
|
120 |
+
|
121 |
+
Minerva-7B-base-v1.0 was trained using [llm-foundry 0.8.0](https://github.com/riccorl/llm-foundry) from [MosaicML](https://mosaicml.com/). The hyperparameters used are the following:
|
122 |
+
|
123 |
+
| Model Name | Optimizer | lr | betas | eps | weight decay | Scheduler | Warmup Steps | Batch Size (Tokens) | Total Steps |
|
124 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
125 |
+
| Minerva-350M-base-v1.0 | Decoupled AdamW | 2e-4 | (0.9, 0.95) | 1e-8 | 0.0 | Cosine | 2% | 4M | 16,690 |
|
126 |
+
| Minerva-1B-base-v1.0 | Decoupled AdamW | 2e-4 | (0.9, 0.95) | 1e-8 | 0.0 | Cosine | 2% | 4M | 47,684 |
|
127 |
+
| Minerva-3B-base-v1.0 | Decoupled AdamW | 2e-4 | (0.9, 0.95) | 1e-8 | 0.0 | Cosine | 2% | 4M | 157,357 |
|
128 |
+
| Minerva-7B-base-v1.0 | AdamW | 3e-4 | (0.9, 0.95) | 1e-5 | 0.1 | Cosine | 2000 | 4M | 591,558 |
|
129 |
+
|
130 |
+
### SFT Training
|
131 |
+
|
132 |
+
The SFT model was trained using [Llama-Factory](https://github.com/hiyouga/LLaMA-Factory). The data mix was the following:
|
133 |
+
|
134 |
+
| Dataset | Source | Code | English | Italian |
|
135 |
+
|--------------------------------------|------------------------------------------------------------------------|----------|---------|---------|
|
136 |
+
| Alpaca-cleaned | [Link](https://huggingface.co/datasets/yahma/alpaca-cleaned) | 0 | 50,000 | 0 |
|
137 |
+
| Databricks-dolly-15k | [Link](https://huggingface.co/datasets/databricks/databricks-dolly-15k) | 0 | 15,011 | 0 |
|
138 |
+
| No-robots | [Link](https://huggingface.co/datasets/HuggingFaceH4/no_robots) | 0 | 9,499 | 0 |
|
139 |
+
| OASST2 | [Link](https://huggingface.co/datasets/OpenAssistant/oasst2) | 0 | 29,000 | 528 |
|
140 |
+
| Tower-blocks_it | [Link](https://huggingface.co/datasets/sapienzanlp/tower_blocks-v0.2_it) | 0 | 0 | 7,276 |
|
141 |
+
| Glaive-code-assistant | [Link](https://huggingface.co/datasets/glaiveai/glaive-code-assistant) | 100,000 | 0 | 0 |
|
142 |
+
| Alpaca-python | [Link](https://huggingface.co/datasets/Vezora/Tested-143k-Python-Alpaca) | 20,000 | 0 | 0 |
|
143 |
+
| WizardLM | [Link](https://huggingface.co/datasets/WizardLMTeam/WizardLM_evol_instruct_70k) | 0 | 29,810 | 0 |
|
144 |
+
| LIMA | [Link](https://huggingface.co/datasets/GAIR/lima?row=0) | 0 | 1,000 | 0 |
|
145 |
+
| OPENORCA | [Link](https://huggingface.co/datasets/Open-Orca/OpenOrca) | 0 | 30,000 | 0 |
|
146 |
+
| Ultrachat | [Link](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) | 0 | 50,000 | 0 |
|
147 |
+
| MagpieMT | [Link](https://huggingface.co/datasets/Magpie-Align/Magpie-Pro-MT-300K-v0.1) | 0 | 30,000 | 0 |
|
148 |
+
| Tulu-V2-Science | [Link](https://huggingface.co/datasets/allenai/tulu-v2-sft-mixture) | 0 | 7,000 | 0 |
|
149 |
+
| Bactrian-X | [Link](https://huggingface.co/datasets/MBZUAI/Bactrian-X) | 0 | 0 | 67,000 |
|
150 |
+
| Magpie (*Translated by us*) | - | 0 | 0 | 60,000 |
|
151 |
+
| Everyday-conversations (*Translated by us*) | - | 0 | 0 | 2,260 |
|
152 |
+
| Aya_datasets | [Link](http://CohereForAI/aya_dataset) | 0 | 3,944 | 738 |
|
153 |
+
| alpaca-gpt4-it | [Link](https://huggingface.co/datasets/efederici/alpaca-gpt4-it) | 0 | 0 | 15,000 |
|
154 |
+
| capybara-claude-15k-ita | [Link](https://huggingface.co/datasets/efederici/capybara-claude-15k-ita) | 0 | 0 | 15,000 |
|
155 |
+
| Wildchat | [Link](https://huggingface.co/datasets/allenai/WildChat-1M) | 0 | 0 | 5,000 |
|
156 |
+
| GPT4_INST | [Link](https://huggingface.co/datasets/DeepMount00/GPT-4o-ITA-INSTRUCT) | 0 | 0 | 10,000 |
|
157 |
+
| Safety Italian | - | 0 | 0 | 21,000 |
|
158 |
+
| Handmade Italian | - | 0 | 0 | 2,000 |
|
159 |
+
|
160 |
+
For more details please check [our tech report](https://nlp.uniroma1.it/minerva/blog#from-a-base-model-to-an-instruct-model).
|
161 |
+
|
162 |
+
### Online DPO Training
|
163 |
+
|
164 |
+
This model card is for our DPO model. Direct Preference Optimization (DPO) is a method that refines models based on user feedback, similar to Reinforcement Learning from Human Feedback (RLHF), but without the complexity of reinforcement learning. Online DPO further improves this by allowing real-time adaptation during training, continuously refining the model with new feedback. For training this model, we used the [Hugging Face TRL](https://github.com/huggingface/trl) library and Online DPO, with the [Skywork/Skywork-Reward-Llama-3.1-8B-v0.2](https://huggingface.co/Skywork/Skywork-Reward-Llama-3.1-8B-v0.2) model as the judge to evaluate and guide optimization. For this stage we used just the prompts from HuggingFaceH4/ultrafeedback_binarized (English), efederici/evol-dpo-ita (Italian) and Babelscape/ALERT translated to Italian were used, with additional manually curated data for safety.
|
165 |
+
|
166 |
+
For more details please check [our tech report](https://nlp.uniroma1.it/minerva/blog#from-a-base-model-to-an-instruct-model).
|
167 |
+
|
168 |
+
## Model Evaluation
|
169 |
+
|
170 |
+
We assessed our model using the [LM-Evaluation-Harness](https://github.com/EleutherAI/lm-evaluation-harness) library, which serves as a comprehensive framework for testing generative language models across a wide range of evaluation tasks.
|
171 |
+
|
172 |
+
All the reported benchmark data was already present in the LM-Evaluation-Harness suite.
|
173 |
+
|
174 |
+
_Scores will be available at later stage._
|
175 |
+
|
176 |
+
<!-- **Italian** Data: -->
|
177 |
+
<!-- | Task | Accuracy |
|
178 |
+
| --- | --- | -->
|
179 |
+
<!-- | [xcopa](https://huggingface.co/datasets/xcopa) (0-shot) | 0.694 |
|
180 |
+
| [Hellaswag](https://huggingface.co/datasets/alexandrainst/m_hellaswag) (5-shot) | 0.5293 |
|
181 |
+
| [Belebele](https://huggingface.co/datasets/facebook/belebele) (5-shot) | 0.2333 |
|
182 |
+
| [TruthfulQA MC 1](https://huggingface.co/datasets/alexandrainst/m_truthfulqa) (0-shot) | 0.2363 |
|
183 |
+
| [TruthfulQA MC 2](https://huggingface.co/datasets/alexandrainst/m_truthfulqa) (0-shot) | 0.3731 |
|
184 |
+
| [M MMLU](https://huggingface.co/datasets/alexandrainst/m_mmlu) (5-shot) | 0.2612 |
|
185 |
+
| [arc challenge](https://huggingface.co/datasets/alexandrainst/m_arc) (5-shot) | 0.3268 | -->
|
186 |
+
|
187 |
+
<!-- **English** Data: -->
|
188 |
+
<!-- | Task | Accuracy |
|
189 |
+
| --- | --- | -->
|
190 |
+
<!-- | [Hellaswag](https://huggingface.co/datasets/Rowan/hellaswag) (5-shot) | 0.6168 |
|
191 |
+
| [piqa](https://huggingface.co/datasets/piqa) (5-shot) | 0.7535 |
|
192 |
+
| [sciq](https://huggingface.co/datasets/sciq) (5-shot) | 0.925 |
|
193 |
+
| [Belebele](https://huggingface.co/datasets/facebook/belebele) (5-shot) | 0.2278 |
|
194 |
+
| [TruthfulQA MC 1](https://huggingface.co/datasets/truthful_qa) (0-shot) | 0.2142 |
|
195 |
+
| [TruthfulQA MC 2](https://huggingface.co/datasets/truthful_qa) (0-shot) | 0.3643 |
|
196 |
+
| [M MMLU](https://huggingface.co/datasets/alexandrainst/m_mmlu) (5-shot) | 0.263 |
|
197 |
+
| [arc challenge](allenai/ai2_arc) (5-shot) | 0.3319 |
|
198 |
+
| [arc easy](allenai/ai2_arc) (5-shot) | 0.6540 | -->
|
199 |
+
|
200 |
+
<!-- ## Training Data
|
201 |
+
|
202 |
+
Minerva-7B-base-v1.0 is trained on 1.14T Italian tokens, 1.14T English tokens, and 200B code tokens.
|
203 |
+
|
204 |
+
The training data is a mixture of the following datasets:
|
205 |
+
|
206 |
+
| Dataset | Tokens | Language | Epochs |
|
207 |
+
| --- | --- | --- | --- |
|
208 |
+
| RedPajama-Data-V2 | 687,952,502,784 | Italian | 1.3 |
|
209 |
+
| CulturaX | 158,201,876,480 | Italian | 1.5 |
|
210 |
+
| Wikipedia | 1,265,135,616 | Italian | 1.0 |
|
211 |
+
| Gutenberg/Wikisource | 147,017,728 | Italian | 2.0 |
|
212 |
+
| EurLex | 1,647,013,888 | Italian | 1.0 |
|
213 |
+
| Gazzetta Ufficiale | 1,654,013,952| Italian | 1.0 |
|
214 |
+
| FineWeb | 1,076,406,624,256 | English | 1.0 |
|
215 |
+
| Wikipedia | 5,259,501,568 | English | 1.0 |
|
216 |
+
| ArXiv | 33,231,106,048 | English | 1.0 |
|
217 |
+
| Gutenberg | 6,947,893,248 | English | 1.0 |
|
218 |
+
| StackExchange | 22,069,268,480 | English | 1.0 |
|
219 |
+
| The Stack V2 | 200,754,900,992 | Code | 1.0 | -->
|
220 |
+
|
221 |
+
<!-- We have extracted some statistics on Italian (115B tokens) and English (210B tokens) documents from CulturaX on the selected sources:
|
222 |
+
|
223 |
+
*Proportion of number of tokens per domain (Italian)*
|
224 |
+
<img src="https://github.com/Andrew-Wyn/images/blob/master/minerva/top_25_url_tokens_proportion_culturax_it.png?raw=true" alt="italian-tok-counts" border="0" width="1800px">
|
225 |
+
|
226 |
+
*Proportion of number of tokens per domain (English)*
|
227 |
+
<img src="https://github.com/Andrew-Wyn/images/blob/master/minerva/top_25_url_tokens_proportion_culturax_en.png?raw=true" alt="english-tok-counts" border="0" width="1800px">
|
228 |
+
-->
|
229 |
+
## Tokenizer Fertility
|
230 |
+
|
231 |
+
The tokenizer fertility measures the average amount of tokens produced per tokenized word.
|
232 |
+
A tokenizer displaying high fertility values in a particular language typically indicates that it segments words in that language extensively.
|
233 |
+
The tokenizer fertility is strictly correlated with the inference speed of the model with respect to a specific language,
|
234 |
+
as higher values mean longer sequences of tokens to generate and thus lower inference speed.
|
235 |
+
|
236 |
+
**Fertility computed over a sample of Cultura X (CX) data and Wikipedia (Wp):**
|
237 |
+
|
238 |
+
| Model | Voc. Size | Fertility IT (CX) | Fertility EN (CX) | Fertility IT (Wp) | Fertility EN (Wp) |
|
239 |
+
| --- | --- | --- |--- | --- |--- |
|
240 |
+
| Mistral-7B-v0.1 | 32000 | 1.87 | 1.32 | 2.05 | 1.57 |
|
241 |
+
| gemma-7b | 256000 | 1.42 | 1.18 | 1.56 | 1.34 |
|
242 |
+
| Minerva-3B-base-v1.0 | 32768 | 1.39 | 1.32 | 1.66 | 1.59 |
|
243 |
+
| Minerva-7B-base-v1.0 | 51200 | 1.32 | 1.26 | 1.56 | 1.51 |
|
244 |
+
|
245 |
+
<!-- ## Notice
|
246 |
+
|
247 |
+
Minerva-7B-base-v1.0 is a pretrained base model and, therefore, has no moderation mechanisms.
|
248 |
+
-->
|
249 |
+
## The Sapienza NLP Team
|
250 |
+
|
251 |
+
* **Riccardo Orlando:** data preprocessing, model training
|
252 |
+
* **Pere-Lluis Huguet Cabot:** data preprocessing, vocabulary, evaluation
|
253 |
+
* **Luca Moroni:** data curation, data analysis, downstream tasks, evaluation
|
254 |
+
* **Simone Conia:** data curation, evaluation, project supervision
|
255 |
+
* **Edoardo Barba:** data preprocessing, downstream tasks, project supervision
|
256 |
+
* **Roberto Navigli:** project coordinator
|
257 |
+
|
258 |
+
### Special thanks for their support
|
259 |
+
|
260 |
+
* Giuseppe Fiameni, Nvidia
|
261 |
+
* Sergio Orlandini, CINECA
|
262 |
+
|
263 |
+
## Acknowledgments
|
264 |
+
|
265 |
+
This work was funded by the PNRR MUR project [PE0000013-FAIR](https://fondazione-fair.it).
|
266 |
+
We acknowledge the [CINECA](https://www.cineca.it) award "IscB_medit" under the ISCRA initiative, for the availability of high performance computing resources and support.
|