CoolFace
Modelpublic

sapienzanlp/Minerva-7B-instruct-v1.0

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
25likes2.3kdownloads
Model Card

<div style="text-align: center; display: flex; flex-direction: column; align-items: center;"> <img src="https://huggingface.co/sapienzanlp/Minerva-7B-instruct-v1.0/resolve/main/minerva-logo.png" style="max-width: 550px; height: auto;"> </div>

Model Card for Minerva-7B-instruct-v1.0

Minerva is the first family of LLMs pretrained from scratch on Italian developed by Sapienza NLP in the context of the Future Artificial Intelligence Research (FAIR) project, in collaboration with CINECA and with additional contributions from Babelscape and the CREATIVE PRIN Project. Notably, the Minerva models are truly-open (data and model) Italian-English LLMs, with approximately half of the pretraining data including Italian text.

Description

This is the model card for Minerva-7B-instruct-v1.0, a 7 billion parameter model trained on almost 2.5 trillion tokens (1.14 trillion in Italian, 1.14 trillion in English and 200 billion in code).

This model is part of the Minerva LLM family:

🚨⚠️🚨 Bias, Risks, and Limitations 🚨⚠️🚨

This section identifies foreseeable harms and misunderstandings.

This is a chat foundation model, subject to model alignment and safety risk mitigation strategies. However, the model may still:

  • Overrepresent some viewpoints and underrepresent others
  • Contain stereotypes
  • Contain personal information
  • Generate:
  • Racist and sexist content
  • Hateful, abusive, or violent language
  • Discriminatory or prejudicial language
  • Content that may not be appropriate for all settings, including sexual content
  • Make errors, including producing incorrect information or historical facts as if it were factual
  • Generate irrelevant or repetitive outputs

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. For more information about this issue, please refer to our survey:

How to use Minerva with Hugging Face transformers

python
import transformers
import torch

model_id = "sapienzanlp/Minerva-7B-instruct-v1.0"

# Initialize the pipeline.
pipeline = transformers.pipeline(
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device_map="auto",
)

# Input text for the model.
input_conv = [{"role": "user", "content": "Qual è la capitale dell'Italia?"}]

# Compute the outputs.
output = pipeline(
  input_conv,
  max_new_tokens=128,
)

output

[{'generated_text': [{'role': 'user', 'content': "Qual è la capitale dell'Italia?"}, {'role': 'assistant', 'content': "La capitale dell'Italia è Roma."}]}]

Model Architecture

Minerva-7B-base-v1.0 is a Transformer model based on the Mistral architecture. Please look at the configuration file for a detailed breakdown of the hyperparameters we chose for this model.

The Minerva LLM family is composed of:

Model NameTokensLayersHidden SizeAttention HeadsKV HeadsSliding WindowMax Context Length
Minerva-350M-base-v1.070B (35B it + 35B en)161152164204816384
Minerva-1B-base-v1.0200B (100B it + 100B en)162048164204816384
Minerva-3B-base-v1.0660B (330B it + 330B en)322560328204816384
Minerva-7B-base-v1.02.48T (1.14T it + 1.14T en + 200B code)324096328None4096

Model Training

Minerva-7B-base-v1.0 was trained using llm-foundry 0.8.0 from MosaicML. The hyperparameters used are the following:

Model NameOptimizerlrbetasepsweight decaySchedulerWarmup StepsBatch Size (Tokens)Total Steps
Minerva-350M-base-v1.0Decoupled AdamW2e-4(0.9, 0.95)1e-80.0Cosine2%4M16,690
Minerva-1B-base-v1.0Decoupled AdamW2e-4(0.9, 0.95)1e-80.0Cosine2%4M47,684
Minerva-3B-base-v1.0Decoupled AdamW2e-4(0.9, 0.95)1e-80.0Cosine2%4M157,357
Minerva-7B-base-v1.0AdamW3e-4(0.9, 0.95)1e-50.1Cosine20004M591,558

SFT Training

The SFT model was trained using Llama-Factory. The data mix was the following:

DatasetSourceCodeEnglishItalian
Glaive-code-assistantLink100,00000
Alpaca-pythonLink20,00000
Alpaca-cleanedLink050,0000
Databricks-dolly-15kLink015,0110
No-robotsLink09,4990
OASST2Link029,000528
WizardLMLink029,8100
LIMALink01,0000
OPENORCALink030,0000
UltrachatLink050,0000
MagpieMTLink030,0000
Tulu-V2-ScienceLink07,0000
Aya_datasetsLink03,944738
Tower-blocks_itLink007,276
Bactrian-XLink0067,000
Magpie (Translated by us)Link0059,070
Everyday-conversations (Translated by us)Link002,260
alpaca-gpt4-itLink0015,000
capybara-claude-15k-itaLink0015,000
WildchatLink005,000
GPT4_INSTLink0010,000
Italian Safety Instructions-0021,426
Italian Conversations-004,843

For more details, please check our tech page.

Online DPO Training

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 library and Online DPO, with the 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, with additional manually curated data for safety.

For more details, please check our tech page.

Model Evaluation

For Minerva's evaluation process, we utilized ITA-Bench, a new evaluation suite to test the capabilities of Italian-speaking models. ITA-Bench is a collection of 18 benchmarks that assess the performance of language models on various tasks, including scientific knowledge, commonsense reasoning, and mathematical problem-solving.

<div style={{ display: 'flex', justifyContent: 'space-around' }}> <img src="https://huggingface.co/sapienzanlp/Minerva-7B-instruct-v1.0/resolve/main/Minerva%20LLMs%20Results.png" alt="Results on instructed models" style={{ width: '45%' }}></img> <img src="https://huggingface.co/sapienzanlp/Minerva-7B-instruct-v1.0/resolve/main/Minerva%20LLMs%20Results%20(1).png" alt="Results on instructed models" style={{ width: '45%' }}></img> </div>

<!-- Italian Data: --> <!-- | Task | Accuracy | | --- | --- | --> <!-- | xcopa (0-shot) | 0.694 | | Hellaswag (5-shot) | 0.5293 | | Belebele (5-shot) | 0.2333 | | TruthfulQA MC 1 (0-shot) | 0.2363 | | TruthfulQA MC 2 (0-shot) | 0.3731 | | M MMLU (5-shot) | 0.2612 | | arc challenge (5-shot) | 0.3268 | -->

<!-- English Data: --> <!-- | Task | Accuracy | | --- | --- | --> <!-- | Hellaswag (5-shot) | 0.6168 | | piqa (5-shot) | 0.7535 | | sciq (5-shot) | 0.925 | | Belebele (5-shot) | 0.2278 | | TruthfulQA MC 1 (0-shot) | 0.2142 | | TruthfulQA MC 2 (0-shot) | 0.3643 | | M MMLU (5-shot) | 0.263 | | arc challenge (5-shot) | 0.3319 | | arc easy (5-shot) | 0.6540 | -->

<!-- ## Training Data

Minerva-7B-base-v1.0 is trained on 1.14T Italian tokens, 1.14T English tokens, and 200B code tokens.

The training data is a mixture of the following datasets:

DatasetTokensLanguageEpochs
RedPajama-Data-V2687,952,502,784Italian1.3
CulturaX158,201,876,480Italian1.5
Wikipedia1,265,135,616Italian1.0
Gutenberg/Wikisource147,017,728Italian2.0
EurLex1,647,013,888Italian1.0
Gazzetta Ufficiale1,654,013,952Italian1.0
FineWeb1,076,406,624,256English1.0
Wikipedia5,259,501,568English1.0
ArXiv33,231,106,048English1.0
Gutenberg6,947,893,248English1.0
StackExchange22,069,268,480English1.0
The Stack V2200,754,900,992Code1.0-->

<!-- We have extracted some statistics on Italian (115B tokens) and English (210B tokens) documents from CulturaX on the selected sources:

Proportion of number of tokens per domain (Italian) <img src="https://github.com/Andrew-Wyn/images/blob/master/minerva/top25urltokensproportionculturaxit.png?raw=true" alt="italian-tok-counts" border="0" width="1800px">

Proportion of number of tokens per domain (English) <img src="https://github.com/Andrew-Wyn/images/blob/master/minerva/top25urltokensproportionculturaxen.png?raw=true" alt="english-tok-counts" border="0" width="1800px"> -->

Tokenizer Fertility

The tokenizer fertility measures the average amount of tokens produced per tokenized word. A tokenizer displaying high fertility values in a particular language typically indicates that it segments words in that language extensively. The tokenizer fertility is strictly correlated with the inference speed of the model with respect to a specific language, as higher values mean longer sequences of tokens to generate and thus lower inference speed.

Fertility computed over a sample of Cultura X (CX) data and Wikipedia (Wp):

ModelVoc. SizeFertility IT (CX)Fertility EN (CX)Fertility IT (Wp)Fertility EN (Wp)
Mistral-7B-v0.1320001.871.322.051.57
gemma-7b2560001.421.181.561.34
Minerva-3B-base-v1.0327681.391.321.661.59
Minerva-7B-base-v1.0512001.321.261.561.51

<!-- ## Notice

Minerva-7B-base-v1.0 is a pretrained base model and, therefore, has no moderation mechanisms. -->

The Sapienza NLP Team

🧭 Project Lead and Coordination

  • _Roberto Navigli_: project lead and coordination; model analysis, evaluation and selection, safety and guardrailing, conversations.

🤖 Model Development

  • _Edoardo Barba_: pre-training, post-training, data analysis, prompt engineering.
  • _Simone Conia_: pre-training, post-training, evaluation, model, and data analysis.
  • _Pere-Lluís Huguet Cabot_: data processing, filtering,g and deduplication, preference modeling.
  • _Luca Moroni_: data analysis, evaluation, post-training.
  • _Riccardo Orlando_: pre-training process and data processing.
👮 Safety and Guardrailing
  • _Stefan Bejgu_: safety and guardrailing.
  • _Federico Martelli_: synthetic prompt generation, model and safety analysis.
  • _Ciro Porcaro_: additional safety prompts.
  • _Alessandro Scirè_: safety and guardrailing.
  • _Simone Stirpe_: additional safety prompts.
  • _Simone Tedeschi_: English dataset for safety evaluation.

Special thanks for their support

  • Giuseppe Fiameni, Nvidia
  • Sergio Orlandini, CINECA

Acknowledgments

This work was funded by the PNRR MUR project PE0000013-FAIR and the CREATIVE PRIN project, which is funded by the MUR Progetti di Rilevante Interesse Nazionale programme (PRIN 2020). We acknowledge the CINECA award "IscB_medit" under the ISCRA initiative for the availability of high-performance computing resources and support.