Instructions to use sapienzanlp/Minerva-3B-base-v1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sapienzanlp/Minerva-3B-base-v1.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sapienzanlp/Minerva-3B-base-v1.0")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sapienzanlp/Minerva-3B-base-v1.0") model = AutoModelForCausalLM.from_pretrained("sapienzanlp/Minerva-3B-base-v1.0") - llama-cpp-python
How to use sapienzanlp/Minerva-3B-base-v1.0 with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="sapienzanlp/Minerva-3B-base-v1.0", filename="minerva-3b.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use sapienzanlp/Minerva-3B-base-v1.0 with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf sapienzanlp/Minerva-3B-base-v1.0 # Run inference directly in the terminal: llama-cli -hf sapienzanlp/Minerva-3B-base-v1.0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf sapienzanlp/Minerva-3B-base-v1.0 # Run inference directly in the terminal: llama-cli -hf sapienzanlp/Minerva-3B-base-v1.0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf sapienzanlp/Minerva-3B-base-v1.0 # Run inference directly in the terminal: ./llama-cli -hf sapienzanlp/Minerva-3B-base-v1.0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf sapienzanlp/Minerva-3B-base-v1.0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf sapienzanlp/Minerva-3B-base-v1.0
Use Docker
docker model run hf.co/sapienzanlp/Minerva-3B-base-v1.0
- LM Studio
- Jan
- vLLM
How to use sapienzanlp/Minerva-3B-base-v1.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sapienzanlp/Minerva-3B-base-v1.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sapienzanlp/Minerva-3B-base-v1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/sapienzanlp/Minerva-3B-base-v1.0
- SGLang
How to use sapienzanlp/Minerva-3B-base-v1.0 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sapienzanlp/Minerva-3B-base-v1.0" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sapienzanlp/Minerva-3B-base-v1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sapienzanlp/Minerva-3B-base-v1.0" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sapienzanlp/Minerva-3B-base-v1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use sapienzanlp/Minerva-3B-base-v1.0 with Ollama:
ollama run hf.co/sapienzanlp/Minerva-3B-base-v1.0
- Unsloth Studio new
How to use sapienzanlp/Minerva-3B-base-v1.0 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for sapienzanlp/Minerva-3B-base-v1.0 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for sapienzanlp/Minerva-3B-base-v1.0 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for sapienzanlp/Minerva-3B-base-v1.0 to start chatting
- Docker Model Runner
How to use sapienzanlp/Minerva-3B-base-v1.0 with Docker Model Runner:
docker model run hf.co/sapienzanlp/Minerva-3B-base-v1.0
- Lemonade
How to use sapienzanlp/Minerva-3B-base-v1.0 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull sapienzanlp/Minerva-3B-base-v1.0
Run and chat with the model
lemonade run user.Minerva-3B-base-v1.0-{{QUANT_TAG}}List all available models
lemonade list
Model Card for Minerva-3B-base-v1.0
Minerva is the first family of LLMs pretrained from scratch on Italian developed by Sapienza NLP in collaboration with Future Artificial Intelligence Research (FAIR) and CINECA. 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-3B-base-v1.0, a 3 billion parameter model trained on 660 billion tokens (330 billion in Italian, 330 billion in English).
This model is part of the Minerva LLM family:
- Minerva-350M-base-v1.0
- Minerva-1B-base-v1.0
- Minerva-3B-base-v1.0
- Minerva-7B-base-v1.0
- Minerva-7B-instruct-v1.0
🚨⚠️🚨 Bias, Risks, and Limitations 🚨⚠️🚨
This section identifies foreseeable harms and misunderstandings.
This is a foundation model, not subject to alignment. Model may:
- 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
import transformers
import torch
model_id = "sapienzanlp/Minerva-3B-base-v1.0"
# Initialize the pipeline.
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
# Input text for the model.
input_text = "La capitale dell'Italia è"
# Compute the outputs.
output = pipeline(
input_text,
max_new_tokens=128,
)
# Output:
# [{'generated_text': "La capitale dell'Italia è la città di Roma, che si trova a [...]"}]
Model Architecture
Minerva-3B-base-v1.0 is a Transformer model based on the Mistral architecture, where the number of layers, number of heads, and the hidden states dimension are modified to reach 3B parameters. Please, take a 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 Name | Tokens | Layers | Hidden Size | Attention Heads | KV Heads | Sliding Window | Max Context Length |
|---|---|---|---|---|---|---|---|
| Minerva-350M-base-v1.0 | 70B (35B it + 35B en) | 16 | 1152 | 16 | 4 | 2048 | 16384 |
| Minerva-1B-base-v1.0 | 200B (100B it + 100B en) | 16 | 2048 | 16 | 4 | 2048 | 16384 |
| Minerva-3B-base-v1.0 | 660B (330B it + 330B en) | 32 | 2560 | 32 | 8 | 2048 | 16384 |
Model Training
Minerva-3B-base-v1.0 was trained using llm-foundry 0.6.0 from MosaicML. The hyperparameters used are the following:
| Model Name | Optimizer | lr | betas | eps | weight decay | Scheduler | Warmup Steps | Batch Size (Tokens) | Total Steps |
|---|---|---|---|---|---|---|---|---|---|
| Minerva-350M-base-v1.0 | Decoupled AdamW | 2e-4 | (0.9, 0.95) | 1e-8 | 0.0 | Cosine | 2% | 4M | 16,690 |
| Minerva-1B-base-v1.0 | Decoupled AdamW | 2e-4 | (0.9, 0.95) | 1e-8 | 0.0 | Cosine | 2% | 4M | 47,684 |
| Minerva-3B-base-v1.0 | Decoupled AdamW | 2e-4 | (0.9, 0.95) | 1e-8 | 0.0 | Cosine | 2% | 4M | 157,357 |
Model Evaluation
We assessed our model using the LM-Evaluation-Harness library, which serves as a comprehensive framework for testing generative language models across a wide range of evaluation tasks.
All the reported benchmark data was already present in the LM-Evaluation-Harness suite.
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-3B-base-v1.0 was trained on 330B Italian tokens and 330B English tokens sampled from CulturaX.
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)

Proportion of number of tokens per domain (English)

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):
| Model | Voc. Size | Fertility IT (CX) | Fertility EN (CX) | Fertility IT (Wp) | Fertility EN (Wp) |
|---|---|---|---|---|---|
| Mistral-7B-v0.1 | 32000 | 1.87 | 1.32 | 2.05 | 1.57 |
| gemma-7b | 256000 | 1.42 | 1.18 | 1.56 | 1.34 |
| Minerva-3B-base-v1.0 | 32768 | 1.39 | 1.32 | 1.66 | 1.59 |
Notice
Minerva-3B-base-v1.0 is a pretrained base model and, therefore, has no moderation mechanisms.
The Sapienza NLP Team
- Riccardo Orlando: data preprocessing, model training
- Pere-Lluis Huguet Cabot: data preprocessing, vocabulary, evaluation
- Luca Moroni: data curation, data analysis, downstream tasks, evaluation
- Simone Conia: data curation, evaluation, project supervision
- Edoardo Barba: data preprocessing, downstream tasks, project supervision
- Roberto Navigli: project lead and coordination
Special thanks for their support
- Giuseppe Fiameni, Nvidia
- Sergio Orlandini, CINECA
Acknowledgments
This work was funded by the PNRR MUR project PE0000013-FAIR. We acknowledge the CINECA award "IscB_medit" under the ISCRA initiative, for the availability of high performance computing resources and support.
- Downloads last month
- 4,983
# Gated model: Login with a HF token with gated access permission hf auth login